Primitive ordered collection in java
Trove library provides some fast primitive collections, eg Map
, List
, but it does not have any ordered collection, eg SortedMap
, T开发者_如何学PythonreeSet
. Is there a library that provides those collections?
Try http://fastutil.dsi.unimi.it/ for some giant ordered structures, but perhaps not all that you want.
There is also LinkedMap
and ListOrderedMap
from the Common Collection library.
OrderedMap map = new LinkedMap();
map.put("FIVE", "5");
map.put("SIX", "6");
map.put("SEVEN", "7");
map.firstKey(); // returns "FIVE"
map.nextKey("FIVE"); // returns "SIX"
map.nextKey("SIX"); // returns "SEVEN"
精彩评论