CSCI 151 with Dr. J, California State University, Chico

CSCI 151:  Algorithms and Data Structures


Main Page   Class Hierarchy   Compound List   File List   Compound Members  

RedBlackTree< Comparable > Class Template Reference

Implements a Red-Black search tree. More...

#include <RedBlackTree.h>

List of all members.

Public Types

enum  { RED, BLACK }
 An emun to define valid RedBlackNode node colors. More...


Public Methods

 RedBlackTree (const Comparable &negInf)
 Construct the tree.

 RedBlackTree (const RedBlackTree &rhs)
 Copy constructor.

 ~RedBlackTree ()
 Destructor for the tree.

const Comparable & findMin () const
 Find the smallest item in the tree.

const Comparable & findMax () const
 Find the largest item in the tree.

const Comparable & find (const Comparable &x) const
 Find item x in the tree.

bool isEmpty () const
 Test if the tree is logically empty.

void printTree () const
 Print the AVL tree contents in sorted order.

void makeEmpty ()
 Make the tree logically empty.

void insert (const Comparable &x)
 Insert x into the tree; duplicates are ignored.

void remove (const Comparable &x)
 Remove x from the tree.

const RedBlackTree & operator= (const RedBlackTree &rhs)
 Deep copy.


Detailed Description

template<class Comparable>
class RedBlackTree< Comparable >

Implements a Red-Black search tree.

Note that all "matching" is based on the compares method.

Author:
Mark Allen Weiss (http://www.cs.fiu.edu/~weiss/)


Member Enumeration Documentation

template<class Comparable>
anonymous enum
 

An emun to define valid RedBlackNode node colors.

Enumeration values:
RED  enum node color RED
BLACK  enum node color BLACK


Constructor & Destructor Documentation

template<class Comparable>
RedBlackTree< Comparable >::RedBlackTree const Comparable &    negInf [explicit]
 

Construct the tree.

Parameters:
negInf "negative infinity" indicator

template<class Comparable>
RedBlackTree< Comparable >::RedBlackTree const RedBlackTree< Comparable > &    rhs
 

Copy constructor.

Parameters:
rhs RedBlackTree object to copy from


Member Function Documentation

template<class Comparable>
const Comparable & RedBlackTree< Comparable >::find const Comparable &    x const
 

Find item x in the tree.

Parameters:
x item to look for
Returns:
the matching item or ITEM_NOT_FOUND if not found.

template<class Comparable>
const Comparable & RedBlackTree< Comparable >::findMax   const
 

Find the largest item in the tree.

Return the largest item of ITEM_NOT_FOUND if empty.

template<class Comparable>
const Comparable & RedBlackTree< Comparable >::findMin   const
 

Find the smallest item in the tree.

Return smallest item or ITEM_NOT_FOUND if empty.

template<class Comparable>
void RedBlackTree< Comparable >::insert const Comparable &    x
 

Insert x into the tree; duplicates are ignored.

Parameters:
x item to be inserted

template<class Comparable>
bool RedBlackTree< Comparable >::isEmpty   const
 

Test if the tree is logically empty.

Returns:
true if empty, false otherwise.

template<class Comparable>
void RedBlackTree< Comparable >::remove const Comparable &    x
 

Remove x from the tree.

Nothing is done if x is not found.

Parameters:
x item to be removed


The documentation for this class was generated from the following files:


Documentation generated using
doxygen