Click to See Complete Forum and Search --> : STL & hash_set problem


Unrul3r
December 17th, 2007, 06:19 AM
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 :D

Mybowlcut
December 17th, 2007, 07:01 AM
Perhaps you should post your errors? This (http://www.codeguru.com/forum/faq.php?faq=vb_faq#faq_vb_read_and_post) will tell you how to use code tags.

treuss
December 17th, 2007, 07:39 AM
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.

Unrul3r
December 17th, 2007, 07:53 AM
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!

Unrul3r
December 18th, 2007, 10:03 AM
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

Lindley
December 18th, 2007, 10:32 AM
I think you probably want a hash_map instead.

treuss
December 18th, 2007, 10:40 AM
or just a std::map if the key is int.