I need a Map<Integer,String>
with a major need to do fast retrievals of values by key
. However I also have the need to retrieve List
of all entries (key
, value
pairs) whose keys are in range (n1 to n2). However, No sorting required in the list.
The map would hold atleast 10,000 such entries.
I initially thought of using TreeMap
but that doesn t help with faster retrievals(O(log n) for get() operations). Is it possible to get a list of entries from HashMap whose keys are in range n1 to n2 ?
What would be my best bet to go with ?