net.datastructures
Class TreeNode<E>

java.lang.Object
  extended by net.datastructures.TreeNode<E>
All Implemented Interfaces:
Position<E>, TreePosition<E>

public class TreeNode<E>
extends java.lang.Object
implements TreePosition<E>

Class implementing a node of a binary tree by storing references to an element, a parent node, a left node, and a right node.

Author:
Luca Vismara, Roberto Tamassia, Michael Goodrich

Constructor Summary
TreeNode()
          Default constructor
TreeNode(E element, TreePosition<E> parent, PositionList<Position<E>> children)
          Main constructor
 
Method Summary
 E element()
          Returns the element stored at this position
 PositionList<Position<E>> getChildren()
          Returns the children of this position
 TreePosition<E> getParent()
          Returns the parent of this position
 void setChildren(PositionList<Position<E>> c)
          Sets the right child of this position
 void setElement(E o)
          Sets the element stored at this position
 void setParent(TreePosition<E> v)
          Sets the parent of this position
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode()
Default constructor


TreeNode

public TreeNode(E element,
                TreePosition<E> parent,
                PositionList<Position<E>> children)
Main constructor

Method Detail

element

public E element()
Returns the element stored at this position

Specified by:
element in interface Position<E>

setElement

public void setElement(E o)
Sets the element stored at this position

Specified by:
setElement in interface TreePosition<E>

getChildren

public PositionList<Position<E>> getChildren()
Returns the children of this position

Specified by:
getChildren in interface TreePosition<E>

setChildren

public void setChildren(PositionList<Position<E>> c)
Sets the right child of this position

Specified by:
setChildren in interface TreePosition<E>

getParent

public TreePosition<E> getParent()
Returns the parent of this position

Specified by:
getParent in interface TreePosition<E>

setParent

public void setParent(TreePosition<E> v)
Sets the parent of this position

Specified by:
setParent in interface TreePosition<E>