|
|
Home » U++ Library support » U++ Core » Proposal on *Index: access via hash value
|
|
|
|
|
|
|
Re: Proposal on *Index: access via hash value [message #20704 is a reply to message #20691] |
Wed, 01 April 2009 09:49  |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Mindtraveller wrote on Tue, 31 March 2009 19:17 | mrjt, yes, I do have very close situation.
UPD: Finally U++ forced me to switch back to VectorMap. It seems like Index is not designed for such cases (but these cases happen very often IMO). Two big drawbacks:
1) Unable to find element by hash
2) Unable to change element, due to I have only (const T &) in return. But this seems too strict. Changing the object doesn`t necessary change it`s hash value. This approach forces one to declare all members as mutable.
|
I don't understand these problems.
1) Why don't you just use the hash as the VectorMap key (VectorMap<unsigned, CollectionElement>())? Then you can search by hash directly, although I don't really see the benefit of this for VectorMap.
2) Unless I've misunderstood then this is just wrong. both the Get() and operator[] methods have non-const variants. You can even get direct non-const access to the internal Value vector. If you want to change the Key then you use GetKey and SetKey. This just isn't a problem.
And as I stated previously if you still really want to use Index the code required to add find by hash is minimal (30-40 lines, mostly a copy of the Index class declaration.)
|
|
|
Goto Forum:
Current Time: Fri May 09 18:03:33 CEST 2025
Total time taken to generate the page: 0.02901 seconds
|
|
|