posted 18 years ago
If you are certain that no key of type 1 could ever match a key of type 2 you could just put each object in the map twice, once with each key. This might work with state and zipcode where AK could not be a zipcode and 10010 could not be a state.
states.put( stateCode, state)
states.put( zipCode, state)
state = states.get( "AK" )
state = states.get( "10010" )
Any key collision would be fatally confusing, I'd expect.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi