Don't iterate over the key set to then retrieve the values too - iterate over the entry set directly:
This is more efficient in general (even for "normal" HashMaps), but it will also reduce contention in your case (half as many accesses to the map).
Yes it is simply:
map.put(s, f);
If you need to check that the key contains a given substring then you do need to iterate over the keys like you are doing, although I'm not sure why you have a while+for+break instead of a simple for.
|
0 Comments