java - HashMap<String, Integer> Search for part of an key? -


this question has answer here:

i using hashmap<string, integer> filled keys of type string all, let's say, 5 chars long. how can search specific key of 4 chars or less, part , @ beginning of other keys , hits collection of <key, value>?

iterate option unless create custom data structure:

for (entry<string, integer> e : map.entryset()) {     if (e.getkey().startswith("xxxx")) {         //add result list     } } 

if need more time efficient you'd need implementation of map tracking these partial keys.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -