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

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -