jdsl
Class LinkedBinaryTree

java.lang.Object
  |
  +--jdsl.LinkedBinaryTree

public class LinkedBinaryTree
extends java.lang.Object
implements BinaryTree

This class is a speedy implementation of the BinaryTree interface.
It implements only the following subset of BinaryTree's methods:
size,isEmpty,replace,leftChild,rightChild,parent,isInternal,isExternal,
isRoot,root,and expandExternal.

See Also:
BinaryTree

Constructor Summary
LinkedBinaryTree()
           
 
Method Summary
 java.util.Iterator children(Position v)
           
 BinaryTree cut(Position subtreeRoot)
           
 java.util.Iterator elements()
           
 void expandExternal(Position v)
           
 boolean isEmpty()
           
 boolean isExternal(Position v)
           
 boolean isInternal(Position v)
           
 boolean isRoot(Position v)
           
 Position leftChild(Position v)
           
 void link(Position mustBeExternal, BinaryTree newSubtree)
           
 Container newContainer()
           
 Position parent(Position v)
           
 java.util.Iterator positions()
           
 void removeAboveExternal(Position v)
           
 java.lang.Object replace(Position v, java.lang.Object o)
           
 BinaryTree replaceSubtree(Position subtreeRoot, BinaryTree newSubtree)
           
 Position rightChild(Position v)
           
 Position root()
           
 Position sibling(Position v)
           
 java.util.Iterator siblings(Position v)
           
 int size()
           
 void swap(Position v, Position w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedBinaryTree

public LinkedBinaryTree()
Method Detail

size

public int size()

isEmpty

public boolean isEmpty()

replace

public java.lang.Object replace(Position v,
                                java.lang.Object o)

leftChild

public Position leftChild(Position v)
Specified by:
leftChild in interface BinaryTree

rightChild

public Position rightChild(Position v)
Specified by:
rightChild in interface BinaryTree

parent

public Position parent(Position v)

isInternal

public boolean isInternal(Position v)

isExternal

public boolean isExternal(Position v)

isRoot

public boolean isRoot(Position v)

root

public Position root()

expandExternal

public void expandExternal(Position v)
Specified by:
expandExternal in interface BinaryTree

newContainer

public Container newContainer()

children

public java.util.Iterator children(Position v)

siblings

public java.util.Iterator siblings(Position v)

sibling

public Position sibling(Position v)
Specified by:
sibling in interface BinaryTree

elements

public java.util.Iterator elements()

positions

public java.util.Iterator positions()

swap

public void swap(Position v,
                 Position w)

removeAboveExternal

public void removeAboveExternal(Position v)
Specified by:
removeAboveExternal in interface BinaryTree

cut

public BinaryTree cut(Position subtreeRoot)
Specified by:
cut in interface BinaryTree

link

public void link(Position mustBeExternal,
                 BinaryTree newSubtree)
Specified by:
link in interface BinaryTree

replaceSubtree

public BinaryTree replaceSubtree(Position subtreeRoot,
                                 BinaryTree newSubtree)
Specified by:
replaceSubtree in interface BinaryTree