Hi,
ObjectKeyIntMap currently has a fast get of the last
value referenced by containsKey(Obj);. It seems it
would greatly speed keeping counts if there was an
additional method for maps that contain numerical
values for increment. Additionally, a delegated put
method would allow this and arbitrary other
functionality. Here's sample code for both cases:
map.increment(key, 5);
and
interface ObjectKeyIntMap {
...
/**
* The given key has mapped to the given
oldValue, and the
* given newValue has been provided by the
calling code for
* this mapping. This method should computer the
final
* value to be stored and return it.
*
* @return The value to store at the given key.
*/
int delegatePut(Object key, int oldValue, int
newValue) {
// No body. Available for delegation.
}
}
class MyMap extends ObjectKeyIntOpenHashMap {
int delegatePut(Object key, int oldValue, int
newValue) {
return oldValue * newValue;
}
}
The call to the delegate is useless unless implemented
though and I don't know if this typically gets
optimized out.
Logged In: YES
user_id=43402
Originator: NO
I think that the suggested feature is very useful when counting things. I will think a bit more about the solution, though.