Anteru Anteru - 1 year ago 69
C++ Question

Is there already some std::vector based set/map implementation?

For small sets or maps, it's usually much faster to just use a sorted vector, instead of the tree-based

- especially for something like 5-10 elements. LLVM has some classes in that spirit, but no real adapter that would provide a
like interface backed up with a

Any (free) implementation of this out there?

Edit: Thanks for all the alternative ideas, but I'm really interested in a vector based set/map. I do have specific cases where I tend to create huge amounts of sets/maps which contain usually less than 10 elements, and I do really want to have less memory pressure. Think about for example neighbor edges for a vertex in a triangle mesh, you easily wind up with 100k sets of 3-4 elements each.

Answer Source

I just stumbled upon your question, hope its not too late.

I recommend a great (open source) library named Loki. It has a vector based implementation of an associative container that is a drop-in replacement for std::map, called AssocVector.

It offers better performance for accessing elements (and worst performance for insertions/deletions).

The library was written by Andrei Alexandrescu author of Modern C++ Design.

It also contains some other really nifty stuff.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download