hash_map vs unordered_map

Discussion in 'C++' started by marek.vondrak@gmail.com, Aug 28, 2008.

  1. Guest

    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, 2008
    #1
    1. Advertising

  2. Leandro Melo Guest

    On 28 ago, 16:30, 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
    Leandro Melo, Aug 29, 2008
    #2
    1. Advertising

  3. Guest

    On Aug 29, 8:17 am, Leandro Melo <> wrote:
    > On 28 ago, 16:30, 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, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paulo Matos

    Template problem with unordered_map

    Paulo Matos, Aug 3, 2006, in forum: C++
    Replies:
    4
    Views:
    451
    Paulo Matos
    Aug 3, 2006
  2. Rares Vernica

    error with tr1 unordered_map iterator

    Rares Vernica, Feb 24, 2007, in forum: C++
    Replies:
    6
    Views:
    1,799
  3. abir
    Replies:
    6
    Views:
    849
    W Karas
    Jun 26, 2008
  4. abir
    Replies:
    3
    Views:
    1,128
  5. Alex Wanderleit
    Replies:
    1
    Views:
    854
    Marcel Müller
    Jan 5, 2011
Loading...

Share This Page