Link to home
Start Free TrialLog in
Avatar of jjacksn
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.

Avatar of _ys_
_ys_

Perhaps this is what you intended:

hash_map<const char*, notes, hash_compare<const char*, eqstr> > toolNotes;

Assuming that 'notes' is defined as a type (e.g. class notes).
Avatar of jjacksn

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
Avatar of jjacksn

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?
Avatar of jjacksn

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.
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial