Reputation: 2971
Is there a collection class that has the LinkedHashMap quality of a predictable iteration order, but at the same time being indexable? LinkedHashMap implements a get() method, which returns the value object, but an indexof() method is not available. I'd like both.
Thanks.
Upvotes: 3
Views: 1117
Reputation: 64036
I have such a thing, a Linked Tree Map free and unencumbered on my website. It sounds close to what you want.
Upvotes: 1
Reputation: 57324
A SortedMap (ConcurrentSkipListMap, TreeMap) has methods that will return submap views of all keys > (or <) the passed in key. So
index(key) == sortedMap.headMap(key).size();
Not likely to be terribly efficient.
Upvotes: 0