Java Utililty Methods HashMap Counter

List of utility methods to do HashMap Counter

Description

The list of methods to do HashMap Counter are organized into topic(s).

Method

Integerincrement(HashMap m, X key)
Increment the value associated with key by 1, or set it to 1 if there was no mapping for key
return m.put(key, ((m.get(key) == null) ? 1 : (m.get(key) + 1)));
voidincrementHashMap(HashMap map, String key, int n)
increment Hash Map
int count;
Integer countI = (Integer) map.get(key);
if (countI == null)
    count = 0;
else {
    count = countI;
map.put(key, count + n);
...
voidincrementMap(HashMap map, Integer key)
increment Map
Integer count = map.get(key);
if (count == null) {
    map.put(key, 1);
} else {
    map.put(key, count + 1);
voidincrementTwoLevelHashMap(HashMap map, String key1, String key2, int n)
increment Two Level Hash Map
HashMap map2 = (HashMap) map.get(key1);
if (map2 == null) {
    map2 = new HashMap();
    map.put(key1, map2);
incrementHashMap(map2, key2, n);