PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > with RogueWave RWHashDictionary
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
with RogueWave RWHashDictionary

Réponse
 
LinkBack Outils de la discussion
Vieux 08/04/2008, 15h05   #1
eskgwin@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut with RogueWave RWHashDictionary

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 ABCEF and RGGEF and TREEF)

The first problem I am encountering is where the user wants to put
ABCEF in as a key with the value of CT0 and ABCEF 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 ABDEF 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
.

Allyson
  Réponse avec citation
Vieux 08/04/2008, 15h17   #2
Puppet_Sock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with RogueWave RWHashDictionary

On Apr 8, 10:05am, eskg...@gmail.com wrote:
> 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09557 seconds with 10 queries