ORIGINAL
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode Class Reference

Internal node class for Red-Black Tree. More...

#include <RBTree.h>

Collaboration diagram for original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode:
Collaboration graph

Public Types

enum class  color { BLACK , RED }
 Node color enumeration.
 

Public Member Functions

 RBNode (const K_TYPE &key=K_TYPE{}, const V_TYPE &value=V_TYPE{}, color color=color::RED, RBNode *parent=nullptr, RBNode *left=nullptr, RBNode *right=nullptr)
 Constructs a new RBNode.
 
 RBNode (const RBNode &other)
 Copy constructor.
 
RBNodeoperator= (const RBNode &other)
 Copy assignment operator.
 
 RBNode (RBNode &&other) noexcept
 Move constructor.
 
void swapData (RBNode &other) noexcept
 Swaps data with another node.
 
void swapColor (RBNode &other) noexcept
 Swaps color with another node.
 
couple< const K_TYPE, V_TYPE > & getVal ()
 Gets key-value pair (non-const)
 
const couple< const K_TYPE, V_TYPE > & getVal () const
 Gets key-value pair (const)
 
const K_TYPEgetKey () const
 Gets key.
 
const V_TYPEgetValue () const
 Gets value (const)
 
V_TYPEgetValue ()
 Gets value (non-const)
 
void setValue (const V_TYPE &value)
 Sets new value.
 
color getColor () const
 Gets node color.
 
RBNodegetPParent () const
 Gets parent node.
 
RBNodegetPLeft () const
 Gets left child.
 
RBNodegetPRight () const
 Gets right child.
 
RBNode *& getPLeftRef ()
 Gets left child reference.
 
RBNode *& getPRightRef ()
 Gets right child reference.
 
void setColor (color new_color)
 Sets node color.
 
void setPParent (RBNode *new_parent)
 Sets parent node.
 
void setPLeft (RBNode *new_left)
 Sets left child.
 
void setPRight (RBNode *new_right)
 Sets right child.
 

Static Public Member Functions

static void connect (RBNode *parent, RBNode *child, bool is_left)
 Connects parent and child nodes.
 

Detailed Description

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<K_TYPE>, typename Compare = increaseComparator<K_TYPE>>
class original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode

Internal node class for Red-Black Tree.

Represents a single node in the tree with:

Constructor & Destructor Documentation

◆ RBNode()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::RBNode ( const K_TYPE key = K_TYPE{},
const V_TYPE value = V_TYPE{},
color  color = color::RED,
RBNode parent = nullptr,
RBNode left = nullptr,
RBNode right = nullptr 
)
explicit

Constructs a new RBNode.

Parameters
keyKey to store
valueValue to store
colorInitial color (default: RED)
parentParent node (default: nullptr)
leftLeft child (default: nullptr)
rightRight child (default: nullptr)

Member Function Documentation

◆ connect()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::connect ( RBNode parent,
RBNode child,
bool  is_left 
)
static

Connects parent and child nodes.

Parameters
parentParent node
childChild node
is_leftWhether child is left child

◆ getColor()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::color original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getColor ( ) const

Gets node color.

Returns
Current color

◆ getKey()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
const K_TYPE & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getKey ( ) const

Gets key.

Returns
Const reference to key

◆ getPLeft()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode * original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getPLeft ( ) const

Gets left child.

Returns
Pointer to left child

◆ getPLeftRef()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode *& original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getPLeftRef ( )

Gets left child reference.

Returns
Reference to left child pointer

◆ getPParent()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode * original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getPParent ( ) const

Gets parent node.

Returns
Pointer to parent node

◆ getPRight()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode * original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getPRight ( ) const

Gets right child.

Returns
Pointer to right child

◆ getPRightRef()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode *& original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getPRightRef ( )

Gets right child reference.

Returns
Reference to right child pointer

◆ getVal() [1/2]

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
original::couple< const K_TYPE, V_TYPE > & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getVal ( )

Gets key-value pair (non-const)

Returns
Reference to key-value pair

◆ getVal() [2/2]

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
const original::couple< const K_TYPE, V_TYPE > & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getVal ( ) const

Gets key-value pair (const)

Returns
Const reference to key-value pair

◆ getValue() [1/2]

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
V_TYPE & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getValue ( )

Gets value (non-const)

Returns
Reference to value

◆ getValue() [2/2]

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
const V_TYPE & original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::getValue ( ) const

Gets value (const)

Returns
Const reference to value

◆ setColor()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::setColor ( color  new_color)

Sets node color.

Parameters
new_colorNew color to set

◆ setPLeft()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::setPLeft ( RBNode new_left)

Sets left child.

Parameters
new_leftNew left child to set

◆ setPParent()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::setPParent ( RBNode new_parent)

Sets parent node.

Parameters
new_parentNew parent to set

◆ setPRight()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::setPRight ( RBNode new_right)

Sets right child.

Parameters
new_rightNew right child to set

◆ setValue()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::setValue ( const V_TYPE value)

Sets new value.

Parameters
valueNew value to set

◆ swapColor()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::swapColor ( RBNode other)
noexcept

Swaps color with another node.

Parameters
otherNode to swap with

◆ swapData()

template<typename K_TYPE , typename V_TYPE , typename ALLOC , typename Compare >
void original::RBTree< K_TYPE, V_TYPE, ALLOC, Compare >::RBNode::swapData ( RBNode other)
noexcept

Swaps data with another node.

Parameters
otherNode to swap with

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