org.aitools.programd.graph
Class NonOptimalNodemaster

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

public class NonOptimalNodemaster
extends AbstractNodemaster

This is the most trivial, and likely the most wasteful, implementation of Nodemapper. It does not attempt to do any optimizations.

Author:
Noel Bush

Field Summary
 
Fields inherited from class org.aitools.programd.graph.AbstractNodemaster
height, hidden, parent
 
Constructor Summary
NonOptimalNodemaster()
           
 
Method Summary
 boolean containsKey(java.lang.String keyToCheck)
          Tells whether the Nodemapper contains the given key.
protected  void fillInHeight(int heightToFillIn)
          Sets the height of this Nodemaster to height, and calls fillInHeight() on its parent (if not null) with a height height + 1.
 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.
 int getHeight()
          Returns the height of the Nodemapper.
 Nodemapper getParent()
          Returns the parent of the Nodemapper
 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.
 void setParent(Nodemapper parentToSet)
          Sets the parent of the Nodemaster.
 void setTop()
          Sets the Nodemaster as being at the top.
 int size()
          Returns the size of the Nodemapper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonOptimalNodemaster

public NonOptimalNodemaster()
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

setParent

public void setParent(Nodemapper parentToSet)
Sets the parent of the Nodemaster.

Specified by:
setParent in interface Nodemapper
Overrides:
setParent in class AbstractNodemaster
Parameters:
parentToSet - the parent to set

getParent

public Nodemapper getParent()
Description copied from interface: Nodemapper
Returns the parent of the Nodemapper

Specified by:
getParent in interface Nodemapper
Overrides:
getParent in class AbstractNodemaster
Returns:
the parent of the Nodemaster

getHeight

public int getHeight()
Description copied from interface: Nodemapper
Returns the height of the Nodemapper. The height is the minimum number of words needed to reach a leaf node from here.

Specified by:
getHeight in interface Nodemapper
Overrides:
getHeight in class AbstractNodemaster
Returns:
the height of the Nodemaster

setTop

public void setTop()
Sets the Nodemaster as being at the top.

Specified by:
setTop in interface Nodemapper
Overrides:
setTop in class AbstractNodemaster

fillInHeight

protected void fillInHeight(int heightToFillIn)
Sets the height of this Nodemaster to height, and calls fillInHeight() on its parent (if not null) with a height height + 1.

Overrides:
fillInHeight in class AbstractNodemaster
Parameters:
heightToFillIn - the height for this node

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.