com.faunos.util
Class CopyOnWriteMap<K,V>

java.lang.Object
  extended by com.faunos.util.AbstractCopyOnWriteMap<K,V,Map<K,V>>
      extended by com.faunos.util.CopyOnWriteMap<K,V>
All Implemented Interfaces:
Cloneable, Map<K,V>

public class CopyOnWriteMap<K,V>
extends AbstractCopyOnWriteMap<K,V,Map<K,V>>
implements Cloneable

A copy-on-write Map implementation using a backing java.util.HashMap.

Author:
Babak Farhang
See Also:
AbstractCopyOnWriteMap

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class com.faunos.util.AbstractCopyOnWriteMap
impl
 
Constructor Summary
CopyOnWriteMap()
          Default constructor creates an empty map.
CopyOnWriteMap(CopyOnWriteMap<K,V> copy)
          Copy constructor.
 
Method Summary
protected  Map<K,V> emptyMap()
          Returns an implementation-specific empty map.
protected  Map<K,V> newMap()
          Returns a new HashMap.
 
Methods inherited from class com.faunos.util.AbstractCopyOnWriteMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, setMap, size, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyOnWriteMap

public CopyOnWriteMap()
Default constructor creates an empty map.


CopyOnWriteMap

public CopyOnWriteMap(CopyOnWriteMap<K,V> copy)
Copy constructor. This makes a shallow copy. Note this class is also Cloneable.

Throws:
NullPointerException - if copy is null.
Method Detail

emptyMap

protected final Map<K,V> emptyMap()
Description copied from class: AbstractCopyOnWriteMap
Returns an implementation-specific empty map. The returned map may be read-only. An implementation ought to return the same empty instance across all instances of its class.

Specified by:
emptyMap in class AbstractCopyOnWriteMap<K,V,Map<K,V>>

newMap

protected Map<K,V> newMap()
Returns a new HashMap.

Specified by:
newMap in class AbstractCopyOnWriteMap<K,V,Map<K,V>>


SourceForge.net Logo