Java Map Merge mergeCounts(Map counter, String key)

Here you can find the source of mergeCounts(Map counter, String key)

Description

merge Counts

License

Apache License

Declaration

public static void mergeCounts(Map<String, Integer> counter, String key) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;

public class Main {

    public static void mergeCounts(Map<String, Integer> counter, String key) {
        if (counter.containsKey(key)) {
            Integer count = counter.get(key);
            counter.put(key, ++count);//from  w  w w .  j a  va 2  s .  c  o m
        } else {
            counter.put(key, 1);
        }
    }
}

Related

  1. mergeCompactedValue(Map obj, String key, Object value)
  2. mergeCompositions( Map target, Map source)
  3. mergeConfig(Map userConfig, Map referenceConfig)
  4. mergeCounterMap(Map map, String key, Object value)
  5. mergeCountMaps(Map base, Map other)
  6. mergeCustomProperties(Map copyTo, Map copyFrom)
  7. mergeDefaults(Map content, Map defaults)
  8. mergeEntries( Map dest, Iterable> entries)
  9. mergeEnv(Map newEnv, Map env)