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

Fast depth first iterator for binary tree like nodes. More...

#include <BinaryTreeFastDepthIterator.h>

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

Public Member Functions

 BinaryTreeFastDepthIterator ()=default
 Default constructor for binary tree fast depth iterator.
 
 BinaryTreeFastDepthIterator (NodeType *node)
 Construct a binary tree fast depth iterator calling the start method with given node. More...
 
void start (NodeType *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...
 
NodeType * next () override
 Obtain the next node according to depth iteration criterion. More...
 
- Public Member Functions inherited from ITreeIterator< NodeType * >
 ITreeIterator ()=default
 Default constructor for tree iterator.
 

Protected Attributes

deque< 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 BinaryTreeFastDepthIterator to a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Detailed Description

template<typename NodeType>
class BinaryTreeFastDepthIterator< NodeType >

Fast depth first iterator for binary tree like nodes.

Author
Alberto M. Esmoris Pena
Version
1.0

Depth first node visiting order is illustrated below:

0
1 4
2 3 5 6
Template Parameters
NodeTypeType of binary tree node. It must correspond to a class which extends IBinaryTreeNode interface
See also
IBinaryTreeNode

Constructor & Destructor Documentation

◆ BinaryTreeFastDepthIterator()

template<typename NodeType >
BinaryTreeFastDepthIterator< NodeType >::BinaryTreeFastDepthIterator ( NodeType *  node)
inline

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

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

Member Function Documentation

◆ hasNext()

template<typename NodeType >
bool BinaryTreeFastDepthIterator< 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< NodeType * >.

◆ next()

template<typename NodeType >
NodeType* BinaryTreeFastDepthIterator< 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< NodeType * >.

◆ serialize()

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

Serialize a BinaryTreeFastDepthIterator to a stream of bytes.

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

◆ start()

template<typename NodeType >
void BinaryTreeFastDepthIterator< NodeType >::start ( NodeType *  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< NodeType * >.


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