about hash_set and hash_map

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
trulo17
Learning poster
Posts: 62
Joined: Mon Jan 24, 2005 6:12 am
Location: Lima,Peru

about hash_set and hash_map

Post by trulo17 »

i know we can use these containers here in online judge, but i would like to know if they can be used in icpc regionals.
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

Usually yes, but that's up to the host.
andresw1
New poster
Posts: 27
Joined: Sat Mar 18, 2006 5:04 pm

Post by andresw1 »

Hello,

Can somebody give some example source code how to use them (and some comments... are they reliable, how can you change the size of the hash array (if you can...)) . I tried to use them some time ago but I couldn't even compile...

Thank you!
trulo17
Learning poster
Posts: 62
Joined: Mon Jan 24, 2005 6:12 am
Location: Lima,Peru

Post by trulo17 »

Code: Select all

struct word
{
    char s[10];
};
struct hasher
{ 
    size_t operator()( word x ) const
    { 
        return hash< const char* >()( x.s ); 
    } 
};
struct eqstr
{
    bool operator()(word a,word b)
    {
        return strcmp(a.s,b.s)==0;
    }
};
typedef hash_map<word,string,hasher,eqstr > myhash;
i'm new to them too, all i can do is to post part of an ac code in which i used them
andresw1
New poster
Posts: 27
Joined: Sat Mar 18, 2006 5:04 pm

Post by andresw1 »

I can't get a few lines here. Is there a way to use some buildin hash function. And how do you se the memory limits for the hash_set? What about that "string" in the init part. Why is that? And what is that
return hash< const char* >()( x.s );
Post Reply

Return to “C++”