Grafalgo
Library of useful data structures and algorithms
|
Class representing a collection of self-adjusting binary search trees. More...
#include <SaBstSet.h>
Public Member Functions | |
SaBstSet (int=100) | |
Constructor for SaBstSet class. | |
~SaBstSet () | |
Destructor for SaBstSet class. | |
bst | find (index) |
Get the root of the bst containing an item. | |
index | access (keytyp, bst &) |
Get the item with a specified key value. | |
bool | insert (index, bst &) |
Insert item into a bst. | |
void | remove (index, bst &) |
Remove an item from a bst. | |
BstPair | split (index, bst) |
Divide a bst at an item. | |
Protected Member Functions | |
index | splay (index) |
Splay a search tree. | |
void | splaystep (index) |
Perform a single splay step. |
Class representing a collection of self-adjusting binary search trees.
Each BST represents a set of items, where each item is represented by a tree node.
Definition at line 20 of file SaBstSet.h.
grafalgo::SaBstSet::SaBstSet | ( | int | size = 100 | ) |
Constructor for SaBstSet class.
size | defines the index range for the constructed object. |
Definition at line 20 of file SaBstSet.cpp.
grafalgo::SaBstSet::~SaBstSet | ( | ) |
Destructor for SaBstSet class.
Definition at line 23 of file SaBstSet.cpp.
index grafalgo::SaBstSet::access | ( | keytyp | k, |
bst & | t | ||
) |
Get the item with a specified key value.
k | is a key value |
t | is a reference to the root of some bst; if the operation changes the root, then t will change |
Definition at line 65 of file SaBstSet.cpp.
bst grafalgo::SaBstSet::find | ( | index | i | ) |
Get the root of the bst containing an item.
i | is an item in some bst |
Definition at line 56 of file SaBstSet.cpp.
bool grafalgo::SaBstSet::insert | ( | index | i, |
bst & | t | ||
) |
Insert item into a bst.
i | is a singleton item |
t | is the root of the bst that i is to be inserted into; if the operation changes the root, t is changed |
Reimplemented from grafalgo::BstSet.
Definition at line 83 of file SaBstSet.cpp.
void grafalgo::SaBstSet::remove | ( | index | i, |
bst & | t | ||
) |
Remove an item from a bst.
i | is an item in some bst |
t | is the bst containing i |
Reimplemented from grafalgo::BstSet.
Definition at line 105 of file SaBstSet.cpp.
index grafalgo::SaBstSet::splay | ( | index | x | ) | [protected] |
Splay a search tree.
x | is an item in a bst (equivalently, node in a search tree); the operation restructures the tree, moving x to the root |
Definition at line 30 of file SaBstSet.cpp.
void grafalgo::SaBstSet::splaystep | ( | index | x | ) | [protected] |
Perform a single splay step.
x | is a node in a search tree |
Definition at line 38 of file SaBstSet.cpp.
BstSet::BstPair grafalgo::SaBstSet::split | ( | index | i, |
bst | t | ||
) |
Divide a bst at an item.
i | is the index of a node in some bst |
t | is the root of the bst containing i |
Reimplemented from grafalgo::BstSet.
Reimplemented in grafalgo::DkBstSet.
Definition at line 132 of file SaBstSet.cpp.