If it's a batch job, a TreeMap
won't use extra memory like HashMap
. HashMap
s default load factor is I believe 0.75 (i.e. the map can be 75% full before the size is grown).
A TreeMap
would be more straight forward too, provided the O(log n) (IIRC) doesn't become a bottle neck. If it does, you could use a List
with your own Tuple
object and a custom Comparator
, but then you don't get a O(1) get()
.