I need to create a custom class/data structure, probably a hashmap..
Normally one puts to a hashmap like so:
myMap.put(myKey, myThing);
This doesn't quite suite my needs, What I need is to remember the most recent *2* things for any key.
So that if I do:
myMap.put(a, 1);
myMap.put(a, 2);
I can get back either the 1 or the 2.
Furthermore, if I do:
myMap.put(a, 3);
then the 1 would disappear and I'd have available the 2 or the 3.
I'd suggestions on how to implement this, whether with hashmap or if you have a better idea, i'm listening.
Start Free Trial