
Hi all, I'm using a rather big std::map which gives good performance but the memory footprint is a bit too big. So I figured to implement an std::map as an std::vector<std::pair<T1,T2>> but thus with the interface of an std::map on top of it. I kind of recall a similar discussion and checked in the boost-sandbox but did not find anything similar. Anybody knows of implementations like these? Thanks, toon

Toon Knapen <toon.knapen@fft.be> writes:
Hi all,
I'm using a rather big std::map which gives good performance but the memory footprint is a bit too big. So I figured to implement an std::map as an std::vector<std::pair<T1,T2>> but thus with the interface of an std::map on top of it.
Can't be done. It has the wrong iterator invalidation properties. You may be able to implement a useful associative container, but it will never be std::map. -- Dave Abrahams Boost Consulting www.boost-consulting.com

"Toon Knapen" wrote:
I'm using a rather big std::map which gives good performance but the memory footprint is a bit too big. So I figured to implement an std::map as an std::vector<std::pair<T1,T2>> but thus with the interface of an std::map on top of it.
I kind of recall a similar discussion and checked in the boost-sandbox but did not find anything similar. Anybody knows of implementations like these?
It looks bit similar to Alexandrescu's AssocVector. Similar container exists in Shmem library (currently in Sandbox Files). /Pavel

You might try Google's SparseHash (http://goog-sparsehash.sourceforge.net) "An extremely memory-efficient hash_map implementation. 2 bits/entry overhead!" On Wed, 16 Mar 2005 11:33:09 +0100, Toon Knapen <toon.knapen@fft.be> wrote:
Hi all,
I'm using a rather big std::map which gives good performance but the memory footprint is a bit too big. So I figured to implement an std::map as an std::vector<std::pair<T1,T2>> but thus with the interface of an std::map on top of it.
I kind of recall a similar discussion and checked in the boost-sandbox but did not find anything similar. Anybody knows of implementations like these?
Thanks,
toon _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
participants (4)
-
Cory Nelson
-
David Abrahams
-
Pavel Vozenilek
-
Toon Knapen