avlbinarysearchtree
Class AVLBinaryTree<E>

java.lang.Object
  extended by avlbinarysearchtree.AVLBinaryTree<E>

public class AVLBinaryTree<E>
extends java.lang.Object

This Class is to be used as a Generic AVLTree in your application


Field Summary
static int INORDER
          This To Specify Tree values inorder
static int POSTORDER
          This To Specify Tree values postorder
static int PREORDER
          This To Specify Tree values preorder
 
Constructor Summary
AVLBinaryTree()
          Default Constructor
AVLBinaryTree(boolean DUPLICATES)
          AVLTree Constructor
 
Method Summary
 boolean add(E obj)
          Adds New Element To The Tree
 boolean contains(E obj)
          Checks if the object is found in the tree or not
 E get(E obj)
          Reutrns a refence to the object if found in the tree
 E getMax()
          Reutrns a refence to the max object in the tree
 E getMin()
          Reutrns a refence to the min object in the tree
 int getSize()
          return the number of nodes in the tree
 boolean isEmpty()
          checks if tree is empty
 java.lang.String printTree()
          Prints The Tree Values
 java.lang.String printTree(int ORDER)
          Prints The Tree Values In The Specified Order
 java.lang.String printTree(int ORDER, java.lang.String seperator)
          Prints The Tree Values In The Specified Order and defines a new seperator to be used
 java.lang.String printTree(java.lang.String seperator)
          Prints The Tree Values
 boolean remove(E obj)
          Removes Element From The Tree
 boolean removeAll()
          This is to clear the AVLTree
 void setDuplicates(boolean DUPLICATES)
          allow duplicate values to be added to the tree if true parameter is given
 java.lang.Object[] toArray()
          Returns an array contains all values specified in the tree
 java.lang.Object[] toArray(int ORDER)
          Returns an array contains all values specified in the tree but in a specified order
<T> T[]
toArray(T[] a)
          Method used to Returns An Array Of The Tree Values Object type
<T> T[]
toArray(T[] a, int ORDER)
          Method used to Returns An Array Of The Tree Values Object type but in a specified order
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INORDER

public static final int INORDER
This To Specify Tree values inorder

See Also:
Constant Field Values

POSTORDER

public static final int POSTORDER
This To Specify Tree values postorder

See Also:
Constant Field Values

PREORDER

public static final int PREORDER
This To Specify Tree values preorder

See Also:
Constant Field Values
Constructor Detail

AVLBinaryTree

public AVLBinaryTree()
Default Constructor


AVLBinaryTree

public AVLBinaryTree(boolean DUPLICATES)
AVLTree Constructor

Parameters:
DUPLICATES - this is used to allow AVLTree to add the same value more than once
Method Detail

removeAll

public boolean removeAll()
This is to clear the AVLTree

Returns:
true or false

add

public boolean add(E obj)
Adds New Element To The Tree

Parameters:
obj - object added to the tree and implements comparable
Returns:
true or false

remove

public boolean remove(E obj)
Removes Element From The Tree

Parameters:
obj - object which will be removed if found in the tree which implements comparable
Returns:
true or false

printTree

public java.lang.String printTree()
Prints The Tree Values

Returns:
text to be printed

printTree

public java.lang.String printTree(java.lang.String seperator)
Prints The Tree Values

Parameters:
seperator - string value to seperate between tree values
Returns:
text to be printed

printTree

public java.lang.String printTree(int ORDER)
Prints The Tree Values In The Specified Order

Parameters:
ORDER -
Returns:
text to be printed in a specified order

printTree

public java.lang.String printTree(int ORDER,
                                  java.lang.String seperator)
Prints The Tree Values In The Specified Order and defines a new seperator to be used

Parameters:
ORDER - order of printing
seperator - the seperator to seperate tree values
Returns:
text to be printed in a specified order

contains

public boolean contains(E obj)
Checks if the object is found in the tree or not

Parameters:
obj - check if the tree has this object or not
Returns:
true or false

toArray

public java.lang.Object[] toArray()
Returns an array contains all values specified in the tree

Returns:
an array conrains all tree values

toArray

public <T> T[] toArray(T[] a)
Method used to Returns An Array Of The Tree Values Object type

Parameters:
a - the object to get values in it's type
Returns:
array of object type

toArray

public java.lang.Object[] toArray(int ORDER)
Returns an array contains all values specified in the tree but in a specified order

Parameters:
ORDER - order type
Returns:
an array contains tree values in a specified order

toArray

public <T> T[] toArray(T[] a,
                       int ORDER)
Method used to Returns An Array Of The Tree Values Object type but in a specified order

Parameters:
a - the object type
ORDER - order type
Returns:
array of object type in a specified order

getMin

public E getMin()
Reutrns a refence to the min object in the tree

Returns:
reference to th object found or null

getMax

public E getMax()
Reutrns a refence to the max object in the tree

Returns:
reference to th object found or null

get

public E get(E obj)
Reutrns a refence to the object if found in the tree

Parameters:
obj -
Returns:
reference to th object found or null

getSize

public int getSize()
return the number of nodes in the tree

Returns:
number of nodes

isEmpty

public boolean isEmpty()
checks if tree is empty

Returns:
true or false

setDuplicates

public void setDuplicates(boolean DUPLICATES)
allow duplicate values to be added to the tree if true parameter is given

Parameters:
DUPLICATES - sets the DUplicates values allaowance