Bridges-C++  3.1.1
Bridges(C++API)
Public Member Functions | List of all members
bridges::datastructure::AVLTreeElement< K, E > Class Template Reference

#include <AVLTreeElement.h>

Inheritance diagram for bridges::datastructure::AVLTreeElement< K, E >:
bridges::datastructure::BSTElement< K, E > bridges::datastructure::BinTreeElement< E > bridges::datastructure::TreeElement< E > bridges::datastructure::Element< E > bridges::datastructure::DataStructure

Detailed Description

template<typename K, typename E>
class bridges::datastructure::AVLTreeElement< K, E >

This class can be used to create avl tree elements, derived from BSTElement.

This class extends the BSTElement class by adding height and balance factor attributes to allow for easier use in a avl tree implementation.

Generic Parameters: K that is the search key type, E the application data type

Author
Kalpathi Subramanian
Date
6/18/15, 7/15/16

There is a tutorial about AVLs : http://bridgesuncc.github.io/tutorials/AVL.html

Public Member Functions

 AVLTreeElement (const K &k, const E &val=E(), const string &lab=string())
 
virtual const string getDStype () const override
 
int getHeight () const
 
void setHeight (const int &h)
 
int getBalanceFactor () const
 
void setBalanceFactor (const int &bf)
 
virtual AVLTreeElementgetLeft () override
 
virtual const AVLTreeElementgetLeft () const override
 
void setLeft (AVLTreeElement *l)
 
virtual AVLTreeElementgetRight () override
 
virtual const AVLTreeElementgetRight () const override
 
void setRight (AVLTreeElement *r)
 
- Public Member Functions inherited from bridges::datastructure::BSTElement< K, E >
 BSTElement (const K &k, BSTElement *l, BSTElement *r, const E &val=E(), const string &lab=string())
 
 BSTElement (const K &k, const E &val=E(), const string &lab=string())
 
getKey () const
 
void setKey (const K &k)
 
void setLeft (BSTElement *l)
 
void setRight (BSTElement *r)
 
- Public Member Functions inherited from bridges::datastructure::BinTreeElement< E >
 BinTreeElement (BinTreeElement *l, BinTreeElement *r, const E &e=E(), const string &lab=string())
 
 BinTreeElement (const E &e=E(), const string &lab=string())
 
void setLeft (BinTreeElement *l)
 
void setRight (BinTreeElement *r)
 
- Public Member Functions inherited from bridges::datastructure::TreeElement< E >
 TreeElement (const E &e=E(), const string &lab=string())
 
vector< TreeElement * > & getChildren ()
 
const vector< TreeElement * > & getChildren () const
 
TreeElementgetChild (const int &n)
 
const TreeElementgetChild (const int &n) const
 
void addChild (TreeElement *child)
 
void setChild (const size_t &index, TreeElement *kid)
 
- Public Member Functions inherited from bridges::datastructure::Element< E >
 Element (const E &val=E(), const string &lab=string())
 
 Element (const Element &e)
 
Elementoperator= (const Element &e)
 
E & operator= (E const &e)
 
virtual ~Element ()
 
ElementVisualizergetVisualizer ()
 
const ElementVisualizergetVisualizer () const
 
LinkVisualizergetLinkVisualizer (const Element *el)
 
LinkVisualizergetLinkVisualizer (const Element *el) const
 
string const & getLabel () const
 
void setLabel (const string &lab)
 
E const & getValue () const
 
E & getValue ()
 
void setValue (const E &val)
 
void setSize (const double &sz)
 Sets size of the element. More...
 
double getSize () const
 
void setColor (const Color &col)
 Set the color of the Element. More...
 
void setColor (const string col)
 Set the color by name. More...
 
Color getColor () const
 Get the current color of the element. More...
 
void setOpacity (double opacity)
 
double getOpacity ()
 
void setShape (const Shape &shp)
 Set the shape of the element. More...
 
Shape getShape () const
 Returns the shape of the element. More...
 
void setLocation (const double &locX, const double &locY)
 
double getLocationX () const
 
double getLocationY () const
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 

Additional Inherited Members

- Static Protected Member Functions inherited from bridges::datastructure::Element< E >
static const string getLinkRepresentation (const LinkVisualizer &lv, const string &src, const string &dest)
 
- Protected Attributes inherited from bridges::datastructure::BSTElement< K, E >
key = K()
 
- Protected Attributes inherited from bridges::datastructure::Element< E >
unordered_map< Element *, LinkVisualizerlinks
 

Constructor & Destructor Documentation

◆ AVLTreeElement()

template<typename K , typename E >
bridges::datastructure::AVLTreeElement< K, E >::AVLTreeElement ( const K &  k,
const E &  val = E(),
const string &  lab = string() 
)
inline

Constructs a AVLTreeElement with the provided value, label, key, setting the left and right AVLTreeElements to NULL. The defaults will be used if not provided.

Parameters
kThe key for ordering
valThe data to hold
labThe label to show

Member Function Documentation

◆ getBalanceFactor()

template<typename K , typename E >
int bridges::datastructure::AVLTreeElement< K, E >::getBalanceFactor ( ) const
inline

Get balance factor of this node

Returns
The balance factor of this AVLTreeElement

◆ getDStype()

template<typename K , typename E >
virtual const string bridges::datastructure::AVLTreeElement< K, E >::getDStype ( ) const
inlineoverridevirtual

Return the data structure name

Returns
the data structure type

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getHeight()

template<typename K , typename E >
int bridges::datastructure::AVLTreeElement< K, E >::getHeight ( ) const
inline

Get the height of the tree

Returns
The height of this AVLTreeElement

◆ getLeft() [1/2]

template<typename K , typename E >
virtual AVLTreeElement* bridges::datastructure::AVLTreeElement< K, E >::getLeft ( )
inlineoverridevirtual

Gets the left child

Returns
The left child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getLeft() [2/2]

template<typename K , typename E >
virtual const AVLTreeElement* bridges::datastructure::AVLTreeElement< K, E >::getLeft ( ) const
inlineoverridevirtual

Gets the left child - Constant version

Returns
The left child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getRight() [1/2]

template<typename K , typename E >
virtual AVLTreeElement* bridges::datastructure::AVLTreeElement< K, E >::getRight ( )
inlineoverridevirtual

Return the right child

Returns
The right child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ getRight() [2/2]

template<typename K , typename E >
virtual const AVLTreeElement* bridges::datastructure::AVLTreeElement< K, E >::getRight ( ) const
inlineoverridevirtual

Return the right child - Constant version

Returns
The right child

Reimplemented from bridges::datastructure::BSTElement< K, E >.

◆ setBalanceFactor()

template<typename K , typename E >
void bridges::datastructure::AVLTreeElement< K, E >::setBalanceFactor ( const int &  bf)
inline

Set the balance factor to "bf"

Parameters
bfThe balance factor of this AVLTreeElement
bfthe balance factor to set at this node

◆ setHeight()

template<typename K , typename E >
void bridges::datastructure::AVLTreeElement< K, E >::setHeight ( const int &  h)
inline

Set the height to "h"

Parameters
hthe height of the tree at this node

◆ setLeft()

template<typename K , typename E >
void bridges::datastructure::AVLTreeElement< K, E >::setLeft ( AVLTreeElement< K, E > *  l)
inline

Sets left child to "l"

Parameters
lThe left tree element

◆ setRight()

template<typename K , typename E >
void bridges::datastructure::AVLTreeElement< K, E >::setRight ( AVLTreeElement< K, E > *  r)
inline

Sets right child to "r"

Parameters
rThe right BSTElement

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