org.aitools.programd.graph
Class OneOptimalNodemaster

java.lang.Object
  extended by org.aitools.programd.graph.AbstractNodemaster
      extended by org.aitools.programd.graph.OneOptimalNodemaster
All Implemented Interfaces:
Nodemapper

public class OneOptimalNodemaster
extends AbstractNodemaster

This is an optimization of NodemapperFactory that avoids creating the internal LinkedMap until the number of mappings exceeds one (1).

Author:
Noel Bush

Field Summary
protected  java.lang.String key
           
protected  int size
           
protected  java.lang.Object value
           
 
Fields inherited from class org.aitools.programd.graph.AbstractNodemaster
height, hidden, parent
 
Constructor Summary
OneOptimalNodemaster()
           
 
Method Summary
 boolean containsKey(java.lang.String keyToCheck)
          Tells whether the Nodemapper contains the given key.
 java.lang.Object get(java.lang.String keyToGet)
          Gets the object associated with the specified key.
 double getAverageSize()
          Returns a weighted average of the sizes of this Nodemapper and its children.
 java.util.Set<java.lang.String> keySet()
          Returns the key set for the Nodemapper.
 java.lang.Object put(java.lang.String keyToUse, java.lang.Object valueToPut)
          Puts the given object into the Nodemaster, associated with the given key.
 void remove(java.lang.Object valueToRemove)
          Removes the given object from the Nodemaster.
 int size()
          Returns the size of the Nodemapper
 
Methods inherited from class org.aitools.programd.graph.AbstractNodemaster
fillInHeight, getHeight, getParent, setParent, setTop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

protected int size

key

protected java.lang.String key

value

protected java.lang.Object value
Constructor Detail

OneOptimalNodemaster

public OneOptimalNodemaster()
Method Detail

put

public java.lang.Object put(java.lang.String keyToUse,
                            java.lang.Object valueToPut)
Puts the given object into the Nodemaster, associated with the given key.

Parameters:
keyToUse - the key to use
valueToPut - the value to put
Returns:
the same object that was put into the Nodemaster

remove

public void remove(java.lang.Object valueToRemove)
Removes the given object from the Nodemaster.

Parameters:
valueToRemove - the object to remove

get

public java.lang.Object get(java.lang.String keyToGet)
Gets the object associated with the specified key.

Parameters:
keyToGet - the key to use
Returns:
the object associated with the given key

keySet

public java.util.Set<java.lang.String> keySet()
Description copied from interface: Nodemapper
Returns the key set for the Nodemapper.

Returns:
the keyset of the Nodemaster

containsKey

public boolean containsKey(java.lang.String keyToCheck)
Description copied from interface: Nodemapper
Tells whether the Nodemapper contains the given key.

Parameters:
keyToCheck - the key to check
Returns:
whether or not the Nodemaster contains the given key

size

public int size()
Description copied from interface: Nodemapper
Returns the size of the Nodemapper

Returns:
the size of the Nodemaster

getAverageSize

public double getAverageSize()
Description copied from interface: Nodemapper
Returns a weighted average of the sizes of this Nodemapper and its children. The average is "weighted" by giving this Nodemapper's size and the average size of its children equal weight. If this Nodemapper does not have a parent (i.e., is the root), then its size is excluded from the calculation.

Returns:
the sizes of this Nodemapper and all its children.