jjacksn
asked on
Question on hash_map in stl
I want to use a hash_map to store some data. the key is going to be a const char* and the object is going to be a custom struct. I have no idea how to go about implementing this and I can't find anything online. I need to be pointed to a tutorial on using hash_maps. the one on sgis website doesn't help enough.
I am trying to call the following:
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
hash_map<const char*, notes, hash<const char*>, eqstr> toolNotes;
and getting an error that hash is undefined.
I am trying to call the following:
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
hash_map<const char*, notes, hash<const char*>, eqstr> toolNotes;
and getting an error that hash is undefined.
ASKER
Ok, that declaration works, but is says its deprecated. Do you know of anywhere I can read about or see sample code of hash_map. Not the sgi version, which is different.
There isn't any hash_map in the standard library, so implementations may vary. Which one are you using?
This may help:
http://www.rpi.edu/~daiglm/plang/ml3.html
--efn
This may help:
http://www.rpi.edu/~daiglm/plang/ml3.html
--efn
ASKER
I programming in VS.NET in C++. STL doesn't have a hash_map? I'm just using include <hash_map> Is there a better hash_map to use?
ASKER
Basically, I want to do the following:
Using a custom deifnied struct, store information about users keyed on their e-mail addresses. I will need to be accessing these over and over, updating the data, then finally outputing to an xml file. What is the best/easiest way to do this. I don't seem to be getting how use hashmap.
Using a custom deifnied struct, store information about users keyed on their e-mail addresses. I will need to be accessing these over and over, updating the data, then finally outputing to an xml file. What is the best/easiest way to do this. I don't seem to be getting how use hashmap.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hash_map<const char*, notes, hash_compare<const char*, eqstr> > toolNotes;
Assuming that 'notes' is defined as a type (e.g. class notes).