Example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

List of usage examples for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap.

Prototype

public ConcurrentHashMap() 

Source Link

Document

Creates a new, empty map with the default initial table size (16).

Usage

From source file:Main.java

public static final <K, V> ConcurrentMap<K, V> newConcurrentMap() {
    return new ConcurrentHashMap<K, V>();
}

From source file:Main.java

public static <K, V> ConcurrentMap<K, V> createConcurrentMap() {
    return new ConcurrentHashMap<K, V>();
}

From source file:Main.java

public static <T> Set<T> newConcurentHashSet() {
    return Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>());
}

From source file:Main.java

/**
 * new concurrentHashMap// w  w  w.  j a  v  a 2s. co  m
 * 
 * @return
 */
public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap() {
    return new ConcurrentHashMap<K, V>();
}

From source file:Main.java

public static synchronized ConcurrentHashMap<String, String> getMap() {
    if (publicDnsMap == null) {
        publicDnsMap = new ConcurrentHashMap<String, String>();
    }//from w  w  w  . j av a 2  s.  c  om
    return publicDnsMap;
}

From source file:Main.java

public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
    Map<Object, Boolean> seen = new ConcurrentHashMap<>();
    return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}

From source file:Main.java

public static Map<String, String> getChildElementNodesMap(Node node) {
    if (node == null) {
        return null;
    }//from  w  ww.j  av  a  2  s.  c o m

    Map<String, String> map = new ConcurrentHashMap<>();
    NodeList nodeList = node.getChildNodes();
    if (nodeList != null && nodeList.getLength() > 0) {
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node item = nodeList.item(i);
            if (item != null && item.getNodeType() == Node.ELEMENT_NODE) {
                map.put(item.getNodeName(), item.getTextContent().trim());
            }
        }
    }
    return map;
}

From source file:Main.java

private static ConcurrentHashMap<String, Object> map() {
    if (_map.get() == null)
        _map.set(new ConcurrentHashMap<String, Object>());
    return _map.get();
}

From source file:Main.java

public static <K, V> ConcurrentHashMap<K, V> newConcurrentHashMap() {
    return new ConcurrentHashMap<K, V>();
}

From source file:Main.java

public static <KEY, VALUE> ConcurrentHashMap<KEY, VALUE> newConcurrentHashMap() {
    return new ConcurrentHashMap<KEY, VALUE>();
}