// package net.datastructures; //begin#fragment BTNode /** * 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 BTNode * * @author Luca Vismara, Roberto Tamassia, Michael Goodrich //begin#fragment BTNode */ public class BTNode implements BTPosition { private E element; // element stored at this node private BTPosition left, right, parent; // adjacent nodes //end#fragment BTNode /** Default constructor */ public BTNode() { } //begin#fragment BTNode /** Main constructor */ public BTNode(E element, BTPosition parent, BTPosition left, BTPosition right) { setElement(element); setParent(parent); setLeft(left); setRight(right); } /** 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 left child of this position */ public BTPosition getLeft() { return left; } /** Sets the left child of this position */ public void setLeft(BTPosition v) { left=v; } /** Returns the right child of this position */ public BTPosition getRight() { return right; } /** Sets the right child of this position */ public void setRight(BTPosition v) { right=v; } /** Returns the parent of this position */ public BTPosition getParent() { return parent; } /** Sets the parent of this position */ public void setParent(BTPosition v) { parent=v; } } //end#fragment BTNode