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

#include <BSTElement.h>

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

Detailed Description

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

This class can be used to create binary search tree elements, derived from BinTreeElement.

This class extends the BinTreeElement class by adding a "key" property to allow for use in a binary search tree implementation.

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

See also
There is a tutorial about Binary Search Trees : http://bridgesuncc.github.io/tutorials/BinarySearchTree.html
Author
Kalpathi Subramanian
Date
6/18/15, 7/17/16, 7/12/19

Public Member Functions

 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())
 
virtual const string getDStype () const override
 
getKey () const
 
void setKey (const K &k)
 
virtual BSTElementgetLeft () override
 
virtual const BSTElementgetLeft () const override
 
void setLeft (BSTElement *l)
 
virtual BSTElementgetRight () override
 
virtual const BSTElementgetRight () const override
 
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
 

Protected Member Functions

virtual const string getElementRepresentation () const override
 

Protected Attributes

key = K()
 
- Protected Attributes inherited from bridges::datastructure::Element< E >
unordered_map< Element *, LinkVisualizerlinks
 

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)
 

Constructor & Destructor Documentation

◆ BSTElement() [1/2]

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

Constructs a BSTElement with the provided value, label, key, left and right BSTElements. The defaults will be used if not provided.

Parameters
kThe key for ordering
lThe left BSTElement
rThe right BSTElement
valThe data to hold
labThe label to show

◆ BSTElement() [2/2]

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

Constructs a BSTElement with the provided value, label, key, setting the left and right BSTElements 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

◆ getDStype()

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

Returns the data structure name

Returns
the data structure name

Reimplemented from bridges::datastructure::BinTreeElement< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >, and bridges::datastructure::AVLTreeElement< K, E >.

◆ getElementRepresentation()

template<typename K , typename E >
virtual const string bridges::datastructure::BSTElement< K, E >::getElementRepresentation ( ) const
inlineoverrideprotectedvirtual

Gets the JSON representation of this element

Reimplemented from bridges::datastructure::Element< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >.

◆ getKey()

template<typename K , typename E >
K bridges::datastructure::BSTElement< K, E >::getKey ( ) const
inline

Returns the key value

Returns
The key of this BSTElement

◆ getLeft() [1/2]

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

Return the left child

Returns
The left child

Reimplemented from bridges::datastructure::BinTreeElement< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >, and bridges::datastructure::AVLTreeElement< K, E >.

◆ getLeft() [2/2]

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

Return the left child - Constant version

Returns
The left child

Reimplemented from bridges::datastructure::BinTreeElement< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >, and bridges::datastructure::AVLTreeElement< K, E >.

◆ getRight() [1/2]

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

Return the right child

Returns
The right child

Reimplemented from bridges::datastructure::BinTreeElement< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >, and bridges::datastructure::AVLTreeElement< K, E >.

◆ getRight() [2/2]

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

Return the right child - Constant version

Returns
The right child

Reimplemented from bridges::datastructure::BinTreeElement< E >.

Reimplemented in bridges::datastructure::KdTreeElement< K, E >, and bridges::datastructure::AVLTreeElement< K, E >.

◆ setKey()

template<typename K , typename E >
void bridges::datastructure::BSTElement< K, E >::setKey ( const K &  k)
inline

Set key to "k"

Parameters
kThe key of this BSTElement

◆ setLeft()

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

Sets left to "l"

Parameters
lThe left child

◆ setRight()

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

Sets right child to "r"

Parameters
rThe right BSTElement

Member Data Documentation

◆ key

template<typename K , typename E >
K bridges::datastructure::BSTElement< K, E >::key = K()
protected

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