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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -