U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Can we have a ValueMap(Unique) ?
Can we have a ValueMap(Unique) ? [message #42920] Mon, 14 April 2014 15:52 Go to previous message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
Today I spent a lot of time to figure out why some code was not working and I found that it was because I have added the same key more than once on a ValueMap, I was expecting getting back the last added value but no and till I found this problem a lot of time passed (I learned a bit more about U++ internals) but it was not fun.

Looking a the ValueMap implementation the ideal place to do it would be on the function "Add" but it is not virtual so I was thinking that adding a new type "VALUEMAPUNIQUE_V" and modify the "Add" function to:
void ValueMap::Add(const Value& key, const Value& value) {
	Data& d = Clone();
        if(data->GetType() == VALUEMAPUNIQUE_V)
        {
           ///check if key already exists and throw an Exception
        }
	d.key.Add(key);
	d.value.Add(value);
}


What U++ users think about have a ValueMap variant like this ?

Cheers !
 
Read Message
Read Message
Previous Topic: ThrowValueTypeError small bug, and suggestion for removing it
Next Topic: CParser do not check for invalid strings that span lines
Goto Forum:
  


Current Time: Sun Apr 26 02:38:57 GMT+2 2026

Total time taken to generate the page: 0.00607 seconds