Package hudson.util
Class CopyOnWriteMap<K,V>
- java.lang.Object
-
- hudson.util.CopyOnWriteMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
- Direct Known Subclasses:
CopyOnWriteMap.Hash
,CopyOnWriteMap.Tree
public abstract class CopyOnWriteMap<K,V> extends Object implements Map<K,V>
Map
that has copy-on-write semantics.This class is suitable where highly concurrent access is needed, yet the write operation is relatively uncommon.
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CopyOnWriteMap.Hash<K,V>
CopyOnWriteMap
backed byHashMap
.static class
CopyOnWriteMap.Tree<K,V>
CopyOnWriteMap
backed byTreeMap
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CopyOnWriteMap()
protected
CopyOnWriteMap(Map<K,V> core)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
protected abstract Map<K,V>
copy()
Set<Map.Entry<K,V>>
entrySet()
This method will return a read-onlySet
.boolean
equals(Object obj)
V
get(Object key)
int
hashCode()
boolean
isEmpty()
Set<K>
keySet()
This method will return a read-onlySet
.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> t)
V
remove(Object key)
void
replaceBy(Map<? extends K,? extends V> data)
Atomically replaces the entire map by the copy of the specified map.int
size()
String
toString()
protected void
update(Map<K,V> m)
Collection<V>
values()
This method will return a read-onlyCollection
.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
replaceBy
public void replaceBy(Map<? extends K,? extends V> data)
Atomically replaces the entire map by the copy of the specified map.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
values
public Collection<V> values()
This method will return a read-onlyCollection
.
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
-