SSF.OS.NetFlow
Class ShrinkableHashMap

java.lang.Object
  |
  +--SSF.OS.NetFlow.ShrinkableHashMap
Direct Known Subclasses:
IpFlowTable

public class ShrinkableHashMap
extends java.lang.Object

User defined HashMap. It can shrink as well as grow dynamically according to the usage of memory


Constructor Summary
ShrinkableHashMap()
          this default constructor should NOT be used
ShrinkableHashMap(int initialCapacity)
          Constructor: the LoadFactor is always set to be 1.0 specify the intial capacity
ShrinkableHashMap(int initialCapacity, float upperFactor)
          Constructor: specify the upperFactor and the initCapacity
ShrinkableHashMap(int initialCapacity, float upperFactor, float lowerFactor)
          Constructor: to specify the lower bound factor, it is necessary to specify the upperLoad factor too so that compiler won't get confused
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Return the object of the given key notice that potentially an object list is returned
protected  void growRehash()
          enlarge the table size by 2 (plus 1)
 void put(java.lang.Object key, java.lang.Object Item)
          Put the object with given key in the map.
 void remove(java.lang.Object key)
          Remove the object corrsponding to the given key if the memory utilization is low enough, shrink
protected  void shrinkRehash()
          shrink the table size by half
 java.util.Collection values()
          Return a collection view of all the objects stored in the map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShrinkableHashMap

public ShrinkableHashMap()
this default constructor should NOT be used


ShrinkableHashMap

public ShrinkableHashMap(int initialCapacity)
Constructor: the LoadFactor is always set to be 1.0 specify the intial capacity


ShrinkableHashMap

public ShrinkableHashMap(int initialCapacity,
                         float upperFactor)
Constructor: specify the upperFactor and the initCapacity


ShrinkableHashMap

public ShrinkableHashMap(int initialCapacity,
                         float upperFactor,
                         float lowerFactor)
Constructor: to specify the lower bound factor, it is necessary to specify the upperLoad factor too so that compiler won't get confused

Method Detail

shrinkRehash

protected void shrinkRehash()
shrink the table size by half


growRehash

protected void growRehash()
enlarge the table size by 2 (plus 1)


put

public void put(java.lang.Object key,
                java.lang.Object Item)
Put the object with given key in the map. "grow" in size if needed


get

public java.lang.Object get(java.lang.Object key)
Return the object of the given key notice that potentially an object list is returned


values

public java.util.Collection values()
Return a collection view of all the objects stored in the map


remove

public void remove(java.lang.Object key)
Remove the object corrsponding to the given key if the memory utilization is low enough, shrink