|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFlexOr.container.BinaryTree
public abstract class BinaryTree
Binary Tree is an abstract class implementing container. It is abstract
because the following methods which depend upon different policies on node
ordering.
-- add
-- contains
-- remove
-- clone -- needs a non abstract class to create an instance.
Constructor Summary | |
---|---|
BinaryTree()
|
Method Summary | |
---|---|
abstract void |
add(java.lang.Object obj)
Adds obj at the default location. |
abstract java.lang.Object |
clone()
Return a copy of the tree that points to the same objects as in the original tree. |
boolean |
contains(java.lang.Object obj)
Determines whether an element is in the tree. |
java.util.Enumeration<java.lang.Object> |
elements()
Returns an enumerator using inorder traversal -- left subtree first. |
boolean |
equals(java.lang.Object container)
Check for equality of contents of two containers. |
java.util.Enumeration<java.lang.Object> |
inOrderLRtraversal()
Return an enumerator using inorder traversal -- left subtree first. |
java.util.Enumeration<java.lang.Object> |
inOrderRLtraversal()
Return an enumerator using inorder traversal -- right subtree first. |
boolean |
isEmpty()
Check if the container is empty. |
boolean |
isFull()
Check if the container is full. |
java.util.Enumeration<java.lang.Object> |
levelOrderLRtraversal()
Return an enumerator using levelorder traversal -- left subtree first. |
java.util.Enumeration<java.lang.Object> |
levelOrderRLtraversal()
Return an enumerator using levelorder traversal -- right subtree first. |
java.util.Enumeration<java.lang.Object> |
postOrderLRtraversal()
Return an enumerator using postorder traversal -- left subtree first. |
java.util.Enumeration<java.lang.Object> |
postOrderRLtraversal()
Return an enumerator using postorder traversal -- right subtree first. |
java.util.Enumeration<java.lang.Object> |
preOrderLRtraversal()
Return an enumerator using preorder traversal -- left subtree first. |
java.util.Enumeration<java.lang.Object> |
preOrderRLtraversal()
Return an enumerator using preorder traversal -- right subtree first. |
java.lang.Object |
remove()
Remove the first element based on an inorder traversal of the tree contents. |
abstract boolean |
remove(java.lang.Object obj)
Remove the specified element. |
void |
removeAll()
Empty the container. |
int |
size()
Returns the number of elements in the container. |
java.lang.String |
toString()
Return a string representation of the contents of the tree. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BinaryTree()
Method Detail |
---|
public boolean contains(java.lang.Object obj)
levelOrderLRtraversal
to search the tree. Subclasses may want to
override this method.
Requires: True Ensures: contains(obj) => result = true not contains(obj) => result = false
contains
in interface Container
public boolean isEmpty()
Requires: True Ensures: isEmpty = (count = 0)
isEmpty
in interface Container
public boolean isFull()
Requires: True Ensures: isFull = false
isFull
in interface Container
public int size()
Requires: True Ensures: result = size
size
in interface Container
public java.util.Enumeration<java.lang.Object> elements()
elements
in interface Container
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> preOrderLRtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> preOrderRLtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> inOrderLRtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> inOrderRLtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> postOrderLRtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> postOrderRLtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> levelOrderLRtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public java.util.Enumeration<java.lang.Object> levelOrderRLtraversal()
java.util.NoSuchElementException
- when nextElement is called with an empty
enumeration sequence.public abstract void add(java.lang.Object obj)
obj
at the default location.
Requires: True Ensures: contains(obj) = true size = old size + 1
add
in interface Container
ContainerFullException
- if container already contains MaxLength
elements for finite size containers.public void removeAll()
Requires: True Ensures: size = 0
removeAll
in interface Container
public java.lang.Object remove()
Requires: size >= 0 Ensures: size = old size - 1 old inorderSequence = obj ^ inorderSequence
remove
in interface Container
ContainerEmptyException
- if removing from an empty container.public abstract boolean remove(java.lang.Object obj)
Requires: size >= 0 Ensures: old binaryTree.contains(obj) => binaryTree = old binaryTree / obj and result = true not old binaryTree.contains(obj) => binaryTree = old binaryTree and result = false
ContainerEmptyException
- if removing from an empty container.public abstract java.lang.Object clone()
Requires: True Ensures: result = copy of BinaryTree
clone
in interface Container
clone
in class java.lang.Object
public java.lang.String toString()
Requires: true Ensures: result = string representation of tree
toString
in interface Container
toString
in class java.lang.Object
public boolean equals(java.lang.Object container)
Requires: True Ensures: result = true => container contents are equal result = false => container contents are not equal
equals
in interface Container
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |