Save This Page
Home » mahout-collections-1.0-src » org.apache.mahout.math.map » [javadoc | source]
org.apache.mahout.math.map
public class: OpenHashMap [javadoc | source]
java.lang.Object
   org.apache.mahout.math.PersistentObject
      org.apache.mahout.math.set.AbstractSet
         org.apache.mahout.math.map.OpenHashMap

All Implemented Interfaces:
    Map, Cloneable, Serializable

Open hash map. This implements Map, but it does not respect several aspects of the Map contract that impose the very sorts of performance penalities that this class exists to avoid. #entrySet , #values , and #keySet() do not return collections that share storage with the main map, and changes to those returned objects are not reflected in the container.
Field Summary
protected static final  byte FREE     
protected static final  byte FULL     
protected static final  byte REMOVED     
protected static final  Object NO_KEY_VALUE     
protected  Object[] table    The hash table keys. 
protected  Object[] values    The hash table values. 
protected  byte[] state    The state of each hash table entry (FREE, FULL, REMOVED). 
protected  int freeEntries    The number of table entries in state==FREE. 
Fields inherited from org.apache.mahout.math.set.AbstractSet:
distinct,  lowWaterMark,  highWaterMark,  minLoadFactor,  maxLoadFactor,  defaultCapacity,  defaultMinLoadFactor,  defaultMaxLoadFactor
Constructor:
 public OpenHashMap() 
 public OpenHashMap(int initialCapacity) 
 public OpenHashMap(int initialCapacity,
    double minLoadFactor,
    double maxLoadFactor) 
Method from org.apache.mahout.math.map.OpenHashMap Summary:
clear,   clone,   containsKey,   containsValue,   ensureCapacity,   entrySet,   equals,   forEachKey,   forEachPair,   get,   getInternalFactors,   indexOfInsertion,   indexOfKey,   indexOfValue,   keySet,   keys,   put,   putAll,   rehash,   remove,   setUp,   toString,   trimToSize,   values
Methods from org.apache.mahout.math.set.AbstractSet:
chooseGrowCapacity,   chooseHighWaterMark,   chooseLowWaterMark,   chooseMeanCapacity,   chooseShrinkCapacity,   clear,   ensureCapacity,   equalsMindTheNull,   isEmpty,   nextPrime,   setUp,   size,   trimToSize
Methods from org.apache.mahout.math.PersistentObject:
clone
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.mahout.math.map.OpenHashMap Detail:
 public  void clear() 
    Removes all (key,value) associations from the receiver. Implicitly calls trimToSize().
 public Object clone() 
    Returns a deep copy of the receiver.
 public boolean containsKey(Object key) 
    Returns true if the receiver contains the specified key.
 public boolean containsValue(Object value) 
    Returns true if the receiver contains the specified value.
 public  void ensureCapacity(int minCapacity) 
    Ensures that the receiver can hold at least the specified number of associations without needing to allocate new internal memory. If necessary, allocates new internal memory and increases the capacity of the receiver.

    This method never need be called; it is for performance tuning only. Calling this method before put()ing a large number of associations boosts performance, because the receiver will grow only once instead of potentially many times and hash collisions get less probable.

 public Set<K, V> entrySet() 
    Allocate a set to contain Map.Entry objects for the pairs and return it.
 public boolean equals(Object obj) 
 public boolean forEachKey(ObjectProcedure<K> procedure) 
    Applies a procedure to each key of the receiver, if any. Note: Iterates over the keys in no particular order. Subclasses can define a particular order, for example, "sorted by key". All methods which can be expressed in terms of this method (most methods can) must guarantee to use the same order defined by this method, even if it is no particular order. This is necessary so that, for example, methods keys and values will yield association pairs, not two uncorrelated lists.
 public boolean forEachPair(ObjectObjectProcedure<K, V> procedure) 
    Applies a procedure to each (key,value) pair of the receiver, if any. Iteration order is guaranteed to be identical to the order used by method #forEachKey(ObjectProcedure) .
 public V get(Object key) 
    Returns the value associated with the specified key. It is often a good idea to first check with #containsKey(Object) whether the given key has a value associated or not, i.e. whether there exists an association for the given key or not.
  void getInternalFactors(int[] capacity,
    double[] minLoadFactor,
    double[] maxLoadFactor) 
    Access for unit tests.
 protected int indexOfInsertion(K key) 
 protected int indexOfKey(K key) 
 protected int indexOfValue(V value) 
 public Set<K> keySet() 
    Allocate a set to contain keys and return it. This violates the 'backing' provisions of the map interface.
 public  void keys(List<K> list) 
    Fills all keys contained in the receiver into the specified list. Fills the list, starting at index 0. After this call returns the specified list has a new size that equals this.size(). This method can be used to iterate over the keys of the receiver.
 public V put(K key,
    V value) 
    Associates the given key with the given value. Replaces any old (key,someOtherValue) association, if existing.
 public  void putAll(Map<? extends K, ? extends V> m) 
 protected  void rehash(int newCapacity) 
    Rehashes the contents of the receiver into a new table with a smaller or larger capacity. This method is called automatically when the number of keys in the receiver exceeds the high water mark or falls below the low water mark.
 public V remove(Object key) 
    Removes the given key with its associated element from the receiver, if present.
 protected  void setUp(int initialCapacity,
    double minLoadFactor,
    double maxLoadFactor) 
    Initializes the receiver.
 public String toString() 
 public  void trimToSize() 
    Trims the capacity of the receiver to be the receiver's current size. Releases any superfluous internal memory. An application can use this operation to minimize the storage of the receiver.
 public Collection<V> values() 
    Allocate a list to contain the values and return it. This violates the 'backing' provision of the Map interface.