2d hash_map iteration ?

Discussion in 'C++' started by Kristofer Pettijohn, Jun 26, 2003.

  1. 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
    Kristofer Pettijohn, Jun 26, 2003
    #1
    1. Advertising

  2. Rob Williscroft wrote in news:Xns93A65C1CA24C6ukcoREMOVEfreenetrtw@
    195.129.110.201:

    > Not the use of o->second.begin(),


    Note the use of o->second.begin(),

    Duh :)

    Rob.
    --
    http://www.victim-prime.dsl.pipex.com/
    Rob Williscroft, Jun 26, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacek Generowicz

    Pre-standardizing hash_map & friends.

    Jacek Generowicz, Aug 26, 2003, in forum: C++
    Replies:
    0
    Views:
    344
    Jacek Generowicz
    Aug 26, 2003
  2. Charles Herman

    hash_map iterator

    Charles Herman, Nov 3, 2003, in forum: C++
    Replies:
    5
    Views:
    5,957
    Ron Natalie
    Nov 4, 2003
  3. Florian Liefers

    C2143, hash_map

    Florian Liefers, Nov 12, 2003, in forum: C++
    Replies:
    11
    Views:
    1,291
    Dan Cernat
    Nov 12, 2003
  4. Jon Cosby

    hash_map

    Jon Cosby, Nov 30, 2003, in forum: C++
    Replies:
    10
    Views:
    8,608
    David Fisher
    Dec 2, 2003
  5. Rudi
    Replies:
    5
    Views:
    4,940
Loading...

Share This Page