2d hash_map iteration ?

  • Thread starter Kristofer Pettijohn
  • Start date
K

Kristofer Pettijohn

Greetings,

I have a 2D hash_map, defined as follows:

typedef hash_map<const char*,
str_session,
hash<const char*>,
eqstr> t_hashchar;
typedef hash_map<const char*,
t_hashchar,
hash<const char*>,
eqstr> t_hashcharchar;

so it is hash[const char*][const char*] = str_session
(in the context used, its hash["username"]["sessionid"] = str_session)

I am attempting to write an outer loop that iterates through the
username's, and an inner loop that iterates through the session id's
for that username.

The code that I have doing this is as follows:

void results(t_hashcharchar &h) {
t_hashcharchar::iterator x;
t_hashchar::iterator y;

for (x = h.begin(); x != h.end(); x++) {
for (y = x->begin(); y != x->end(); y++) {
// do stuff
}
}
}

but gives me compilation errors.

I'm either (more than likely) not understanding something properly, or
am missing something blatently obvious.

Could someone please help point out the obvious to me, or guide me towards
finding a way to do this?

Thanks!

Kristofer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top