I have a HashMap with millions of entries.
Need to retrieve all entries whose keys match a specific set of criteria (in this case, each key is an object with two integer properties; I need to retrieve all keys where each of these integers fall within a specified range).
What is the fastest, most efficient way to iterate through all such keys?
UPDATE: In this particular case, though I didn’t specify it up front, the first integer in the key has a natural precedence over the second integer.
Here’s a solution using TreeMap: