Someone said that hashmaps are pretty slow. So I'm just wondering if to use hashmap or switch logic.
My requirement is this. I have a set of CountryNames and CountryCodes. My ListView displays country names. When the country name element is clicked, I must Toast CountryCode.
In such a scenario, should I support the HashMap of country names and codes and access this in order to get the appropriate code ?:
myMap.put("US", 355); myMap.put("UK", 459); //etc
Or is it better to write such a case with a switch
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 will the map be used?
-Kiki
. , .equals().. , .
(, 10 ), . .( 50) . , , , . 10 ~ 50 , , , , .
, , , , gnuperf., , , , , Trie., , HashMap - . , ( ).