CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Posts
    3

    STL & hash_set problem

    Hello,

    I'm new to the forums and this is my first post (not sure if it's in the right place) and i'm also a beginner at programming in c++, so bear a little with me.

    I'm trying to get the STL hash_set included in my code but i'm getting some wierd problems compiling (very big compiling error). Firstly, i don't know if i installed STL correctly (extracted to include dir in devc++). Second, i included the hash_set (#include <hash_set.h>) in a simple example program and getting the huge compile error. I think it's a very common problem but due to my ignorance i'm unable to solve it. I hope no additional information is required as i think many of you may already know what is going on.

    Thanks,
    Unrul3r

    PS: Sorry if the post is a bit messy/sloppy but i'm in a bit of a hurry
    Last edited by Unrul3r; December 17th, 2007 at 07:54 AM.

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: STL & hash_set problem

    Perhaps you should post your errors? This will tell you how to use code tags.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  3. #3
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    Re: STL & hash_set problem

    What STL are you exactly talking about?

    Most of the STL has become part of the C++ standard, thus any C++ compiler will contain STL. However, hash set was one of the few components that did not make it into the standard.

    If you've downloaded some STL source code somewhere (SGI?) and extracted it into your include directory, you will probably have created a mess, due to the mixture of STL files that came with the compiler and extracted ones.

    I suggest you use boost (www.boost.org) for a hash set implementation. Boost builds upon the current C++ standard and thus does not overlap with your compiler implementation of STL.
    More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf

    Premature optimization is the root of all evil --Donald E. Knuth


    Please read Information on posting before posting, especially the info on using [code] tags.

  4. #4
    Join Date
    Dec 2007
    Posts
    3

    Re: STL & hash_set problem

    Yes, it was SGI. I will delete all files of SGI STL from the dir since none have collided with original files and check out Boost. Thanks a bunch, Will report soon.

    Edit: Boost seem really nice will try it in the future, but a friend of mine got it working, i was putting some files in the wrong dirs so i ended up using SGI STL . Thanks very much anyways for the fast response from all!
    Last edited by Unrul3r; December 17th, 2007 at 10:12 AM.

  5. #5
    Join Date
    Dec 2007
    Posts
    3

    Re: STL & hash_set problem

    Have another question: I'm not understanding very well the implemented concept of hash_set, so i would like to know how do i define the hash_set type. i want like a hashtable with with elements of type string but a key of int type.

    hash_set <int> defines only teh type of the key right? what about the elements?

    Regards

  6. #6
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: STL & hash_set problem

    I think you probably want a hash_map instead.

  7. #7
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    Re: STL & hash_set problem

    or just a std::map if the key is int.
    More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf

    Premature optimization is the root of all evil --Donald E. Knuth


    Please read Information on posting before posting, especially the info on using [code] tags.

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