Help with RogueWave RWHashDictionary

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • eskgwin@gmail.com

    #1

    Help with RogueWave RWHashDictionary

    I have an RWHashDictionar y that I am inserting keys and values into. I
    really need duplicate keys, but I know that I can't have them. This is
    what I am going to do instead:

    RWCollectableSt ring* key1;
    RWCollectableSt ring* val1;

    key1 = new RWCollectableSt ring(wholemeas) ; //wholemeas is an RWCString
    that contains values like ABC:DEF and RGG:DEF and TRE:DEF)

    The first problem I am encountering is where the user wants to put
    ABC:DEF in as a key with the value of CT0 and ABC:DEF in as a key with
    a value of PN0. I know I can't do that in a hash dictionary so I am
    going to add a :# (# will come from a loop and be distinct) to the end
    of each key before adding it to the dictionary.

    The second problem I am encountering is getting these key/value pairs
    back out. I only know the ABD:DEF part and not the :1, :2, etc. part
    of the key. I don't even know if there are any :1, :2, etc. keys in
    the dictionary.

    Is there a way to do a substring on the key to get all the key/values
    back out of the dictionary without exactly knowing the keys? I can't
    find a way to do it and maybe I need to change this to something that
    can take duplicates. But then I have another problem, when trying to
    get them out one at a time. If I am searching on the key, how will it
    know which value to get?

    If you understand what I am trying to do, thanks. And thanks for any
    help.

    Allyson
  • Puppet_Sock

    #2
    Re: Help with RogueWave RWHashDictionar y

    On Apr 8, 10:05 am, eskg...@gmail.c om wrote:
    I have an RWHashDictionar y that I am inserting keys and values into. I
    really need duplicate keys, but I know that I can't have them. This is
    what I am going to do instead:
    [snip]

    Ok, first off, possibly there are better places to talk
    about a specific library. Here we do standard C++. It may
    be that there are news groups, or even specialized forums,
    where folks know a lot more about a specific custom lib.

    Anyway: What you are doing sounds a lot like a one-to-many
    type relationship. As you say you "can't have them."

    If you are only going to have one or two out of many 1000's
    of entries, maybe what you really need to do is rethink how
    you are approaching the probelm. That is, maybe you let a
    bad requirement sneak into your specification, and a little
    bit of careful refactoring would get rid of this for you.

    If you are going to have many of these cases, maybe what
    you need is to have a collection as the item the key
    points at rather than a single item. That is, instead
    of a single item pointed at by each key, put in another
    layer of abstraction, and have each key point at a
    collection of items. That's why I talked about there
    only being a small number of these. The extra overhead
    of the new layer will be a lot of extra pain if you
    only have one or two. But if it's common, it may be
    worthwhile.

    I've no idea what an RWCollectableSt ring is. (does it
    come in the bottom of a box of cereal?) But if you
    were doing something like an std::map then you could
    have the key be a string and the value be a std::vector
    or some such.
    Socks

    Comment

    Working...