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

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

public class CopyOnWriteSortedMap<K,V>
extends AbstractCopyOnWriteMap<K,V,SortedMap<K,V>>
implements SortedMap<K,V>, Cloneable

A copy-on-write SortedMap implementation using a backing java.util.TreeMap.

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
CopyOnWriteSortedMap()
          Creates an empty instance.
CopyOnWriteSortedMap(Comparator<? super K> comparator)
          Creates an instance using the specified comparator.
CopyOnWriteSortedMap(CopyOnWriteSortedMap<K,V> copy)
          Copy constructor.
 
Method Summary
 Comparator<? super K> comparator()
           
protected  SortedMap<K,V> emptyMap()
          Returns an implementation-specific empty map.
 K firstKey()
           
 SortedMap<K,V> headMap(K toKey)
           
 K lastKey()
           
protected  SortedMap<K,V> newMap()
          Returns a new TreeMap.
 SortedMap<K,V> subMap(K fromKey, K toKey)
           
 SortedMap<K,V> tailMap(K fromKey)
           
 
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
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

CopyOnWriteSortedMap

public CopyOnWriteSortedMap()
Creates an empty instance.


CopyOnWriteSortedMap

public CopyOnWriteSortedMap(Comparator<? super K> comparator)
Creates an instance using the specified comparator.


CopyOnWriteSortedMap

public CopyOnWriteSortedMap(CopyOnWriteSortedMap<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 SortedMap<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,SortedMap<K,V>>

newMap

protected SortedMap<K,V> newMap()
Returns a new TreeMap.

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

comparator

public Comparator<? super K> comparator()
Specified by:
comparator in interface SortedMap<K,V>

firstKey

public K firstKey()
Specified by:
firstKey in interface SortedMap<K,V>

headMap

public SortedMap<K,V> headMap(K toKey)
Specified by:
headMap in interface SortedMap<K,V>

lastKey

public K lastKey()
Specified by:
lastKey in interface SortedMap<K,V>

subMap

public SortedMap<K,V> subMap(K fromKey,
                             K toKey)
Specified by:
subMap in interface SortedMap<K,V>

tailMap

public SortedMap<K,V> tailMap(K fromKey)
Specified by:
tailMap in interface SortedMap<K,V>


SourceForge.net Logo