The BST class represents a linked-memory BST Tree.
More...
#include <bst.h>
template<class K, class V>
class BST< K, V >
The BST class represents a linked-memory BST Tree.
- Template Parameters
-
K | the type of key stored in the tree |
V | the type of value stored in the tree |
◆ BST() [1/2]
template<class K , class V >
Constructor to create an empty tree.
◆ BST() [2/2]
template<class K , class V >
BST< K, V >::BST |
( |
const BST< K, V > & |
other | ) |
|
Copy constructor.
- Parameters
-
◆ ~BST()
template<class K , class V >
Destructor; frees all nodes associated with this tree.
◆ clear()
template<class K , class V >
Frees all nodes associated with this tree and sets it to be empty.
◆ find()
template<class K , class V >
V BST< K, V >::find |
( |
const K & |
key | ) |
|
Finds an element in the BST tree.
- Parameters
-
key | The element to search for |
- Returns
- The value stored for that key
◆ getInorderTraversal()
template<class K , class V >
Gets the in-order traversal of an BST tree's keys.
◆ getPreorderTraversal()
template<class K , class V >
Gets the pre-order traversal of an BST tree's keys.
◆ height()
template<class K , class V >
- Returns
- The height of the binary tree. Recall that the height of a binary tree is just the length of the longest path from the root to a leaf, and that the height of an empty tree is -1.
◆ insert()
template<class K , class V >
void BST< K, V >::insert |
( |
const K & |
key, |
|
|
const V & |
value |
|
) |
| |
Inserts a key and value into the BST.
- Parameters
-
key | The key to insert |
value | The value associated with the key |
◆ operator=()
template<class K , class V >
const BST< K, V > & BST< K, V >::operator= |
( |
const BST< K, V > & |
rhs | ) |
|
Assignment operator.
- Parameters
-
- Returns
- A reference to the current tree
◆ print()
template<class K , class V >
Prints the BST to a stream.
- Parameters
-
out | The stream to print to (default is stdout) |
◆ printFunctionOrder()
template<class K , class V >
Prints the function calls to a stream.
- Parameters
-
out | The stream to print to (default is stdout) |
◆ remove()
template<class K , class V >
void BST< K, V >::remove |
( |
const K & |
key | ) |
|
Removes a key from the BST.
The key is assumed to exist in the tree.
- Parameters
-
◆ setOutput()
template<class K , class V >
This function is used for grading.
- Parameters
-
newOut | The stream to print to |
The documentation for this class was generated from the following files:
- base/src/bst.h
- base/src/bst.hpp
- base/src/bst_given.hpp