C++ STL: Vector vs List

Поделиться
HTML-код
  • Опубликовано: 17 сен 2024
  • This video has some errors, I made a followup vid with corrections:
    • Amendment to Vector vs...
    In this video we'll look at the STL (Standard Template Library). This is a library of commonly used data types and algorithms, created so we don't need to waste time re-programming these fundamental things ourselves.
    The main focus of this video is to compare two of the most common data structures: The vector and the List. They are both used to hold a dynamic number of items, like arrays but you can add and remove items. But they have some interesting differences.
    The vector is best when you need random access to the elements. And/Or, when you do not need to add items to the beginning or the middle of the vector.
    Lists are best when you don't need random access to elements, and/or you need to add items to the beginning or the middle.
    Ps. Sorry about the horrid slides. The color is awful ... :(
    Become a patron and support What's a Creel programming vids on Patreon:
    www.patreon.com/whatsacreel
    FaceBook:
    pages/WhatsaCreel/167732956665435

Комментарии • 49

  • @communistgoatboy
    @communistgoatboy 8 лет назад +3

    When traversing sequence containers, don't forget about range-based for loops. :)
    for(auto &e : container) { std::cout

    • @WhatsACreel
      @WhatsACreel  8 лет назад

      +communistgoatboy Brilliant! I made an amendment vid thanking you people and (hopefully) righting some of my blunders in this vid. Thanks for watching and commenting, and I hope I've not lost you.
      Link to amendment is:
      ruclips.net/video/N6aZ0eEzzUg/видео.html

    • @AndyU96
      @AndyU96 6 лет назад

      Why do you not use 'using namespace std;'?

  • @ExoContinuum
    @ExoContinuum 7 лет назад +6

    Just discovered your channel. You are incredibly amazing at explaining things quickly and precisely. Thanks a bunch, man!

  • @leerv.
    @leerv. 5 лет назад +3

    For any newbies watching, the .push_back and .pop_back vector methods may be named to sound like the the way items are handled in stack memory. You "push" the latest item onto the top of the stack and to remove the latest item you "pop" it off the stack. I'm only speculating here, though.

    • @WhatsACreel
      @WhatsACreel  5 лет назад +2

      Cheers mate! I think you're spot on there! They seem to have taken the syntax from stacks. Thanks for watching brus :)

  • @Davidemmanuelkatz
    @Davidemmanuelkatz 4 года назад +2

    this is the best kangaroo programming channel in the world. Love the accent! Love the channel!

  • @kaleabmamo4205
    @kaleabmamo4205 6 лет назад +1

    What a brief explanation, please keep it up. Thank you

  • @bakensaken6745
    @bakensaken6745 3 года назад +1

    Surprizingly good explaination! I watched other videos on the subject but this one taught me most.

  • @dennisrkb
    @dennisrkb 4 года назад +1

    *Adding items in the middle is not a use case of lists. 99% of the time, the required traversal to get to the middle element will take longer than copying half a vector's elements.

  • @epickittylover489
    @epickittylover489 8 лет назад +3

    WOOHOO!!!

  • @AsifMohammedSifat
    @AsifMohammedSifat Год назад

    What an explanation!! Thank You.

  • @tanishq2766
    @tanishq2766 2 года назад

    Are you Feynmann's son mate? :)
    Great Explanation !

  • @RurikLoderr
    @RurikLoderr 4 года назад

    Can you do any linear algebra with the vectors? Or would that be something you used a specialized library for?

  • @AdminDarkraiRSK
    @AdminDarkraiRSK 5 лет назад +1

    just fantastic

    • @WhatsACreel
      @WhatsACreel  5 лет назад +1

      Thank you brus! Cheers for watching :)

  • @sagivalia5041
    @sagivalia5041 2 года назад

    Since an iterator of a list is a pointer to the first element with the .begin()
    couldn't you just, according to the demo, simply said *(poslist+50+i)?

  • @Landofjello
    @Landofjello 4 года назад

    Do I have to put v.begin() + 1 as the argument for v.erase(), or can I just put the index?

  • @yasamanderiszadeh902
    @yasamanderiszadeh902 3 года назад

    What a great video. Thanks!

  • @AzeemHashmani
    @AzeemHashmani 8 лет назад +1

    Big fan of yours
    Hitting the subscribe button !!

    • @WhatsACreel
      @WhatsACreel  8 лет назад +1

      +Azeem Hashmani Legend! Thank you!

  • @bryce910
    @bryce910 7 лет назад

    When it comes to accessing through a vector on each frame, (when hardly deleting) a vector would be better...correct?

  • @nictrace
    @nictrace 5 лет назад +1

    hi man! Can you make video in fullscreen mode slideshow?

  • @uabpsab
    @uabpsab 3 года назад

    Very nice. Subbed immediately.

  • @dreznik
    @dreznik 5 лет назад

    nice video, wonder if you could do one on BOOST too

  • @epickittylover489
    @epickittylover489 8 лет назад

    Biggest fan!!!

  • @MsSkip60
    @MsSkip60 8 лет назад

    More STL please!

  • @epickittylover489
    @epickittylover489 8 лет назад +3

    First to like!!!

  • @OMARI-yp6dk
    @OMARI-yp6dk 7 лет назад

    thank you

  • @mohamedhessuin6384
    @mohamedhessuin6384 6 лет назад

    awesome!!

  • @epickittylover489
    @epickittylover489 8 лет назад +3

    YES IM FIRST!!!!!!!

  • @piotrlenarczyk5803
    @piotrlenarczyk5803 7 лет назад

    Thank you for video:) Lists could be practical in embedded hardware in my personal opinion.

  • @Coffeemancer
    @Coffeemancer 2 года назад

    please do C#

  • @nanthakumark7613
    @nanthakumark7613 4 года назад

    awesome ....play in *0.75 speed 😁😁😁😁😁

  • @trunksero5206
    @trunksero5206 5 лет назад

    Hot

  • @gunrunjk
    @gunrunjk 5 лет назад

    I think you have a big mistake, you are not counting from your "create an iterator and iterator to position." If you including that processing, it will not show the big different time

    • @WhatsACreel
      @WhatsACreel  5 лет назад

      Yep, maybe, I aint sure. I think this whole vid was pretty shakey. Well cheers for pointing that out, have a good one!

  • @epickittylover489
    @epickittylover489 8 лет назад +1

    Im hogging the comment section

    • @WhatsACreel
      @WhatsACreel  8 лет назад

      +epic_kitty_lover489 EPIC!!!!!!!

  • @AndyU96
    @AndyU96 6 лет назад +1

    Are you Australian?

  • @SumoCumLoudly
    @SumoCumLoudly 6 лет назад +9

    c++ is a monstrosity

    • @deanroddey2881
      @deanroddey2881 5 лет назад

      You might be interested in seeing an alternative of C++ without all of the STL craziness. I've created such a thing over many years:
      github.com/DeanRoddey/CIDLib

    • @AdminDarkraiRSK
      @AdminDarkraiRSK 5 лет назад

      @dean that sounds amazing 😎👍

  • @AnotherPointOfView944
    @AnotherPointOfView944 Год назад

    I hate SLT syntax.

  • @boubacarsbtoure2036
    @boubacarsbtoure2036 10 месяцев назад

    FFS