Page 1 of 1

about hash_set and hash_map

Posted: Tue Apr 04, 2006 4:49 am
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.

Posted: Tue Apr 04, 2006 5:53 am
by Krzysztof Duleba
Usually yes, but that's up to the host.

Posted: Thu Apr 06, 2006 11:19 pm
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!

Posted: Mon Apr 10, 2006 6:06 pm
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

Posted: Mon Apr 10, 2006 11:28 pm
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 );