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
When traversing sequence containers, don't forget about range-based for loops. :)
for(auto &e : container) { std::cout
+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
Why do you not use 'using namespace std;'?
Just discovered your channel. You are incredibly amazing at explaining things quickly and precisely. Thanks a bunch, man!
Welcome!
@@WhatsACreel agree!
Venus
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.
Cheers mate! I think you're spot on there! They seem to have taken the syntax from stacks. Thanks for watching brus :)
this is the best kangaroo programming channel in the world. Love the accent! Love the channel!
What a brief explanation, please keep it up. Thank you
Surprizingly good explaination! I watched other videos on the subject but this one taught me most.
*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.
WOOHOO!!!
What an explanation!! Thank You.
Are you Feynmann's son mate? :)
Great Explanation !
Can you do any linear algebra with the vectors? Or would that be something you used a specialized library for?
just fantastic
Thank you brus! Cheers for watching :)
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)?
Do I have to put v.begin() + 1 as the argument for v.erase(), or can I just put the index?
What a great video. Thanks!
Big fan of yours
Hitting the subscribe button !!
+Azeem Hashmani Legend! Thank you!
When it comes to accessing through a vector on each frame, (when hardly deleting) a vector would be better...correct?
hi man! Can you make video in fullscreen mode slideshow?
Very nice. Subbed immediately.
nice video, wonder if you could do one on BOOST too
Biggest fan!!!
More STL please!
First to like!!!
thank you
awesome!!
YES IM FIRST!!!!!!!
Thank you for video:) Lists could be practical in embedded hardware in my personal opinion.
please do C#
awesome ....play in *0.75 speed 😁😁😁😁😁
Hot
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
Yep, maybe, I aint sure. I think this whole vid was pretty shakey. Well cheers for pointing that out, have a good one!
Im hogging the comment section
+epic_kitty_lover489 EPIC!!!!!!!
Are you Australian?
I sure am!
c++ is a monstrosity
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
@dean that sounds amazing 😎👍
I hate SLT syntax.
FFS