com.waveset.util
Class TreeNode
java.lang.Object
com.waveset.util.TreeNode
- public class TreeNode
- extends java.lang.Object
A simple collection that stores the nodes in a tree and provides
for depth-first and breadth first iteration.
This is an unsynchronized class. If you use this class from multiple
threads, you must do it in a synchronized context.
Field Summary |
static java.lang.String |
code_id
|
Constructor Summary |
TreeNode(java.lang.Object key,
java.lang.Object o,
TreeNode parent)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
code_id
public static final java.lang.String code_id
- See Also:
- Constant Field Values
TreeNode
public TreeNode(java.lang.Object key,
java.lang.Object o,
TreeNode parent)
isEmpty
public boolean isEmpty()
containsKey
public boolean containsKey(java.lang.Object key,
boolean searchAllChildren)
containsValue
public boolean containsValue(java.lang.Object value,
boolean searchAllChildren)
get
public TreeNode get(java.lang.Object key,
boolean searchAllChildren)
- Get the requested object
getChildren
public java.util.List getChildren()
getKey
public java.lang.Object getKey()
getValue
public java.lang.Object getValue()
setValue
public void setValue(java.lang.Object value)
getParent
public TreeNode getParent()
setParent
public void setParent(TreeNode parent)
getTouched
public boolean getTouched()
setTouched
public void setTouched(boolean touched)
getTopNode
public TreeNode getTopNode()
- Walk to the top of the tree and return that node.
put
public TreeNode put(java.lang.Object key,
java.lang.Object value)
throws TreeNode.WouldCreateCycleException
- Throws:
TreeNode.WouldCreateCycleException
put
public void put(TreeNode child)
throws TreeNode.WouldCreateCycleException
- Throws:
TreeNode.WouldCreateCycleException
remove
public TreeNode remove(java.lang.Object key)
clear
public void clear()
toList
public java.util.List toList(boolean breadthFirst)
- Return a List of all keys in the tree which can be used for iterating
over the tree.
- Parameters:
breadthFirst
- - returns the keys in breadth order - the children
of this node will be first, then their children, etc. If false, the
keys are in depth order which will have the first child, then its first
child, etc.
toString
public java.lang.String toString()
equals
public boolean equals(java.lang.Object o)
main
public static void main(java.lang.String[] args)