C++ data structure with lookuptime O(1), like java's hashmap in stl?
c++, data-structures, performance
Solution
The problem is that the O(1) lookup is not standard. I am unsure about what boost has, but some STL implementations (like sgi) have hash_map. That's what you need.
Here is the documentation.
Just try out:
#include <hash_map>
Keep in mind if this works, it is not portable... but maybe for now that's ok, and later you can find workarounds.
Problem
Is there such a structure in c++ standard library? I don't have access to anything else so unordered_map in tr1 cant be used (and boost etc). What I have is a large number of custom class elements 100000+ which I need to store, and access them very fast O(1) on everage. I can't use arrays/vectors as the elements will be stored randomly and I don't know the position of the element. Is my only alternative to implements an own hashmap implementation with only the c++ standard library available?