Helios++
Helios software for LiDAR simulations
BinaryTreeDepthIterator< NodeType > Class Template Reference

Like fast depth first iterator but wrapping tree nodes inside a IterableTreeNode instance. More...

#include <BinaryTreeDepthIterator.h>

Inheritance diagram for BinaryTreeDepthIterator< NodeType >:
Collaboration diagram for BinaryTreeDepthIterator< NodeType >:

Public Member Functions

 BinaryTreeDepthIterator ()=default
 Default constructor for binary tree depth iterator.
 
 BinaryTreeDepthIterator (NodeType *node, int const depth=0)
 Construct a binary tree depth iterator calling the start method with given node. More...
 
 BinaryTreeDepthIterator (IterableTreeNode< IBinaryTreeNode > node)
 Construct a binary tree depth iterator calling the start method with given iterable tree node. More...
 
void start (NodeType *node, int const depth=0)
 
void start (IterableTreeNode< IBinaryTreeNode > node) override
 Start the iterator so the first visited node will be given one. It is, when calling next, given node will be returned. More...
 
bool hasNext () const override
 Check if the iterator has more nodes to visit (true) or not (false) More...
 
IterableTreeNode< IBinaryTreeNodenext () override
 Obtain the next node according to depth iteration criterion. More...
 
- Public Member Functions inherited from ITreeIterator< IterableTreeNode< IBinaryTreeNode > >
 ITreeIterator ()=default
 Default constructor for tree iterator.
 

Protected Attributes

deque< IterableTreeNode< IBinaryTreeNode > > pendingNodes
 Double ended queue used as a stack to handle nodes visiting.
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize a BinaryTreeDepthIterator to a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename NodeType>
class BinaryTreeDepthIterator< NodeType >

Like fast depth first iterator but wrapping tree nodes inside a IterableTreeNode instance.

Author
Alberto M. Esmoris Pena
Version
1.0
Template Parameters
NodeTypeType of binary tree node. It must correspond to a class which extends IBinaryTreeNode interface
See also
BinaryTreeFastDepthIterator
IterableTreeNode
IBinaryTreeNode

Constructor & Destructor Documentation

◆ BinaryTreeDepthIterator() [1/2]

template<typename NodeType >
BinaryTreeDepthIterator< NodeType >::BinaryTreeDepthIterator ( NodeType *  node,
int const  depth = 0 
)
inline

Construct a binary tree depth iterator calling the start method with given node.

Parameters
nodeNode to start depth iterating from
depthThe depth at which given node is said to be located
See also
BinaryTreeDepthIterator::start

◆ BinaryTreeDepthIterator() [2/2]

template<typename NodeType >
BinaryTreeDepthIterator< NodeType >::BinaryTreeDepthIterator ( IterableTreeNode< IBinaryTreeNode node)
inline

Construct a binary tree depth iterator calling the start method with given iterable tree node.

Parameters
nodeIterable tree node to start depth iterating from
See also
BinaryTreeDepthIterator::start

Member Function Documentation

◆ hasNext()

template<typename NodeType >
bool BinaryTreeDepthIterator< NodeType >::hasNext ( ) const
inlineoverridevirtual

Check if the iterator has more nodes to visit (true) or not (false)

Returns
True if there are nodes left to be visited, false otherwise
See also
ITreeIterator::hasNext

Implements ITreeIterator< IterableTreeNode< IBinaryTreeNode > >.

◆ next()

template<typename NodeType >
IterableTreeNode<IBinaryTreeNode> BinaryTreeDepthIterator< NodeType >::next ( )
inlineoverridevirtual

Obtain the next node according to depth iteration criterion.

Returns
Next node according to depth iteration criterion
See also
ITreeIterator::next

Implements ITreeIterator< IterableTreeNode< IBinaryTreeNode > >.

◆ serialize()

template<typename NodeType >
template<class Archive >
void BinaryTreeDepthIterator< NodeType >::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Serialize a BinaryTreeDepthIterator to a stream of bytes.

Template Parameters
ArchiveType of rendering
Parameters
arSpecific rendering for the stream of bytes
versionVersion number for the BinaryTreeDepthIterator

◆ start() [1/2]

template<typename NodeType >
void BinaryTreeDepthIterator< NodeType >::start ( IterableTreeNode< IBinaryTreeNode node)
inlineoverridevirtual

Start the iterator so the first visited node will be given one. It is, when calling next, given node will be returned.

Parameters
nodeNode to start depth iterating from
See also
ITreeIterator::start

Implements ITreeIterator< IterableTreeNode< IBinaryTreeNode > >.

◆ start() [2/2]

template<typename NodeType >
void BinaryTreeDepthIterator< NodeType >::start ( NodeType *  node,
int const  depth = 0 
)
inline
Parameters
depthThe depth at which given node is said to be located
See also
start(IterableTreeNode<IBinaryTreeNode>)

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