org.erights.e.elib.tables
Class IdentityMap

java.lang.Object
  |
  +--org.erights.e.elib.tables.IdentityMap
All Implemented Interfaces:
Iteratable

public class IdentityMap
extends Object
implements Iteratable

Untamed:


Field Summary
private  IdentityKeyColumn myKeys
           
private  float myLoadFactor
          The load factor for the map.
private  ShareCount myShareCount
           
private  int mySizeThreshold
          The current size threshold for the map, that is, the number of elements to hold before growing.
private  Column myValues
           
 
Constructor Summary
  IdentityMap()
          Enabled: Reasonable defaults
  IdentityMap(Class keyType, Class valueType)
          Enabled: Reasonable defaults
  IdentityMap(Class keyType, Class valueType, int initCapacity)
          Enabled:
  IdentityMap(Class keyType, Class valueType, int initCapacity, float loadFactor)
          Enabled:
private IdentityMap(IdentityKeyColumn keys, Column values)
          Reasonable defaults
private IdentityMap(IdentityKeyColumn keys, Column values, float loadFactor)
           
private IdentityMap(IdentityKeyColumn keys, Column values, float loadFactor, ShareCount shareCount)
           
  IdentityMap(int initialCapacity)
          Enabled: Reasonable defaults
  IdentityMap(int initialCapacity, float loadFactor)
          Enabled: Reasonable defaults
 
Method Summary
 IdentityMap diverge(Class kType, Class vType)
          Enabled: Unlike java.util.Hashtable, this part efficiently makes a lazy copy by copy-on-write sharing.
 Object get(Object key)
          Enabled: Returns the value to which the key is mapped in this map.
 Object get(Object key, Object instead)
          Enabled: Returns the value to which the key is mapped in this map.
 Object getKeys(Class type)
          Enabled:
 Object getValues(Class type)
          Enabled:
 void iterate(AssocFunc func)
          Enabled:
 Class keyType()
          Enabled: All keys in this map must be of this type
 boolean maps(Object key)
          Enabled: Returns true if the specified object is a key in the collection, as defined by the equality function of the collection.
 void put(Object key, Object value)
          Enabled: Defaults to not strict
 void put(Object key, Object value, boolean strict)
          Enabled:
private  void rehash()
           
 void removeAll()
          Enabled: Rather than doing a write-fault (which would make a private copy to be immediately dropped) this decrements the sharing count and re-initializes.
 void removeKey(Object key)
          Enabled: Defaults to not strict
 void removeKey(Object key, boolean strict)
          Enabled:
 int size()
          Enabled: The number of keys in the collection
 Class valueType()
          Enabled: All values in this map must be of this type
private  void writeFault()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myKeys

private IdentityKeyColumn myKeys

myValues

private Column myValues

mySizeThreshold

private int mySizeThreshold
The current size threshold for the map, that is, the number of elements to hold before growing. It is calculated as capacity * myLoadFactor.


myLoadFactor

private float myLoadFactor
The load factor for the map.


myShareCount

private ShareCount myShareCount
Constructor Detail

IdentityMap

public IdentityMap()
Enabled: Reasonable defaults


IdentityMap

public IdentityMap(int initialCapacity)
Enabled: Reasonable defaults


IdentityMap

public IdentityMap(int initialCapacity,
                   float loadFactor)
Enabled: Reasonable defaults


IdentityMap

public IdentityMap(Class keyType,
                   Class valueType)
Enabled: Reasonable defaults


IdentityMap

private IdentityMap(IdentityKeyColumn keys,
                    Column values)
Reasonable defaults


IdentityMap

private IdentityMap(IdentityKeyColumn keys,
                    Column values,
                    float loadFactor)

IdentityMap

private IdentityMap(IdentityKeyColumn keys,
                    Column values,
                    float loadFactor,
                    ShareCount shareCount)

IdentityMap

public IdentityMap(Class keyType,
                   Class valueType,
                   int initCapacity)
Enabled:


IdentityMap

public IdentityMap(Class keyType,
                   Class valueType,
                   int initCapacity,
                   float loadFactor)
Enabled:

Method Detail

get

public Object get(Object key)
           throws IndexOutOfBoundsException
Enabled: Returns the value to which the key is mapped in this map. Unlike java.util.Dictionary, a map doesn't indicate a lookup failure by returning null, since null is a valid value. map throws an exception instead.

IndexOutOfBoundsException

get

public Object get(Object key,
                  Object instead)
Enabled: Returns the value to which the key is mapped in this map. If key is not mapped, return 'instead' instead.


size

public int size()
Enabled: The number of keys in the collection


iterate

public void iterate(AssocFunc func)
Enabled:

Specified by:
iterate in interface Iteratable

maps

public boolean maps(Object key)
Enabled: Returns true if the specified object is a key in the collection, as defined by the equality function of the collection.

Parameters:
key - the object to look for
Returns:
true if the key is in the collection

getKeys

public Object getKeys(Class type)
Enabled:


getValues

public Object getValues(Class type)
Enabled:


put

public void put(Object key,
                Object value)
Enabled: Defaults to not strict


put

public void put(Object key,
                Object value,
                boolean strict)
Enabled:


rehash

private void rehash()

removeKey

public void removeKey(Object key)
Enabled: Defaults to not strict


removeKey

public void removeKey(Object key,
                      boolean strict)
Enabled:


removeAll

public void removeAll()
Enabled: Rather than doing a write-fault (which would make a private copy to be immediately dropped) this decrements the sharing count and re-initializes.


diverge

public IdentityMap diverge(Class kType,
                           Class vType)
Enabled: Unlike java.util.Hashtable, this part efficiently makes a lazy copy by copy-on-write sharing. Modify operations on a shared map then cause the delayed copy to happen.


keyType

public Class keyType()
Enabled: All keys in this map must be of this type


valueType

public Class valueType()
Enabled: All values in this map must be of this type


writeFault

private void writeFault()


comments?