public class ConcurrentWeakHashMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.concurrent.ConcurrentMap<K,V>
| Modifier and Type | Class and Description |
|---|---|
static interface |
ConcurrentWeakHashMap.LazyValueCreator<K,V> |
| Constructor and Description |
|---|
ConcurrentWeakHashMap()
Constructs a new, empty HashMap with a default capacity and load factor.
|
ConcurrentWeakHashMap(int initialCapacity)
Constructs a new, empty HashMap with the specified initial capacity and default load factor.
|
ConcurrentWeakHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
Constructs a new, empty HashMap with the specified initial capacity and the specified load factor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all mappings from all segment, leaving the ConcurrentWeakHashMap empty.
|
boolean |
containsKey(java.lang.Object key) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key)
Returns the value to which this HashMap maps the specified key.
|
V |
getOrPut(K key,
ConcurrentWeakHashMap.LazyValueCreator<K,V> valueCreator)
Checks if a value is already mapped and returns that one.
|
java.util.Set<K> |
keySet() |
V |
put(K key,
V value) |
V |
putIfAbsent(K key,
V value) |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size()
This function is not accurate under concurrent environment.
|
clone, containsValue, equals, hashCode, isEmpty, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitpublic ConcurrentWeakHashMap(int initialCapacity,
float loadFactor,
int concurrencyLevel)
initialCapacity - the initial capacity of the HashMap.loadFactor - a number between 0.0 and 1.0.concurrencyLevel - the estimated number of concurrently updating threads. The implementation performs internal sizing to
try to accommodate this many threads.java.lang.IllegalArgumentException - if neither keys nor values use hard references, if the initial capacity is less than or equal to zero,
or if the load factor is less than or equal to zeropublic ConcurrentWeakHashMap(int initialCapacity)
initialCapacity - the initial capacity of the HashMap.public ConcurrentWeakHashMap()
public V get(java.lang.Object key)
public V remove(java.lang.Object key)
public boolean remove(java.lang.Object key,
java.lang.Object value)
public int size()
public boolean containsKey(java.lang.Object key)
public void clear()
public java.util.Set<K> keySet()
public V getOrPut(K key, ConcurrentWeakHashMap.LazyValueCreator<K,V> valueCreator)
Please note that the returned value is always the one which stays inside the map after that call, which is totally different to traditional methods like put or putIfAbsent!
Copyright © 2018 SAP SE. All Rights Reserved.