Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoupled version of hash_map/unordered_map

I'm writing an embedded application, and the environment I use does not, unfortunately, have C++11 support at present.

I need to implement a hash/unordered map (a regular std::map won't do for performance reasons), but can't seem to find a way to do it cleanly.

Boost doesn't want to work without bringing in practically the whole library. Even the original STL hash_map from SGI wants several headers, and duplicates standard library functionality, causing ambiguous function calls. It's a real mess.

For ease of implementation, versioning, quality control, V&V, etc. I really need something that leverages the existing standard library and exists in only a few header files that I can put right in the same folder as all the other source/header files. Does such a thing exist, or am I without hope? I've searched for a long while, but have come up empty-handed.

Thanks very much for any help. I can certainly clarify further if necessary.

like image 945
llakais Avatar asked Nov 13 '12 18:11

llakais


1 Answers

Did you look at the GNU implementation? On my Ubuntu Machine, unordered_map.h does not include anything. This file is located at

    /usr/include/c++/4.6/bits/unordered_map.h

which is about 400 lines although the file "unordered_map" in /usr/include/c++/4.6/ has more headers but you can tweak those I guess.

I think you can find the source code for implementation from GNU.org (?) and compile it yourself?

like image 128
CS Pei Avatar answered Sep 19 '22 17:09

CS Pei