bubble v0.0.1
Loading...
Searching...
No Matches
avl_tree< T > Class Template Reference

Class for AVL tree. More...

#include <avl_tree.h>

Classes

class  Iterator
 Iterator class. More...
 

Public Member Functions

 avl_tree (std::vector< T > _elements={}) noexcept
 Contructor for AVL tree class.
 
 avl_tree (const avl_tree &a) noexcept
 Copy constructor for avl tree class.
 
avl_treeoperator= (const avl_tree &a) noexcept
 operator = for avl tree class
 
 ~avl_tree () noexcept
 Destroy the avl tree object.
 
void insert (T key)
 insert function.
 
void clear ()
 clear function Erase all the nodes from the tree.
 
get_root () const
 get_root function
 
bool search (T key)
 search function.
 
Iterator begin ()
 pointer that points to begin
 
Iterator end ()
 pointer that points to end
 
size_t size () const
 size function
 
void remove (T key)
 remove function.
 
std::vector< T > inorder () const
 inorder function.
 
std::vector< T > preorder () const
 preorder function.
 
std::vector< T > postorder () const
 postorder function.
 
std::vector< std::vector< T > > level_order ()
 level order function.
 

Friends

std::ostream & operator<< (std::ostream &out, avl_tree< T > &t)
 operator << for avl_tree class
 

Detailed Description

template<typename T>
class avl_tree< T >

Class for AVL tree.

Constructor & Destructor Documentation

◆ avl_tree() [1/2]

template<typename T >
avl_tree< T >::avl_tree ( std::vector< T > _elements = {})
inlineexplicitnoexcept

Contructor for AVL tree class.

Parameters
__elementsyou can directly pass a vector<T> so you don't have to do insert multiple times.

◆ avl_tree() [2/2]

template<typename T >
avl_tree< T >::avl_tree ( const avl_tree< T > & a)
inlineexplicitnoexcept

Copy constructor for avl tree class.

Parameters
athe tree we want to copy

Member Function Documentation

◆ begin()

template<typename T >
Iterator avl_tree< T >::begin ( )
inline

pointer that points to begin

Returns
Iterator

◆ end()

template<typename T >
Iterator avl_tree< T >::end ( )
inline

pointer that points to end

Returns
Iterator

◆ get_root()

template<typename T >
T avl_tree< T >::get_root ( ) const
inline

get_root function

Returns
T: the root value Created for bubble.h container

◆ inorder()

template<typename T >
std::vector< T > avl_tree< T >::inorder ( ) const
inline

inorder function.

Returns
vector<T>, the elements inorder.

◆ insert()

template<typename T >
void avl_tree< T >::insert ( T key)
inline

insert function.

Parameters
keykey to be inserted.

◆ level_order()

template<typename T >
std::vector< std::vector< T > > avl_tree< T >::level_order ( )
inline

level order function.

Returns
vector<T>, the level order traversal of the tree

◆ operator=()

template<typename T >
avl_tree & avl_tree< T >::operator= ( const avl_tree< T > & a)
inlinenoexcept

operator = for avl tree class

Parameters
athe tree we want to copy
Returns
avl_tree&

◆ postorder()

template<typename T >
std::vector< T > avl_tree< T >::postorder ( ) const
inline

postorder function.

Returns
vector<T>, the elements postorder.

◆ preorder()

template<typename T >
std::vector< T > avl_tree< T >::preorder ( ) const
inline

preorder function.

Returns
vector<T>, the elements preorder.

◆ remove()

template<typename T >
void avl_tree< T >::remove ( T key)
inline

remove function.

Parameters
keykey to be removed.

◆ search()

template<typename T >
bool avl_tree< T >::search ( T key)
inline

search function.

Parameters
keykey to be searched.
Returns
true if the key exists in the tree.

◆ size()

template<typename T >
size_t avl_tree< T >::size ( ) const
inline

size function

Returns
size_t the size of the tree

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