Class for BST tree.
More...
#include <bst.h>
|
| | bst (std::vector< T > _elements={}) noexcept |
| | Contructor for BST tree class.
|
| | bst (const bst &b) |
| | Copy constructor for bst class.
|
| bst & | operator= (const bst &b) |
| | operator = for bst class
|
|
void | clear () |
| | clear function
|
| void | insert (T key) |
| | insert function.
|
| bool | search (T key) |
| | search function.
|
| void | remove (T key) |
| | remove function.
|
| Iterator | begin () |
| | pointer that points to begin
|
| Iterator | end () |
| | pointer that points to end
|
| size_t | size () |
| | size function
|
| std::vector< T > | inorder () |
| | inorder function.
|
| std::vector< T > | preorder () |
| | preorder function.
|
| std::vector< T > | postorder () |
| | postorder function.
|
| std::vector< std::vector< T > > | level_order () |
| | level order function
|
|
| std::ostream & | operator<< (std::ostream &out, bst< T > &t) |
| | visualize function
|
template<typename T>
class bst< T >
Class for BST tree.
◆ bst() [1/2]
template<typename T>
| bst< T >::bst |
( |
std::vector< T > | _elements = {} | ) |
|
|
inlineexplicitnoexcept |
Contructor for BST tree class.
- Parameters
-
| __elements | you can directly pass a vector<T> so you don't have to do insert multiple times. |
◆ bst() [2/2]
Copy constructor for bst class.
- Parameters
-
| b | the tree we want to copy |
◆ begin()
pointer that points to begin
- Returns
- Iterator
◆ end()
pointer that points to end
- Returns
- Iterator
◆ inorder()
template<typename T>
| std::vector< T > bst< T >::inorder |
( |
| ) |
|
|
inline |
inorder function.
- Returns
- vector<T>, the elements inorder.
◆ insert()
template<typename T>
| void bst< T >::insert |
( |
T | key | ) |
|
|
inline |
insert function.
- Parameters
-
◆ level_order()
template<typename T>
| std::vector< std::vector< T > > bst< T >::level_order |
( |
| ) |
|
|
inline |
level order function
- Returns
- vector<vector<T>>, the level order traversal of the tree
◆ operator=()
template<typename T>
| bst & bst< T >::operator= |
( |
const bst< T > & | b | ) |
|
|
inline |
operator = for bst class
- Parameters
-
| b | the tree we want to copy |
- Returns
- bst&
◆ postorder()
template<typename T>
| std::vector< T > bst< T >::postorder |
( |
| ) |
|
|
inline |
postorder function.
- Returns
- vector<T>, the elements postorder.
◆ preorder()
template<typename T>
| std::vector< T > bst< T >::preorder |
( |
| ) |
|
|
inline |
preorder function.
- Returns
- vector<T>, the elements preorder.
◆ remove()
template<typename T>
| void bst< T >::remove |
( |
T | key | ) |
|
|
inline |
remove function.
- Parameters
-
◆ search()
template<typename T>
| bool bst< T >::search |
( |
T | key | ) |
|
|
inline |
search function.
- Parameters
-
- Returns
- true if the key exists in the tree.
◆ size()
template<typename T>
| size_t bst< T >::size |
( |
| ) |
|
|
inline |
size function
- Returns
- size_t the size of the tree
◆ operator<<
template<typename T>
| std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
bst< T > & | t ) |
|
friend |
visualize function
- Returns
- .dot file that can be previewed using graphviz in vscode.
operator << for bst class
The documentation for this class was generated from the following file:
- /Users/runner/work/AlgoPlus/AlgoPlus/src/classes/tree/bst.h