All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class DataStructures.RedBlackTree

java.lang.Object
    |
    +----DataStructures.RedBlackTree

public class RedBlackTree
extends Object
Implements a red-black tree. Note that all "matching" is based on the compareTo method.


Constructor Index

 o RedBlackTree(Comparable)
Construct the tree.

Method Index

 o find(Comparable)
Find an item in the tree.
 o findMax()
Find the largest item in the tree.
 o findMin()
Find the smallest item the tree.
 o insert(Comparable)
Insert into the tree.
 o isEmpty()
Test if the tree is logically empty.
 o main(String[])
 o makeEmpty()
Make the tree logically empty.
 o printTree()
Print the tree contents in sorted order.
 o remove(Comparable)
Remove from the tree.

Constructors

 o RedBlackTree
public RedBlackTree(Comparable negInf)
Construct the tree.

Parameters:
negInf - a value less than or equal to all others.

Methods

 o insert
public void insert(Comparable item)
Insert into the tree. Does nothing if item already present.

Parameters:
item - the item to insert.
 o remove
public void remove(Comparable x)
Remove from the tree. Not implemented in this version.

Parameters:
x - the item to remove.
 o findMin
public Comparable findMin()
Find the smallest item the tree.

Returns:
the smallest item or null if empty.
 o findMax
public Comparable findMax()
Find the largest item in the tree.

Returns:
the largest item or null if empty.
 o find
public Comparable find(Comparable x)
Find an item in the tree.

Parameters:
x - the item to search for.
Returns:
the matching item or null if not found.
 o makeEmpty
public void makeEmpty()
Make the tree logically empty.

 o isEmpty
public boolean isEmpty()
Test if the tree is logically empty.

Returns:
true if empty, false otherwise.
 o printTree
public void printTree()
Print the tree contents in sorted order.

 o main
public static void main(String[] args)

All Packages  Class Hierarchy  This Package  Previous  Next  Index