public class CopyOnWriteMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>, java.lang.Cloneable
Map
in which all operations that change the
Map are implemented by making a new copy of the underlying Map.
While the creation of a new Map can be expensive, this class is designed for
cases in which the primary function is to read data from the Map, not to
modify the Map. Therefore the operations that do not cause a change to this
class happen quickly and concurrently.构造器和说明 |
---|
CopyOnWriteMap()
Creates a new instance of CopyOnWriteMap.
|
CopyOnWriteMap(int initialCapacity)
Creates a new instance of CopyOnWriteMap with the specified initial size
|
CopyOnWriteMap(java.util.Map<K,V> data)
Creates a new instance of CopyOnWriteMap in which the
initial data being held by this map is contained in
the supplied map.
|
限定符和类型 | 方法和说明 |
---|---|
void |
clear()
Removes all entries in this map.
|
java.lang.Object |
clone() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
This method will return a read-only
Set . |
V |
get(java.lang.Object key) |
boolean |
isEmpty() |
java.util.Set<K> |
keySet()
This method will return a read-only
Set . |
V |
put(K key,
V value)
Adds the provided key and value to this map.
|
void |
putAll(java.util.Map<? extends K,? extends V> newData)
Inserts all the keys and values contained in the
provided map to this map.
|
V |
remove(java.lang.Object key)
Removed the value and key from this map based on the
provided key.
|
int |
size() |
java.util.Collection<V> |
values()
This method will return a read-only
Collection . |
public CopyOnWriteMap()
public CopyOnWriteMap(int initialCapacity)
initialCapacity
- The initial size of the Map.public V remove(java.lang.Object key)
public void putAll(java.util.Map<? extends K,? extends V> newData)
public void clear()
public int size()
public boolean isEmpty()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public V get(java.lang.Object key)
public java.util.Set<K> keySet()
Set
.public java.util.Collection<V> values()
Collection
.public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Set
.public java.lang.Object clone()
clone
在类中 java.lang.Object