Reputation: 237
I'm trying to achieve something like a LinkedHashMap, with entries added in the top, rather than in the bottom (LIFO). I don't want to sort it afterwards, just looking for an implementation that allows exactly that.
Thanks.
Upvotes: 3
Views: 1154
Reputation: 46
If you are looking for a "StackHashMap", this can probably help you:
http://www.koders.com/java/fidA648AB05902E307E4CDD11A20D41499984C495AE.aspx?s=IHandler
Upvotes: 2
Reputation: 533590
Sometimes you are better off using two collections to make things clearer, esp. when you are doing something unusual. In this case, a Deque (which doesn't have to be synchronized/thread safe) or Stack (which is synchronized) with a Map may be the best option.
Upvotes: 3
Reputation: 75386
Perhaps you are looking for a Stack?
http://download.oracle.com/javase/1.4.2/docs/api/java/util/Stack.html
Upvotes: 0