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 |
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 !
|
|
|
Goto Forum:
Current Time: Mon Apr 29 18:41:29 CEST 2024
Total time taken to generate the page: 0.02393 seconds
|