ecologylab.generic
Class HashMapWriteSynch<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by ecologylab.generic.HashMapWriteSynchBase<K,V>
              extended by ecologylab.generic.HashMapWriteSynch<K,V>
Type Parameters:
K -
V -
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
Direct Known Subclasses:
HashMapFromStringsWriteSynch

public class HashMapWriteSynch<K,V>
extends HashMapWriteSynchBase<K,V>

Hashed data structure with synchronized writes/deletes and unsynchronized reads.

Author:
andruid, robinson
See Also:
Serialized Form

Constructor Summary
HashMapWriteSynch()
           
HashMapWriteSynch(int arg0)
           
HashMapWriteSynch(int arg0, float arg1)
           
HashMapWriteSynch(java.util.Map<? extends K,? extends V> arg0)
           
 
Method Summary
 V getOrCreateAndPutIfNew(K key, ValueFactory<K,V> factory)
          If there is already an entry, return it.
 V getOrPutIfNew(K key, V value)
          If there is already an entry, return it.
 
Methods inherited from class ecologylab.generic.HashMapWriteSynchBase
putAll, remove
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

HashMapWriteSynch

public HashMapWriteSynch(int arg0,
                         float arg1)

HashMapWriteSynch

public HashMapWriteSynch(int arg0)

HashMapWriteSynch

public HashMapWriteSynch()

HashMapWriteSynch

public HashMapWriteSynch(java.util.Map<? extends K,? extends V> arg0)
Method Detail

getOrPutIfNew

public V getOrPutIfNew(K key,
                       V value)
If there is already an entry, return it. Otherwise, add the entry, and return null.

NB: NEVER replaces an existing entry.

Overrides:
getOrPutIfNew in class HashMapWriteSynchBase<K,V>

getOrCreateAndPutIfNew

public V getOrCreateAndPutIfNew(K key,
                                ValueFactory<K,V> factory)
If there is already an entry, return it. Otherwise, create an entry with the factory.

Returns:
The entry matching key, found or constructed.