Help with RogueWave RWHashDictionary

E

eskgwin

I have an RWHashDictionary 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:

RWCollectableString* key1;
RWCollectableString* val1;

key1 = new RWCollectableString(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
 
P

Puppet_Sock

I have an RWHashDictionary 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 RWCollectableString 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
 

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

Similar Threads

I need help with homework 1
Need help with this code 2
Output confusion 2
RogueWave constructor failing 0
Help with Loop 0
Pygame animation help!!!! 0
Help with Paypal Live Transactions 1
Please help 7

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top