Hi,
Someone told me hashmaps are rather slow. So I am just wondering whether to use a hashmap or simply a switch case logic.
My requirement is this. I have a set of CountryNames and CountryCodes. My ListView displays the names of the countries. When an country name item is clicked, I must Toast the CountryCode.
In such a scenario, should I maintain a HashMap of CountryNames and Codes and access this to get the corresponding Code?:
myMap.put("US", 355);
myMap.put("UK", 459);
//etc
Or is it better to write a switch case like so
switch (vCountryNamePos):
{
case 0: //US
vCountryCode = 355;
break;
case 1: //UK
vCountryCode = 459;
break;
//etc
}
Which is faster? If not Hashmaps, then in what practical scenarios would a Map be used?
-Kiki