public final class CopyOnWriteHashMap<K,V> extends AbstractMap<K,V>
This is essentially a hash array mapped trie: inner nodes use a bitmap in order to map hashes to slots by counting ones. In case of a collision (two values having the same 32-bits hash), a leaf node is created which stores and searches for values sequentially.
Reads and writes both perform in logarithmic time. Null keys and values are not supported.
This structure might need to perform several object creations per write so it is better suited for work-loads that are not too write-intensive.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 构造器和说明 |
|---|
CopyOnWriteHashMap()
Create a new empty map.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T[] |
appendElement(T[] array,
T element) |
boolean |
containsKey(Object key) |
CopyOnWriteHashMap<K,V> |
copyAndPut(K key,
V value)
Associate
key with value and return a new copy
of the hash table. |
<K1 extends K,V1 extends V> |
copyAndPutAll(Iterable<Map.Entry<K1,V1>> entries) |
CopyOnWriteHashMap<K,V> |
copyAndPutAll(Map<? extends K,? extends V> other)
Same as
copyAndPut(Object, Object) but for an arbitrary number of entries. |
CopyOnWriteHashMap<K,V> |
copyAndRemove(Object key)
Remove the given key from this map.
|
CopyOnWriteHashMap<K,V> |
copyAndRemoveAll(Collection<?> keys)
Same as
copyAndRemove(Object) but for an arbitrary number of entries. |
static <K,V> CopyOnWriteHashMap<K,V> |
copyOf(Map<? extends K,? extends V> map)
Return a copy of the provided map.
|
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
static <T> T[] |
insertElement(T[] array,
T element,
int index) |
int |
size() |
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, toString, valuescompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static <K,V> CopyOnWriteHashMap<K,V> copyOf(Map<? extends K,? extends V> map)
public static <T> T[] appendElement(T[] array,
T element)
public static <T> T[] insertElement(T[] array,
T element,
int index)
public boolean containsKey(Object key)
containsKey 在接口中 Map<K,V>containsKey 在类中 AbstractMap<K,V>public CopyOnWriteHashMap<K,V> copyAndPut(K key, V value)
key with value and return a new copy
of the hash table. The current hash table is not modified.public CopyOnWriteHashMap<K,V> copyAndPutAll(Map<? extends K,? extends V> other)
copyAndPut(Object, Object) but for an arbitrary number of entries.public <K1 extends K,V1 extends V> CopyOnWriteHashMap<K,V> copyAndPutAll(Iterable<Map.Entry<K1,V1>> entries)
public CopyOnWriteHashMap<K,V> copyAndRemove(Object key)
public CopyOnWriteHashMap<K,V> copyAndRemoveAll(Collection<?> keys)
copyAndRemove(Object) but for an arbitrary number of entries.Copyright © 2019. All rights reserved.