Package org.aoju.bus.core.map
Class SafeHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.concurrent.ConcurrentHashMap<K,V>
org.aoju.bus.core.map.SafeHashMap<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,ConcurrentMap<K,,V> Map<K,V>
安全的ConcurrentHashMap实现 此类用于解决在JDK8中调用
ConcurrentHashMap.computeIfAbsent(Object, Function)可能造成的死循环问题- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K,V> Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescription构造,默认初始大小(16)SafeHashMap(int initialCapacity) 构造SafeHashMap(int initialCapacity, float loadFactor) 构造SafeHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) 构造SafeHashMap(Map<? extends K, ? extends V> map) 构造 -
Method Summary
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, valuesMethods inherited from class java.util.AbstractMap
clone
-
Constructor Details
-
SafeHashMap
public SafeHashMap()构造,默认初始大小(16) -
SafeHashMap
public SafeHashMap(int initialCapacity) 构造- Parameters:
initialCapacity- 预估初始大小
-
SafeHashMap
-
SafeHashMap
public SafeHashMap(int initialCapacity, float loadFactor) 构造- Parameters:
initialCapacity- 初始容量loadFactor- 增长系数
-
SafeHashMap
public SafeHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) 构造- Parameters:
initialCapacity- 初始容量loadFactor- 增长系数concurrencyLevel- 并发级别,即Segment的个数
-
-
Method Details
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
computeIfAbsentin interfaceMap<K,V> - Overrides:
computeIfAbsentin classConcurrentHashMap<K,V>
-