Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the preferred STL collection when that's all you need?

Tags:

c++

stl

I just need a "bag of things". It doesn't need to be a set, a map or even have any particular order. I just need to be able to add things and iterate over it, nothing more. I don't expect it to be very large but it can't get really bad perf if it does.

What container should I use?

like image 382
BCS Avatar asked Nov 26 '25 16:11

BCS


1 Answers

The standard recommends using vector as your default container. But Herb Sutter actually makes a case for using deque as your first choice.

like image 104
Fred Larson Avatar answered Nov 29 '25 06:11

Fred Larson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!