STL Container to use?

W

wackyphill

For quick sequential access thru the collection which is best?
I know Vector is good for random access but I'll almost always be
working thru all objects in a loop.

Thanks.
 
R

Rolf Magnus

For quick sequential access thru the collection which is best?

This is the one thing that is quick in pretty much any container.
I know Vector is good for random access but I'll almost always be
working thru all objects in a loop.

What about adding or removing elements? Does that happen often? If not,
stick with vector.
 
C

Code4u

For quick sequential access thru the collection which is best?
I know Vector is good for random access but I'll almost always be
working thru all objects in a loop.

Thanks.

vector would be the best choice because the storage is guaranteed to
be contiguous, which in turn means that any sane implementation will
have very efficient iteration. I've read a good rule of thumb is that
if you're wondering which container to use, most of the time vector
will be the best choice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top