473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

hash_map vs unordered_map

Hi,
I am wondering if there are any functional differences between SGI's
hash_map and tr1's unordered_map. Can these two containers be
interchanged? What would it take to switch from hash_map to
unordered_map? Thank you.
-Marek
Aug 28 '08 #1
2 8090
On 28 ago, 16:30, marek.vond...@gmail.com wrote:
Hi,
I am wondering if there are any functional differences between SGI's
hash_map and tr1's unordered_map. Can these two containers be
interchanged? What would it take to switch from hash_map to
unordered_map? Thank you.
Hi.

It's not clear to me what exactly is your doubt. Just like SGI's
hash_map the "new" unordered_map is also based on a hash table. Since
hash_map (and hash_set, hash_multimap, hash_multiset) is not standard,
several compilers have provided their own implementation (GCC's for
example is based on SGI's hash map). Usually the implementation
differs in some aspect, even related to the interface (including the
template parameters), and are located in an extended namespace.

There're implementations of TR1 with support for unordered_map. IIRC
Boost's TR1 lacked this particular data structure (I'm not sure if
it's there yet), but Visual Studio's 2008 feature pack does included
it. You might wanna try one of those so you can check out the
differences.

Well, does this help at all?

--
Leandro T. C. Melo


Aug 29 '08 #2
On Aug 29, 8:17*am, Leandro Melo <ltcm...@gmail.comwrote:
On 28 ago, 16:30, marek.vond...@gmail.com wrote:
Hi,
I am wondering if there are any functional differences between SGI's
hash_map and tr1's unordered_map. Can these two containers be
interchanged? What would it take to switch from hash_map to
unordered_map? Thank you.
It's not clear to me what exactly is your doubt. Just like SGI's
hash_map the "new" unordered_map is also based on a hash table. Since
hash_map (and hash_set, hash_multimap, hash_multiset) is not standard,
several compilers have provided their own implementation (GCC's for
example is based on SGI's hash map).
Right. GCC provides SGI style hash_map under the name
__gnu_cxx::hash_map, MSVC with Dinkumware C++ library under the name
stdext::hash_map. The Dinkumware version differs from the SGI's
hash_map in certain minor details, but wrappers can be written so that
it would behave as SGI's hash_map. Now, my question is if the same
thing can be easily done with unordered_map, such that the wrapper
would have the same external interface like SGI's hash_map and provide
same guarantees about iterator invalidations, etc. I have an existing
code base that assumes that there is a class ext::hash_map that has
the semantics of SGI hash_map and that maps either to
__gnu_cxx::hash_map, SGI's hash_map, STLPort's hash_map or a wrapper
around stdext::hash_map. I would like to extend this so it could be
mapped to tr1::unordered_map as well.

-Marek
Aug 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christian Meier | last post by:
Hello, Yes, I know that hash maps aren't in the standard. But I couldn't find any better newsgroup for this post. (or is there an SGI library newsgroup?) I am currently testing the hash_map...
5
by: peter_k | last post by:
Hi I've defined hash_map in my code using this: ------------------------------------------- #include <string> #include <hash_map.h> & namespace __gnu_cxx {
10
by: g | last post by:
hello! I wanna replace an std::map<std::string,Services*> with hash_map.How I will do this? any link with examples? transactions.insert(std::pair<std::string,Services*>("Aservice",new...
1
by: anjangoswami06 | last post by:
Hi, I am interested to know how it is possible to update the data type with "insert" with stl hash_map. Suppose we have, hash_map<const char *, MyDataType, hash_compare<const char*,...
4
by: Paulo Matos | last post by:
HI all, I'm using unordered_map from TR1. I have a table variable which is a private member of a template class: template<typename K, typename D, typename EQ> class FooClass { public:
4
by: yuyang08 | last post by:
Hello, everyone, I am wondering what is the hash function that is used in hash_map/hash_set. Can I replace it with my own hash function? Any comments on this? Thanks! -Andy
6
by: Rares Vernica | last post by:
Hi, I am using tr1/unordered_map in my code. My code compiled ok on g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu1). Now I need to compile my code on g++ (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5). I get...
4
by: lokki | last post by:
Hello, can anybody tell me what's wrong with following example code? char *k, *v; k = new char; strcpy(k, "a2"); v = new char;
4
by: James Kanze | last post by:
On Jul 16, 10:53 pm, Mirco Wahab <wa...@chemie.uni-halle.dewrote: It depends. You might like to have a look at my "Hashing.hh" header (in the code at kanze.james.neuf.fr/code-en.html---the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.