ARRAY - Making DATA STRUCTURES in C++

Sdílet
Vložit
  • čas přidán 16. 07. 2020
  • The first 1000 people who click the link will get 2 free months of Skillshare Premium: skl.sh/thechernoproject10
    Patreon ► / thecherno
    Instagram ► / thecherno
    Twitter ► / thecherno
    Discord ► thecherno.com/discord
    Series Playlist ► thecherno.com/cpp
    This video was sponsored by Skillshare.

Komentáře • 240

  • @TheCherno
    @TheCherno  Před 4 lety +43

    Thanks for watching! Don't forget that the first 1000 people who click the link will get 2 free months of Skillshare Premium: skl.sh/thechernoproject10

    • @swapnilbhave3767
      @swapnilbhave3767 Před 4 lety +2

      Watched your all C++ vidoes.. those are awesome.. thanks for this video waiting for STL from long time

    • @skillerraptor8669
      @skillerraptor8669 Před 4 lety

      Damn I cannot take it.

    • @ketanlalcheta4558
      @ketanlalcheta4558 Před 4 lety

      Not able to sign up

    • @amirasyraf3352
      @amirasyraf3352 Před 4 lety

      Just wanna say thank you so much for the Skillshare offer.
      Can't wait to study more programming and game design! :D

    • @aqezzz
      @aqezzz Před 4 lety

      Thanks for this, I've been wanting to try it! Got in on it!

  • @ethansuresh2322
    @ethansuresh2322 Před 4 lety +246

    Suggestion: video on CMAKE, makefiles, etc

    • @kaoti
      @kaoti Před 4 lety +5

      YES PLEASE

    • @jscorpio1987
      @jscorpio1987 Před 4 lety +13

      Somebody asks that on almost every one of those videos and I’m pretty sure the reason he hasn’t done a video on the subject is because Makefiles, etc., aren’t part of the C++ language, and this is a C++ language tutorial. Plus, he uses visual studio, which doesn’t use Makefiles, so it would be pointless.

    • @klauseternal3381
      @klauseternal3381 Před 4 lety +15

      @@jscorpio1987 you could say it's a null pointer

    • @leocarvalho8051
      @leocarvalho8051 Před 4 lety +3

      He doesnt even use cmake and makefile is not usefull to him since he uses windows+vstudio only

    • @deathscreton
      @deathscreton Před 3 lety +7

      Those are poor excuses for not doing it. Plenty of projects that use C++ make use of cmake or make files. He probably runs into them quite a bit, especially with open source projects.

  • @muhammadaamirzaman
    @muhammadaamirzaman Před 4 lety +86

    Waiting for data structures for a looooong time super excited for this series

  • @1973Washu
    @1973Washu Před 4 lety +43

    Suggestion: linked lists then binary trees.
    My knowledge of this area is a little patchy and hearing a second expert explanation of a topic is always welcome.

    • @locomotivere4497
      @locomotivere4497 Před 4 lety

      cool

    • @nallid7357
      @nallid7357 Před 4 lety +3

      I agree with this order, binary trees are in of themselves a linked list. Hopefully he'll explain doubly, single, and circular linked lists sometime soon.

    • @soniablanche5672
      @soniablanche5672 Před 6 měsíci

      ​@@nallid7357 Not all. You can implement binary heap with an array.

  • @ShivamJha00
    @ShivamJha00 Před 4 lety +32

    Definitely need video on implementing iterator please

    • @jamesmnguyen
      @jamesmnguyen Před 4 lety +2

      A really super simple forward iterator is literally just a pointer. So part of your goal is already done.

    • @oracleoftroy
      @oracleoftroy Před 4 lety +1

      @@jamesmnguyen Yeah, but that only works for two data structures, vector and array, and the latter works because arrays decay into pointers. Implementing iterators for anything else is more complicated.

    • @maksymiliank5135
      @maksymiliank5135 Před 4 lety +1

      @@oracleoftroy Iterators for linked lists are also pretty easy. It gets harder for trees though, because you need to figure out the logic to access every element in the right order. Especially if it is a search tree, where the order is important

    • @nashaut7635
      @nashaut7635 Před 4 lety +1

      @@maksymiliank5135 ... which is indeed one good reason to look forward for a tutorial from The Cherno. That promises to be quite exciting.

  • @wesleythomas6858
    @wesleythomas6858 Před 4 lety +12

    Love raw breakdowns like this. This quality is what makes your channel unique 👍

  • @darthxertor3617
    @darthxertor3617 Před 4 lety +2

    Awesome man! Very glad you opted to start delving into data structures and algorithms in your C++ vids! Very much looking forward to more of these! Thanks so much.

  • @woofelator
    @woofelator Před 4 lety +1

    I'm glad you're doing this series lmao. I took a data structures course at my university last year, and now I can keep myself refreshed on the material through these videos so I don't forget all these concepts

  • @BobStraitFTW
    @BobStraitFTW Před 4 lety +10

    I've wanted to this exact thing for a long time and was never able to fit the pieces together. Thank you. :D

  • @ajj7794
    @ajj7794 Před 4 lety +3

    i love you for doing this. 1 BIG recommedation is to move this videos to early parts of the playlist. many thanks. love your work!

  • @tonychristney2728
    @tonychristney2728 Před 4 lety

    That "noise" at the top is very useful. It allows you to write things like using container = std::array; container x; memset(x.data(), 0, x.size() * sizeof(container::value_type));
    Then when you need to change int to uint64_t or uint8_t, you only need to change it in one place. Putting sizeof(int) in that memset is buffer overflow waiting to happen.

  • @griimick
    @griimick Před 4 lety +3

    Thanks for this series. The stack and heap allocation just made me smile.

  • @rcookie5128
    @rcookie5128 Před 4 lety

    This series is super helpfull! :)
    Edit: Also, the way Cherno explains the things (dissected and explained step by step, from basic functionality too the more complex results) is so much better then most written documentation you can find..

  • @thanostitan.infinity
    @thanostitan.infinity Před 4 lety +1

    I was waiting soo eagerly for this 🙏🏼 your videos have become my bread butter daily these days haha.
    Thanks so much for sharing all your knowledge cherno!

  • @ParkerPlaysPC
    @ParkerPlaysPC Před 4 lety +1

    Love this data structure focused video in the C++ series. Please keep the coming!

  • @fmt2586
    @fmt2586 Před 4 lety

    Thank you So Much , you are the best channel i've seen ... you are beyond professional. You are my inspiration in learning c++ and, i hope you keep making videos, love you Cherno.

  • @nextrie
    @nextrie Před 4 lety +3

    Simply brilliant, Cherno! Keep them coming!

  • @SOLZandSAGE
    @SOLZandSAGE Před 4 lety +20

    Could you do a video on ideas for projects beginners/intermediate C++ programmers could do to add on to their resume? Currently going into my 3rd year in college, and I'm looking to apply for internships for next summer, but I don't really have any projects to put on my resume nor do I know where to start.

  • @practicalsoftwaremarcus
    @practicalsoftwaremarcus Před 4 lety +6

    Thank you so much ! Looking forward for the iteraror implementation. Also, I'd like to see you talk about boost library, more specifically boost::bind methods (also also, I believe they have been integrated into STD by now)

  • @hafsahmr9010
    @hafsahmr9010 Před 4 lety +1

    Waited for this for so long! Looking forward.

  • @mohammednihad6755
    @mohammednihad6755 Před 4 lety

    I'm really gonna LOVE this! I was always trying to implement different STL classes that I use and love myself. And also to expand and add upon them. My favourite ones were String and List(dynamic array).
    Thanks a lot for your great content Yan 💙💙

    • @lionkor98
      @lionkor98 Před 4 lety

      std::list is not a dynamic array ;)

  • @osman9750
    @osman9750 Před 4 lety

    Love this style where the video zooms in on the code and it is easier to see.👍

  • @soniamh8839
    @soniamh8839 Před 3 lety

    My very favourite topic in C++ : data structures. Thank you so looking forward to it.

  • @nastarankouhdareh8354
    @nastarankouhdareh8354 Před 4 lety +1

    Thank you Cherno! was helpful as always.

  • @ianpan0102
    @ianpan0102 Před 3 lety

    Definitely gave me more insight regarding OOP and templates!

  • @badwolf8112
    @badwolf8112 Před 4 lety

    glad you're making data structs & algos series.
    would also be good to mention using arrays unless you need optimization is bad practice, and more generally optimizing before you need to. and it would be nice if you go into some of the nitty gritty details about why there's an overhead from not keeping your data contiguous; it's not self evident, and especially mysterious if you know your programs use virtual memory.

  • @DanishRaza-ji2du
    @DanishRaza-ji2du Před 4 lety

    Loved your videos. Learning so much.

  • @vojinmilovic2802
    @vojinmilovic2802 Před 4 lety +1

    This was so helpful! Thanks

  • @sasoyu8922
    @sasoyu8922 Před 4 lety +1

    Awesome! Can't wait to see the next DS 😍

  • @anupkodlekere8604
    @anupkodlekere8604 Před 4 lety +2

    Would love it if you would do more of these!

  • @shashikantpawar7069
    @shashikantpawar7069 Před 4 lety

    Thank you so much 🙂. What a great series of c++..

  • @sukhrajrandhawa5195
    @sukhrajrandhawa5195 Před 4 lety

    Would love to see videos implementing data structures of other STL containers like vectors and strings with things such as iterators within them in the future. Anyway, great video :)

  • @CosmJJ
    @CosmJJ Před 4 lety

    Thanks, Cherno! Your channel is a real treasure)

  • @yijirong6518
    @yijirong6518 Před 2 lety

    best cover of data structure. Thanks for sharing

  • @kavishshah6441
    @kavishshah6441 Před 4 lety +2

    Yes more of this please

  • @petrkassadinovich2705
    @petrkassadinovich2705 Před 4 lety

    I found this very useful, thank you!

  • @matthewcorbett8637
    @matthewcorbett8637 Před 4 lety

    Great Video! I just made a dynamic array and a doubly linked list last semester. It is so much harder than it oringinally sounded. Would love to see how to create a (un)ordered (multi)map or a priority tree of some sort! Thanks again! :)

  • @pawelkikta
    @pawelkikta Před 4 lety

    Thank you Cherno. Admire your work.

  • @floatingpointerror55
    @floatingpointerror55 Před 4 lety

    Great refresher!!!♡☆

  • @PrinceGupta-jo8lo
    @PrinceGupta-jo8lo Před 4 lety +22

    Suggestion: templated version of segment tree.
    I know it's not that important but if you find time, it'll be pretty interesting to do.

  • @xvoidee
    @xvoidee Před 4 lety

    Live demos are cool! Hopefully I will see you on some gamedev/cpp conference as a speaker.

  • @jgurtz
    @jgurtz Před 4 lety +1

    Nice, would be lovely to see you cover tree-based data structures. probably after linked lists.

  • @patrickmetznermorais2868
    @patrickmetznermorais2868 Před 4 lety +28

    Great videos!!!
    Could you make a video about UNIT TESTs in C++?

  • @evilcorp.7288
    @evilcorp.7288 Před 4 lety

    The content....Love it 🔥

  • @noahrosser7006
    @noahrosser7006 Před 4 lety +1

    Thank you

  • @Zerefse
    @Zerefse Před 11 měsíci

    thanks for the explanation😊

  • @chippandenga6722
    @chippandenga6722 Před 3 lety

    You are running through the material so fast, you cannot be teaching. You are not teaching what you are talking about but running through the material demonstrating how well you know it. But, for someone trying to learn, it all flies over my head.

  • @buchnejf
    @buchnejf Před 4 lety +1

    Great Great Great! video. What a great video to watch while drinking my morning coffee ;)

  • @rohitrajak5128
    @rohitrajak5128 Před 4 lety +1

    AVL trees intrigue me and I'd love to see them in a future video

  • @Thebreak1
    @Thebreak1 Před 4 lety

    Nice video as always ^^
    I'd like to see some implementation of Dictionaries and maybe showing that with hash functions. I only understand that they are probably used for that, but I wonder how you actually use them effective. Wondering how much space to allocate and still use hashes.

  • @bulentgercek
    @bulentgercek Před 3 lety

    I dislike all those who hit the dislike button. Thanks for that beautiful lesson Cherno!

  • @aleksandrzhilkin826
    @aleksandrzhilkin826 Před 3 lety

    Honestly, I did not touch c++ since 3rd year at uni. This video made ne remember a lot about c++ and tought me more about it than 2 hours at uni ever did)
    Def subscribed coaus of that. Even though I don't use c++ at work)

  • @xavierreigneau41
    @xavierreigneau41 Před 2 lety +2

    In case you need it, here is the source code of the array data structure:
    #include
    #include
    template
    class Array{
    public:
    constexpr size_t Size() const {
    return S;
    }
    T& operator[](size_t index){
    return m_Data[index];
    }
    const T& operator[](size_t index) const{
    return m_Data[index];
    }
    T* Data(){
    return m_Data;
    }
    const T* Data() const {
    return m_Data;
    }
    private:
    T m_Data[S];
    };
    int main(){
    Array data;
    data[0] = "Cherno";
    data[1] = "C++";
    data[2] = "We";
    data[3] = "Love";
    data[4] = "Programming!";
    for(size_t i = 0; i

  • @smileynetsmileynet7922
    @smileynetsmileynet7922 Před 4 lety +1

    I'd love to see a simple compiler series using flex and bison to generate a abstract syntax tree that is class based. Then see it in action. An AST that can be reused in other languages you work on.

  • @dhruvpatel3323
    @dhruvpatel3323 Před 4 lety

    Cherno this C++ series is legendary

  • @dekrain
    @dekrain Před 4 lety

    A few remarks
    The STL array has its underlying array field public to allow for aggregate initialization, like you can do with a plain array.
    All the type members like pointer, const_iterator, etc. are actually required by the standard, not just in MSVC implementation

  • @zubaeralam9202
    @zubaeralam9202 Před 4 lety +24

    I am an undergraduate student. I already love your content and find it really inspiring. But can you please do more content related to basics and Data Structures?

  • @swapnilbhave3767
    @swapnilbhave3767 Před 4 lety +1

    Waiting for this

  • @hongquangvu3091
    @hongquangvu3091 Před 4 lety +1

    That is exactly what i want to learn.

  • @maxscriptguru
    @maxscriptguru Před 27 dny

    People, never ever in a million years do a memset call like was shown in this video. That is allowing external code to operate in the private parts of the class. Place the memory setting code INSIDE the class. That code there I would have marked as needs work if I ever saw it in a pull request.

  • @init_yeah
    @init_yeah Před 4 lety

    Thanks again

  • @carsonholloway
    @carsonholloway Před 4 lety +2

    FINALLY!! I've been waiting for a DATA STRUCTURES series for what feels like ages. Much appreciated!!

  • @refikalpertuncer8512
    @refikalpertuncer8512 Před 4 lety

    dude you are a god

  • @harishkantsoni9977
    @harishkantsoni9977 Před 4 lety

    thanks for the video

  • @thatGuyFean
    @thatGuyFean Před 3 lety

    you know , I had sworn that I will never understand loops but after watching your video on the topic , I am on the safe side now, I guess, Thanks man....

  • @legolas5684
    @legolas5684 Před 4 lety +1

    More videos like this pls pls!!!!!!!!!

  • @AnalogDude_
    @AnalogDude_ Před 3 lety

    nice & usefull video

  • @Xxp0r
    @Xxp0r Před 4 lety

    Exception handling, and whether or not to use them please :)

  • @stepanhrbek8151
    @stepanhrbek8151 Před 3 lety

    Great video! Suggestion: I would really like to know what constexpr and noexcept are...

  • @patrickes4540
    @patrickes4540 Před 4 lety

    Very good content as always. In one of the first videos (video 2 of C++ Series) I downloaded your vs settings. They seems to have changed. Do you update the link or give a one with your updated settings?

  • @nobody2937
    @nobody2937 Před 2 lety

    Cherno, can you please make a video to explain the difference between constexpr and const ? Thank you ...

  • @ChlorieHCl
    @ChlorieHCl Před 4 lety +3

    While arrays may be easy to deal with, I would certainly like to see you implement some much more complex types like tuple. XD
    Also, those size_type things are required by the standard, so that template meta-programming on std containers is easier.
    std::array are implemented as a struct containing a public member of the array, which makes the struct an aggregate, that enables the aggregate initialization syntax (like std::array array{ 0,1,2,3,4 };) without requiring any constructor to be implemented manually.

    • @sebastiangudino9377
      @sebastiangudino9377 Před 2 lety

      How is a tuple complex?

    • @ChlorieHCl
      @ChlorieHCl Před 2 lety

      @@sebastiangudino9377 Try implement a tuple type yourself and you'll see.

  • @vexedev
    @vexedev Před 3 lety

    The problem I had with these types of structures is that it becomes annoying to pass the arrays around in functions. since Array is a completely different type than Array unless there's some magical c++ way to do it...

  • @benoitrousseau4137
    @benoitrousseau4137 Před 4 lety

    Careful with alloca(), it is non-standard (even in C) I think it's only standardized by POSIX, which makes sense because Microsoft's version easily breaks in try/catch blocks. alloca() does have its uses, but if you can get away with a stack array or a SmallVector, you probably want to use that instead.

  • @davidmiller3867
    @davidmiller3867 Před 4 lety

    Great!!!

  • @aquavitale3551
    @aquavitale3551 Před 4 lety

    Looking forward to Cherno making his own mini-stl

  • @yavuzselimcagan5233
    @yavuzselimcagan5233 Před 2 lety

    Awesome

  • @basitsaeed9705
    @basitsaeed9705 Před 4 lety

    WE WANT MORE DATA STRUCT VIDEOS les goo

  • @ShivamJha00
    @ShivamJha00 Před 4 lety

    Wow continue doing data structure please

  • @MdSheraj
    @MdSheraj Před 4 lety

    Please cover unit tests and tuples implementation.

  • @nrgamepoint3132
    @nrgamepoint3132 Před 3 lety

    hi bro can u start the data structures and mainly algorithm series if u have time.im eagerly looking for that series. or can u point where i can learn those concepts really good.

  • @MonteLogic
    @MonteLogic Před 3 lety

    Great, no 2-minute long intro that has nothing to do with the video, great!

  • @Girugi
    @Girugi Před 4 lety +4

    The alloca has a larger issue there. Unrelated to performance. The problem is that it will be freed after the constructor retutn/exit the scope of the function. Meaning you can not use it like that. Only way to get around that is to make the allocation in the scope where the object is created.
    If you do it like you did it might compile and work in some cases. But in reality you are using stack memory that the program sees as free and might be occupied by other stuff. So it's an undefined behavior.
    Alloca is awesome, but dangerous if used wrong like that. Should make eha clear.

  • @karimkohel3240
    @karimkohel3240 Před 4 lety

    YESSSSS

  • @moeal5110
    @moeal5110 Před 3 lety

    suggestion: please keep your video without any background music. NO MUSIC, please
    I love your video they are informative and concise.

  • @ThisRandomUsername
    @ThisRandomUsername Před 4 lety +1

    Suggestion: I know this isn't a data structure, but somewhat related. Could you talk about endianness and how to deal with it? I suppose this is more to do with data punning than anything, but as a firmware engineer working in c, it would be nice to know how one deals with it in c++.

  • @luandkg
    @luandkg Před 3 lety

    Continue this, Implement other data structures like List Set Map Binary Tree

  • @zhupdhk
    @zhupdhk Před 4 lety +2

    Does anyone know which theme he uses for Visual Studio?

  • @TheApsiiik
    @TheApsiiik Před 4 lety

    What if I want put my array in function method? I don't want care about size. I want use Size()! Again, I have to use template?
    tamplate
    function doSomthing(Array arr){
    ...
    }?
    So if i have hundred or thousand of diffrent arrays I have to alwase make copy of function who will do stuf?
    Did I miss understand it?
    Should I create second function to handle size ? To avoid make copy of huge block of code? Grrr... More I am thinking about it, more it become complicated.

  • @zoriiginalx7544
    @zoriiginalx7544 Před 4 lety

    Awesome! Would love to see more data structure videos :)

  • @Yupppi
    @Yupppi Před 8 měsíci

    I dig arrays but it feels like whenever I'm writing a program (mind you I'm not a programmer by education or profession, I just have had some classes in my degree), it's a case where you ask the user the size of the container (or the data set to be more accurate) if you're not reading it from a file. And c++ doesn't let me get that size, then create an array with that size and use it, it demands a const size that apparently needs to be set at compiling.
    Although at some point I somehow managed to make it compile with the user input variable size for array size, I have no idea why. It got very upset some days later and redlined it hard. Somehow I had managed to make some sort of loophole around it. Maybe it treated it as heap allocated somehow.
    It would be really nice to get those turned into stack allocated arrays though, because every function used all the data in the container.
    Maybe if there was a good idea of the limits of the data set, but I find that the programs I've written to help with some stuff should allow quite big sets, even though I might use it for small sets especially in testing.
    In general, I find that most if not all of my programs revolve around asking user input and then calculating something. Programming would be so nice if it was done without user inputs. Especially Rust would be nice to use without.

  • @sun4502
    @sun4502 Před 4 lety

    Can't you use const for the size issue ? You said template is the only solution for that issue.

  • @nyx1284
    @nyx1284 Před 3 lety

    I find it interesting that the debugbreak doesn't work on the const reference of our array.

  • @_Omni
    @_Omni Před 4 lety

    _malloca should be used, it is a version of alloca with security enhancements.

  • @naturallyweird661
    @naturallyweird661 Před 4 lety

    Hey how do I add external libraries in visual studio please ...

  • @user-if1ey5sm1v
    @user-if1ey5sm1v Před 4 lety

    Hey just wondering if I can get your visual studio config in terms of colors? Hope you understand what I mean

  • @mohammednihad6755
    @mohammednihad6755 Před 4 lety

    We can technically define:
    const int size = 7;
    And before using it to define an array, we can change its value via a pointer like this:
    int c = 5;
    const int a(c);
    cin >> (*(&c + 1));
    int array[a]
    //////////
    Now I know that array size must be declared at compile time but this just works... I wonder what strange behaviours will be caused by this hmmmmm...

  • @FreeDomSy-nk9ue
    @FreeDomSy-nk9ue Před 4 lety +1

    Would you make a video about constexpr and noexcept

  • @jawman311
    @jawman311 Před 3 lety

    Is there a reason the Data() function returns a pointer rather than an address like the operator[] function? I saw your references video and know they are very similar, but not sure if it matters in this case.
    Thanks for these awesome videos by the way!

  • @jorgejarai
    @jorgejarai Před 4 lety

    The TAs at my Data Structures class allocate *everything* in the heap, even objects which already allocate to the heap by themselves. And they don't even care about releasing the used memory before ending the program.
    The program may compile and run one way or the other, but I think that's a very bad habit (and bad habits die hard). At least they could tell us we shouldn't do that in production environments or something like that.

    • @lionkor98
      @lionkor98 Před 4 lety

      Those people usually come from Java where you "new" everything and never delete