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

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

#include <BinaryTreeFastBreadthIterator.h>

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

Public Member Functions

 BinaryTreeFastBreadthIterator ()=default
 Default constructor for binary tree fast breadth iterator.
 
 BinaryTreeFastBreadthIterator (NodeType *node)
 Construct a binary tree fast breadth 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 breadth 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 queue to handles nodes visiting.
 

Private Member Functions

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

Friends

class boost::serialization::access
 

Detailed Description

template<typename NodeType>
class BinaryTreeFastBreadthIterator< NodeType >

Fast breadth first iterator for binary tree like nodes.

Author
Alberto M. Esmoris Pena
Version
1.0

Breadth first node visiting order is illustrated below:

0
1 2
3 4 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

◆ BinaryTreeFastBreadthIterator()

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

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

Parameters
nodeNode to start breadth iterating from
See also
BinaryTreeFastBreadthIterator::start

Member Function Documentation

◆ hasNext()

template<typename NodeType >
bool BinaryTreeFastBreadthIterator< 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* BinaryTreeFastBreadthIterator< NodeType >::next ( )
inlineoverridevirtual

Obtain the next node according to breadth iteration criterion.

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

Implements ITreeIterator< NodeType * >.

◆ serialize()

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

Serialize a BinaryTreeFastBreadthIterator to a stream of bytes.

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

◆ start()

template<typename NodeType >
void BinaryTreeFastBreadthIterator< 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 breadth iterating from
See also
ITreeIterator::start

Implements ITreeIterator< NodeType * >.


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