msvcyc
msvcyc

Reputation: 2593

Criteria for selecting the right STL container for the job?

Do you just base your STL container selections on the following attributes?

  1. Searching/Updating
  2. Insertion and
  3. Deletion

If not, what else do you base your selections upon? Is there any reference out there that lists how each container performs across all these different attributes?

Upvotes: 1

Views: 723

Answers (4)

Anton I. Sipos
Anton I. Sipos

Reputation: 3613

+1 for effective STL.

But if you need an on-line reference, there is a good flowchart in StackOverflow Question 471432

Upvotes: 2

Ian Ringrose
Ian Ringrose

Reputation: 51917

I start of by thinking about the "shape" of the data, how often each item can repeat etc.

Upvotes: 0

Laserallan
Laserallan

Reputation: 11312

Guarantee that the data is placed in continuous memory can be important. Typically if you are interested in using the data in the structure with interfaces that looks like doSomething(int* data, int dataCount).

Upvotes: 0

Meredith L. Patterson
Meredith L. Patterson

Reputation: 4921

Scott Meyers' Effective STL covers not only this, but the weird pitfalls that you'll run into with some of the odder containers like set.

Upvotes: 4

Related Questions