package net.datastructures; //begin#fragment TNode /** * Class implementing a node of a binary tree by storing references to * an element, a parent node, a left node, and a right node. //end#fragment TNode * * @author Luca Vismara, Roberto Tamassia, Michael Goodrich //begin#fragment TNode */ public class TreeNode implements TreePosition { private E element; // element stored at this node private TreePosition parent; // adjacent node private PositionList> children; // children nodes //end#fragment TNode /** Default constructor */ public TreeNode() { } //begin#fragment TNode /** Main constructor */ public TreeNode(E element, TreePosition parent, PositionList> children) { setElement(element); setParent(parent); setChildren(children); } /** Returns the element stored at this position */ public E element() { return element; } /** Sets the element stored at this position */ public void setElement(E o) { element=o; } /** Returns the children of this position */ public PositionList> getChildren() { return children; } /** Sets the right child of this position */ public void setChildren(PositionList> c) { children=c; } /** Returns the parent of this position */ public TreePosition getParent() { return parent; } /** Sets the parent of this position */ public void setParent(TreePosition v) { parent=v; } } //end#fragment TNode