The class SumTreeNode is a private class which represents a node in Sum-Tree. This is only used when we use proportional prioritization.
More...
#include <SumTreeNode.h>
|
int64_t | index_ = -1 |
| The index value of current node. This is only valid for leaf node and represents the index of the node from left. More...
|
|
bool | isLeaf_ = true |
| The boolean flag indicating if the current node is a leaf node or not. More...
|
|
SumTreeNode * | leftNode_ = nullptr |
| The pointer to left child node. More...
|
|
SumTreeNode * | parent_ = nullptr |
| The pointer to parent node. More...
|
|
SumTreeNode * | rightNode_ = nullptr |
| The pointer to right child node. More...
|
|
int64_t | treeIndex_ = -1 |
| The tree index of current node. This represents the index in of the node in container buffer. More...
|
|
int64_t | treeLevel_ = 0 |
| The tree level of current node. This represents the height of the node in the current tree. More...
|
|
float_t | value_ = 0 |
| The value of current node. Value of each node is the sum of its children's value. More...
|
|
The class SumTreeNode is a private class which represents a node in Sum-Tree. This is only used when we use proportional prioritization.
◆ SumTreeNode()
SumTreeNode::SumTreeNode |
( |
SumTreeNode * |
parent, |
|
|
float_t |
value, |
|
|
int64_t |
treeIndex = -1 , |
|
|
int64_t |
index = -1 , |
|
|
int64_t |
treeLevel = 0 , |
|
|
SumTreeNode * |
leftNode = nullptr , |
|
|
SumTreeNode * |
rightNode = nullptr |
|
) |
| |
Class constructor for SumTreeNode. Using this constructor we can set the pointers correctly to link the node with its right children and parents (if any).
- Parameters
-
*parent | : The pointer to the parent node. Can be set to nullptr if parent hasn't been allocated yet. |
value | : The value of the node. Value of each node is the sum of its children's value. |
treeIndex | : The tree index of a node representing the index in of the node in container buffer. |
index | : The index of the leaf node. It should be set to -1 if the node is not a leaf node. |
treeLevel | : The tree level of current node representing the height of the node in the current tree. |
*leftNode | : The pointer to left child node. |
*rightNode | : The pointer to right child node. |
◆ ~SumTreeNode()
SumTreeNode::~SumTreeNode |
( |
| ) |
|
|
default |
Sum-Tree Node default destructor.
◆ get_index()
int64_t SumTreeNode::get_index |
( |
| ) |
const |
Get the index value of the current node; from SumTreeNode::index_.
- Returns
- : The index value of the of leaf nodes, -1 for other nodes.
◆ get_left_node()
Get the pointer to left child node.
- Returns
- : The pointer to the left child node.
◆ get_parent()
Get the pointer to parent node.
- Returns
- : The pointer to the parent node.
◆ get_right_node()
Get the pointer to right child node.
- Returns
- : The pointer to the right child node.
◆ get_tree_index()
int64_t SumTreeNode::get_tree_index |
( |
| ) |
const |
◆ get_tree_level()
int64_t SumTreeNode::get_tree_level |
( |
| ) |
const |
Get the tree level value of the current node, i.e. the node's height; from SumTreeNode::treeLevel_.
- Returns
- : The tree level value, 1 indicating leaf level.
◆ get_value()
float_t SumTreeNode::get_value |
( |
| ) |
const |
Get the float value of the current node; from SumTreeNode::value_.
- Returns
- : The float value of the node.
◆ is_head()
bool SumTreeNode::is_head |
( |
| ) |
|
Get the status of the current node to check if the node is the root node.
- Returns
- : Flag indicating if the node is the head/root or not.
◆ is_leaf()
bool SumTreeNode::is_leaf |
( |
| ) |
const |
Get the status of the current node to check if the node is a leaf or not. It returns true for leaf nodes.
- Returns
- : Flag indicating if the node is a leaf or not.
◆ remove_left_node()
void SumTreeNode::remove_left_node |
( |
| ) |
|
Removes the left node. This will only de-link the nodes and will not de-allocate/free any memory.
◆ remove_right_node()
void SumTreeNode::remove_right_node |
( |
| ) |
|
Removes the right node. This will only de-link the nodes and will not de-allocate/free any memory.
◆ set_leaf_status()
void SumTreeNode::set_leaf_status |
( |
bool |
isLeaf | ) |
|
Sets the leaf status of the given node.
- Parameters
-
*isLeaf | : Boolean flag to be used to update. |
◆ set_left_node()
Sets the left child node for a given node. This must be set first before setting the right child node.
- Parameters
-
*node | : The pointer to the left node to be linked. |
◆ set_parent_node()
void SumTreeNode::set_parent_node |
( |
SumTreeNode * |
parent | ) |
|
Sets the parent of the given node.
- Parameters
-
*parent | : The pointer to the parent node to be linked. |
◆ set_right_node()
Sets the right child node for a given node. This will throw std::runtime_error
if left node has not been set.
- Parameters
-
*node | : The pointer to the right node to be linked. |
◆ set_value()
void SumTreeNode::set_value |
( |
float_t |
newValue | ) |
|
Sets the new value in the node.
- Parameters
-
newValue | : The new value to be set in the node. |
◆ index_
int64_t SumTreeNode::index_ = -1 |
|
private |
The index value of current node. This is only valid for leaf node and represents the index of the node from left.
◆ isLeaf_
bool SumTreeNode::isLeaf_ = true |
|
private |
The boolean flag indicating if the current node is a leaf node or not.
◆ leftNode_
The pointer to left child node.
◆ parent_
The pointer to parent node.
◆ rightNode_
The pointer to right child node.
◆ treeIndex_
int64_t SumTreeNode::treeIndex_ = -1 |
|
private |
The tree index of current node. This represents the index in of the node in container buffer.
◆ treeLevel_
int64_t SumTreeNode::treeLevel_ = 0 |
|
private |
The tree level of current node. This represents the height of the node in the current tree.
◆ value_
float_t SumTreeNode::value_ = 0 |
|
private |
The value of current node. Value of each node is the sum of its children's value.