HashMap getKeyByValue function
807601Mar 10 2008 — edited Mar 10 2008Hi.
It looks to me like we do have the HashMap.containsValue(value) function that returns true if the map does contain that value, but we don't have a function that would tell us the key corresponding to that value. Doesn't it seem a bit ironic? I mean, they made containsValue() just to let us know that the value is in there, but it wouldn't return the key. We gotta iterate ourselves through the map in order to find the key. Isn't it what containsValue() does? Iterate through the map to find out if the value is in there or not? Would it have been so difficult to make a getKeyByValue function?
Am I missing something? I've gone through the API, and I can't seem to find any other way to get a key by it's value, except for iterating through the entire map.