CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2010
    Posts
    13

    Hashset equilalent of C++

    What is the equivalent of HashSet in C++? How do I use it (as in basic add, remove, and iterating through)

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Hashset equilalent of C++

    At the moment, my guess is that it would be std::tr1::unordered_set, but being part of the TR1 extensions, it may not necessarily be available.

    For the time being, you could use Boost.Unordered, which provided the basis for the unordered containers in TR1. Boost provides a TR1 wrapper too.
    Last edited by laserlight; April 13th, 2010 at 10:06 AM. Reason: Oops, missed the tr1 namespace
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    May 2009
    Posts
    2,413

    Re: Hashset equilalent of C++

    Quote Originally Posted by dietao234 View Post
    What is the equivalent of HashSet in C++? How do I use it (as in basic add, remove, and iterating through)
    HashSet of Java?

    There is no equivalent yet but one is planned for the upcoming new C++ standard. Many compiler suppliers offer it already. It's called std::tr1::unordered_set.

  4. #4
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: Hashset equilalent of C++

    From what language?

    c++ has std::set/std::map, which is (usually) implemented as a binary tree (red/black tree as a matter of fact).

    boost has a boost::hash_set/boost::hash_map which is basically the same thing, but implemented as a hash structure. This will be implemented into c++ as "std::::tr1::unordered_set" and "std::::tr1::unordered_map". Boost's structure has been renamed a a consequence.

    As for how to use them, maybe the best thing for you to do is to google these structures and come back if you have any questions? I can answer any of your questions, but there are better tutorials out there then I can type right now.

    http://www.cplusplus.com/reference/stl/set/
    http://www.cplusplus.com/reference/stl/map/
    http://www.boost.org/doc/libs/1_36_0...unordered.html

    Hope that helps?

  5. #5
    Join Date
    May 2009
    Posts
    2,413

    Re: Hashset equilalent of C++

    Quote Originally Posted by monarch_dodra View Post
    c++ has std::set/std::map,
    The Java equivalents of these are TreeSet and TreeMap respectively.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured