3 #include <IBinaryTreeNode.h>
4 #include <IterableTreeNode.h>
5 #include <ITreeIterator.h>
27 template <
typename NodeType>
34 friend class boost::serialization::access;
41 template<
class Archive>
42 void serialize(Archive &ar,
const unsigned int version){
43 boost::serialization::base_object<
47 ar &boost::serialization::base_object<
95 inline void start(NodeType *node,
int const depth=0){
123 if(node.
getNode()->getRightChild() !=
nullptr)
125 node.
getNode()->getRightChild(),
128 if(node.
getNode()->getLeftChild() !=
nullptr)
130 node.
getNode()->getLeftChild(),
Like fast depth first iterator but wrapping tree nodes inside a IterableTreeNode instance.
Definition: BinaryTreeDepthIterator.h:30
void serialize(Archive &ar, const unsigned int version)
Serialize a BinaryTreeDepthIterator to a stream of bytes.
Definition: BinaryTreeDepthIterator.h:42
void start(IterableTreeNode< IBinaryTreeNode > node) override
Start the iterator so the first visited node will be given one. It is, when calling next,...
Definition: BinaryTreeDepthIterator.h:104
void start(NodeType *node, int const depth=0)
Definition: BinaryTreeDepthIterator.h:95
bool hasNext() const override
Check if the iterator has more nodes to visit (true) or not (false)
Definition: BinaryTreeDepthIterator.h:114
BinaryTreeDepthIterator(NodeType *node, int const depth=0)
Construct a binary tree depth iterator calling the start method with given node.
Definition: BinaryTreeDepthIterator.h:75
deque< IterableTreeNode< IBinaryTreeNode > > pendingNodes
Double ended queue used as a stack to handle nodes visiting.
Definition: BinaryTreeDepthIterator.h:59
IterableTreeNode< IBinaryTreeNode > next() override
Obtain the next node according to depth iteration criterion.
Definition: BinaryTreeDepthIterator.h:120
BinaryTreeDepthIterator(IterableTreeNode< IBinaryTreeNode > node)
Construct a binary tree depth iterator calling the start method with given iterable tree node.
Definition: BinaryTreeDepthIterator.h:84
BinaryTreeDepthIterator()=default
Default constructor for binary tree depth iterator.
Interface defining core mechanisms that must be provided by any tree iterator.
Definition: ITreeIterator.h:13
Class representing an iterable tree node. It is a wrapper for a given tree node type which handles so...
Definition: IterableTreeNode.h:12
NodeType * getNode() const
Obtain the tree node being wrapped.
Definition: IterableTreeNode.h:63
int getDepth() const
Obtain the depth of wrapped tree node.
Definition: IterableTreeNode.h:84