, . , .
( ), TreeMap ( HashMap) homeTown , , Map ( , , ). , .
In case you need a list of all users with a given homeTown, you just need to find this list on the Map and return it (without copying the necessary elements), I'm not 100% sure about the implementation of Map in Java, but the full method should be constant time (worst-case logarithmic, depending on map implementation).
source
share