org.alicebot.server.core.node
Class Nodemaster

java.lang.Object
  extended by org.alicebot.server.core.node.Nodemaster
All Implemented Interfaces:
Nodemapper

public class Nodemaster
extends java.lang.Object
implements Nodemapper

This non-trivial implementation of Nodemapper uses a TreeMap internally, but only allocates it when the number of keys is two or more.

The Nodemaster saves space when many of the Nodemappers have only one branch, as is often the case in a real-world @{link Graphmaster Graphmaster}.

Author:
Richard Wallace, Noel Bush

Field Summary
protected  int height
          The minimum number of words needed to reach a leaf node from here.
protected  java.util.HashMap Hidden
           
protected  java.lang.String key
           
protected  Nodemapper parent
           
protected  int size
           
protected  java.lang.Object value
           
 
Constructor Summary
Nodemaster()
           
 
Method Summary
 boolean containsKey(java.lang.String key)
          Tells whether the Nodemapper contains the given key.
 java.lang.Object get(java.lang.String key)
          Gets an object from the Nodemapper.
 int getHeight()
          Returns the height of the Nodemapper.
 Nodemapper getParent()
          Returns the parent of the Nodemapper
 java.util.Set keySet()
          Returns the key set for the Nodemapper.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Puts an object into the Nodemapper.
 void remove(java.lang.Object value)
          Removes a node from the Nodemapper.
 void setParent(Nodemapper parent)
          Sets the parent of the Nodemapper
 void setTop()
          Sets the height of this Nodemapper to "top", i.e.
 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
 

Field Detail

size

protected int size

key

protected java.lang.String key

value

protected java.lang.Object value

Hidden

protected java.util.HashMap Hidden

height

protected int height
The minimum number of words needed to reach a leaf node from here. Defaults to Integer.MAX_VALUE (zero).


parent

protected Nodemapper parent
Constructor Detail

Nodemaster

public Nodemaster()
Method Detail

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Description copied from interface: Nodemapper
Puts an object into the Nodemapper.

Specified by:
put in interface Nodemapper
Parameters:
key - the key with which the object should be stored / will be retrieved
value - the object to be stored

remove

public void remove(java.lang.Object value)
Description copied from interface: Nodemapper
Removes a node from the Nodemapper.

Specified by:
remove in interface Nodemapper
Parameters:
value - the value to remove

get

public java.lang.Object get(java.lang.String key)
Description copied from interface: Nodemapper
Gets an object from the Nodemapper.

Specified by:
get in interface Nodemapper
Parameters:
key - the key to use in retrieving the object
Returns:
the object with that key (if found)

keySet

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

Specified by:
keySet in interface Nodemapper
Returns:
the Set of keys

containsKey

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

Specified by:
containsKey in interface Nodemapper
Parameters:
key - the key to look for
Returns:
boolean indicating whether the Nodemapper contains the key

size

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

Specified by:
size in interface Nodemapper
Returns:
the size of the Nodemapper

setParent

public void setParent(Nodemapper parent)
Description copied from interface: Nodemapper
Sets the parent of the Nodemapper

Specified by:
setParent in interface Nodemapper
Parameters:
parent - the parent of the Nodemapper

getParent

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

Specified by:
getParent in interface Nodemapper
Returns:
the parent of the Nodemapper

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
Returns:
the height of the Nodemapper

setTop

public void setTop()
Description copied from interface: Nodemapper
Sets the height of this Nodemapper to "top", i.e. 0 (zero), causing each ancestor n to have a minimum height of n, unless the ancestor is the root node. Not sure if this is correct.

Specified by:
setTop in interface Nodemapper