Need help with a dictionary class...

Discussion in 'C++' started by SpreadTooThin, Jun 7, 2007.

  1. I have a dictionary that looks like:

    a0,b0,c0,d0,e0
    a1,b1,c1,d1,e1
    ....
    ....

    Currently I consider [a,b] (Class Tag) to be the key and [c,d,e]
    (Class Value) to be the value.
    However I now need to use [e] as the key and [a,b,c,d] as the value.

    the dictionary class uses defines:
    std::map<Tag, Value> dictionary;
    as the dictionary... (Where Tag and Values are classes)

    What must I do to be able to have more than one key?
    Must I define two new classes for TagB and ValuesB and another
    dictionary based on these classes?
    Multimaps seems to pop into mind.. but I don't know how to use the and
    am not sure if they are part of the stl...
    SpreadTooThin, Jun 7, 2007
    #1
    1. Advertising

  2. SpreadTooThin wrote:
    > I have a dictionary that looks like:
    >
    > a0,b0,c0,d0,e0
    > a1,b1,c1,d1,e1
    > ...
    > ...
    >
    > Currently I consider [a,b] (Class Tag) to be the key and [c,d,e]
    > (Class Value) to be the value.


    IOW, you have an associative array:

    K0 : V0
    K1 : V1
    ...

    where Kx is a list and Vx is a list?

    > However I now need to use [e] as the key and [a,b,c,d] as the value.


    I.e.

    Kk0 : Vv0
    ...

    (same scheme), and Kkx and Vvx are also lists, right?

    >
    > the dictionary class uses defines:
    > std::map<Tag, Value> dictionary;
    > as the dictionary... (Where Tag and Values are classes)
    >
    > What must I do to be able to have more than one key?


    Probably, more than one dictionary...

    > Must I define two new classes for TagB and ValuesB and another
    > dictionary based on these classes?


    Probably.

    > Multimaps seems to pop into mind.. but I don't know how to use the and
    > am not sure if they are part of the stl...


    There is 'std::multimap', but it is like a 'map' with mutliple keys
    allowed. I don't see how it's applicable here.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Jun 7, 2007
    #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. Ilias Lazaridis
    Replies:
    6
    Views:
    429
    Ilias Lazaridis
    Feb 21, 2006
  2. james_027
    Replies:
    1
    Views:
    310
    Marc 'BlackJack' Rintsch
    Aug 22, 2007
  3. Navkirat Singh
    Replies:
    6
    Views:
    2,976
    Navkirat Singh
    Jul 29, 2010
  4. Chris Rebert
    Replies:
    0
    Views:
    508
    Chris Rebert
    Jul 29, 2010
  5. Fox

    dictionary within dictionary

    Fox, Mar 8, 2005, in forum: ASP General
    Replies:
    5
    Views:
    172
    Michael D. Kersey
    Mar 13, 2005
Loading...

Share This Page