CompleteBinaryTree< DataType, StorageStrategy >::Node Class Reference
A node iterator of a CompleteBinaryTree.
More...
#include <completeBinaryTree.h>
List of all members.
Public Member Functions |
| Node () |
| Default constructor.
|
| Node (CompleteBinaryTree< DataType, StorageStrategy > *T, DataType *ptr, const SizeType bfsIndex) |
| Default constructor.
|
const DataType * | getAddress () const |
| Returns the address of the data of the node.
|
const SizeType & | getBfsIndex () const |
| Returns the bfs index of a node ( root node has bfs index = 1).
|
const SizeType & | getDepth () const |
| Returns the depth of the node (its distance from root).
|
SizeType | getHeight () const |
| Returns the height of the node (its distance from the leaves).
|
SizeType | getHorizontalIndex () const |
| Returns the horizontal index of this node ( the index among the same level nodes).
|
SizeType | getMemoryUsage () |
| Returns the number of bytes allocated to this node.
|
SizeType | getPoolIndex () const |
| Returns the pool index of the node ( the index of the array where it is stored).
|
void | goLeft () |
| Sets the node as its left child node There is NO check if this node is already a leaf.
|
void | goRight () |
| Sets the node as its right child node There is NO check if this node is already a leaf.
|
void | goUp () |
| Sets the node as its parent node There is NO check if this node is already a leaf.
|
bool | isLeaf () const |
| Checks if this Node is a leaf.
|
bool | isRightChild () const |
| Checks if this Node is a right child.
|
bool | isToTheLeftOf (const Node &other) const |
| Checks if this leaf is to the left of another node.
|
bool | isRoot () const |
| Checks if this Node is root.
|
Node & | operator= (const Node &other) |
| Assignment operator.
|
bool | operator== (const Node &other) const |
| Equality operator.
|
bool | operator!= (const Node &other) const |
| Inequality operator.
|
void | setAtBfsIndex (const SizeType &bfsIndex) |
| Sets the node at the given bfs index (root node has bfs index = 1).
|
void | setAtPos (const SizeType &height, const SizeType &horizontalPosition) |
| Sets the Node at a given height and a given horizontal index.
|
void | setAtRoot () |
| Sets the node at the root node.
|
Protected Attributes |
CompleteBinaryTree< DataType,
StorageStrategy > * | m_T |
| The binary tree this Node lies upon.
|
DataType * | m_ptr |
| The address where the node's data lie upon.
|
SizeType | m_bfsIndex |
| The index of the node in the node array using the Breadth First Search layout indexing.
|
SizeType | m_depth |
| The depth of the node (its distance from the root node).
|
Detailed Description
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
class CompleteBinaryTree< DataType, StorageStrategy >::Node
A node iterator of a CompleteBinaryTree.
- Template Parameters:
-
| DataType | The data to associate with the nodes. It must be a class or struct |
| StorageStrategy | The underlying storage implementation to use. Available implementations are 'HeapStorage', 'ExplicitHeapStorage', 'VebStorage', 'ExplicitVebStorage', 'ExplicitPowerVebStorage' and 'SplitStorage' |
- Author:
- Panos Michail
Constructor & Destructor Documentation
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Default constructor.
- Parameters:
-
| T | The tree the node lies upon |
| ptr | A pointer to the data associated with this node |
| bfsIndex | The index of the node in the Breadth First Search |
Member Function Documentation
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
const DataType* CompleteBinaryTree< DataType, StorageStrategy >::Node::getAddress |
( |
|
) |
const [inline] |
Returns the address of the data of the node.
- Returns:
- A pointer to the data of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
const SizeType& CompleteBinaryTree< DataType, StorageStrategy >::Node::getBfsIndex |
( |
|
) |
const [inline] |
Returns the bfs index of a node ( root node has bfs index = 1).
- Returns:
- The bfs index of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
const SizeType& CompleteBinaryTree< DataType, StorageStrategy >::Node::getDepth |
( |
|
) |
const [inline] |
Returns the depth of the node (its distance from root).
- Returns:
- The depth of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
SizeType CompleteBinaryTree< DataType, StorageStrategy >::Node::getHeight |
( |
|
) |
const [inline] |
Returns the height of the node (its distance from the leaves).
- Returns:
- The height of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
SizeType CompleteBinaryTree< DataType, StorageStrategy >::Node::getHorizontalIndex |
( |
|
) |
const [inline] |
Returns the horizontal index of this node ( the index among the same level nodes).
- Returns:
- The horizontal index of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
SizeType CompleteBinaryTree< DataType, StorageStrategy >::Node::getMemoryUsage |
( |
|
) |
[inline] |
Returns the number of bytes allocated to this node.
- Returns:
- The number of bytes allocated to this node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
SizeType CompleteBinaryTree< DataType, StorageStrategy >::Node::getPoolIndex |
( |
|
) |
const [inline] |
Returns the pool index of the node ( the index of the array where it is stored).
- Returns:
- The pool index of the node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Checks if this Node is a leaf.
- Returns:
- True if this Node is a leaf, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
bool CompleteBinaryTree< DataType, StorageStrategy >::Node::isRightChild |
( |
|
) |
const [inline] |
Checks if this Node is a right child.
- Returns:
- True if this Node is a right child, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Checks if this Node is root.
- Returns:
- True if this Node is root, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
bool CompleteBinaryTree< DataType, StorageStrategy >::Node::isToTheLeftOf |
( |
const Node & |
other |
) |
const [inline] |
Checks if this leaf is to the left of another node.
- Parameters:
-
| other | The node to compare to |
- Returns:
- True the ancestor of this node on the level of the other node is to the left of the other node, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Inequality operator.
- Parameters:
-
| other | The node to compare to |
- Returns:
- True if the other node points to different data from this node, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Assignment operator.
- Parameters:
-
- Returns:
- A reference to the newly assigned Node
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
Equality operator.
- Parameters:
-
| other | The node to compare to |
- Returns:
- True if the other node points to the same data as this node, false otherwise
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
void CompleteBinaryTree< DataType, StorageStrategy >::Node::setAtBfsIndex |
( |
const SizeType & |
bfsIndex |
) |
[inline] |
Sets the node at the given bfs index (root node has bfs index = 1).
- Parameters:
-
| bfsIndex | The bfs index to set the node to |
template<typename DataType, template< typename datatype > class StorageStrategy = HeapStorage>
void CompleteBinaryTree< DataType, StorageStrategy >::Node::setAtPos |
( |
const SizeType & |
height, |
|
|
const SizeType & |
horizontalPosition | |
|
) |
| | [inline] |
Sets the Node at a given height and a given horizontal index.
- Parameters:
-
| height | The new height of the node |
| horizontalPosition | The horizontal index of this node on this level |
The documentation for this class was generated from the following file: