edu.princeton.cs.algs4.growingtree.framework
Interface Tree<P extends NodeProperties>

All Known Subinterfaces:
AnimatingTree<P>, AnimatingTreeHead<P>, DrawingTree<P>, DrawingTreeHead<P>, TreeHead<P>
All Known Implementing Classes:
GrowingTreeHead, GrowingTreeNode, MovingBSTTree

public interface Tree<P extends NodeProperties>

A rooted Tree, where every node is pointed to by just one other node, which is called its parent.

A Tree represents a group of objects, known as its elements, each with its corresponding key. The key maps the value of each node and is used as a comparator. The Tree collection is similiar to a Map, except that duplicate keys are allowed.

Version:
1.1 9/15/01
Author:
Corey Sanders

Method Summary
 Tree[] getChildren()
          Returns the children of the current Tree.
 KeyType getKey()
          Returns the key of the current Tree.
 int getLevel()
          Gets the the level of the Tree.
 Tree<P> getParentTree()
          Returns the parent of the current Tree.
 java.lang.Object getValue()
          Returns the value of the current Tree.
 boolean isEmpty()
          Returns true if the current Tree is empty.
 int size()
          Returns the number of objects in the current Tree.
 

Method Detail

size

int size()
Returns the number of objects in the current Tree.

Returns:
the number of objects in the current Tree.

isEmpty

boolean isEmpty()
Returns true if the current Tree is empty.

Returns:
true if the Tree is empty.

getValue

java.lang.Object getValue()
Returns the value of the current Tree.

Returns:
the value of the current Tree.

getKey

KeyType getKey()
Returns the key of the current Tree.

Returns:
the key of the current Tree.

getLevel

int getLevel()
Gets the the level of the Tree. The level is the integer count of how far down in the tree the current node is.

Returns:
integer count of the level of the current Tree.

getParentTree

Tree<P> getParentTree()
Returns the parent of the current Tree.

Returns:
Tree that is the parent and null if the tree is the head.

getChildren

Tree[] getChildren()
Returns the children of the current Tree.

Returns:
Tree array that is the children and null if the tree is an exterior node.