By insert() , I mean insertBefore(key) or insertAfter(key) .
As far as I can figure out, inserting a key in the middle of a card can only be achieved by creating a new card and copying it through existing keys and a new key in the correct order.
Given that LinkedHashMaps are based on double lists, it would be trivial to implement insertBefore(key) or insertAfter(key) .
Did I miss something?
Update Thanks to everyone who indicated that the above methods would violate the contract to maintain the insertion order.
So let me rephrase the question: does anyone know a class that would allow me to do this?
I looked at SortedMap (and its derivatives, including NavigableMap ), but I do not want the map to be sorted explicitly. Think of a nodeList in your browser DOM. I just need to be able to insert elements (in this case, KV pairs) in random order.
thanks
source share