Package com.yahoo.yolean.concurrent
Class CopyOnWriteHashMap<K,V>
java.lang.Object
com.yahoo.yolean.concurrent.CopyOnWriteHashMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
This is a thread hash map for small collections that are stable once built. Until it is stable there will be a race among all threads missing something in the map. They will then clone the map add the missing stuff and then put it back as active again. Here are no locks, but the cost is that inserts will happen a lot more than necessary. The map reference is volatile, but on most multi-cpu machines that has no cost unless modified.
- Author:
- baldersheim
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
isEmpty()
keySet()
void
int
size()
values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CopyOnWriteHashMap
public CopyOnWriteHashMap()
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-