Java Utililty Methods ConcurrentHashMap

List of utility methods to do ConcurrentHashMap

Description

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

Method

ConcurrentHashMapcreateConcurrentHashMap()
create Concurrent Hash Map
return new ConcurrentHashMap<K, V>();
ConcurrentHashMapcreateConcurrentHashMap()
Creates a concurrent map with lesser segements to save memory.
return createConcurrentHashMap(16);
MapgetConcurrentHashMap()
get Concurrent Hash Map
return Collections.synchronizedMap(new ConcurrentHashMap<K, V>());
doublegetDoubleSafe(ConcurrentHashMap map, String key)
get Double Safe
Double v = map.get(key);
if (v == null)
    return 0.0;
else
    return v;
ConcurrentHashMapgetMapSafe( ConcurrentHashMap> map, String key)
get Map Safe
ConcurrentHashMap<String, Double> map2 = map.get(key);
if (map2 == null) {
    map2 = new ConcurrentHashMap<String, Double>();
    map.put(key, map2);
return map2;
Map.Entrymax(ConcurrentHashMap map)
max
return map.reduceEntries(10, (e1, e2) -> {
    return e1.getValue() > e2.getValue() ? e1 : e2;
});
voidParseKeyValString(String keyValString, ConcurrentHashMap map)
Parse Key Val String
if (!keyValString.startsWith("#") && !keyValString.startsWith("//") && !keyValString.startsWith("
    for (i = 0; i < keyValString.length(); ++i) {
        char cur = keyValString.charAt(i);
        if (cur == ' ' || cur == '\t' || cur == '=') {
            i++;
            break;
        sb.append(cur);
...
voidparseMap(String config, ConcurrentHashMap map)
parse Map
StringTokenizer tupleTokenizer = new StringTokenizer(config, "/");
while (tupleTokenizer.hasMoreTokens()) {
    String tuple = tupleTokenizer.nextToken();
    StringTokenizer commaTokenizer = new StringTokenizer(tuple, ",");
    if (commaTokenizer.countTokens() != 2) {
        throw new Exception("parsing Map, wrong format!");
    String key = commaTokenizer.nextToken();
...
VputIfAbsent(ConcurrentHashMap col, K key, V val)
put If Absent
if (col.containsKey(key) == false) {
    col.put(key, val);
return col.get(key);
voidsetFieldValue(Object value, ConcurrentHashMap fieldHolder, String name, String desc)
set Field Value
fieldHolder.put(getFieldKey(name, desc), value);