Maps are great to get things done easily, but they are memory hogs and suffer from caching issues. And when you have a map in a critical loop that can be bad.
So I was wondering if anyone can recommend another container that has the same API but uses lets say a vector or hash implementation instead of a tree implementation. My goal here is to swap the containers and not have to rewrite all the user code that relies on the map.
Update: performance wise the best solution would be a tested map facade on a std::vector
You can use std::tr1::unordered_map, which is already present in most STL implementations, and is part of the C++0x standard.
Here is it's current signature :
template <class Key,
class T,
class Hash = std::tr1::hash<Key>,
class Pred = std::equal_to<Key>,
class Alloc = std::allocator<std::pair<const Key, T> > >
class unordered_map;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With