2 #ifndef _TREE_ITERATOR_IMPL_CPP
3 #define _TREE_ITERATOR_IMPL_CPP
5 #ifndef _MADARA_NO_KARL_
44 while (!
stack_.top().left().is_null())
76 if (!stack_.is_empty())
79 if (!stack_.top().right().is_null())
83 stack_.push(stack_.pop().right());
86 while (!stack_.top().left().is_null())
87 stack_.push(stack_.top().left());
118 stack_.size() == in_order_rhs->
stack_.size())
121 if (stack_.is_empty() && in_order_rhs->
stack_.is_empty())
128 if (stack_.top().get_root() == in_order_rhs->
stack_.top().get_root())
145 return !(*
this == rhs);
197 if (!stack_.is_empty())
209 stack_.push(current.
right());
211 stack_.push(current.
left());
239 stack_.size() == pre_order_rhs->
stack_.size())
242 if (stack_.is_empty() && pre_order_rhs->
stack_.is_empty())
249 if (stack_.top().get_root() == pre_order_rhs->
stack_.top().get_root())
266 return !(*
this == rhs);
305 current = current.
left();
310 current = current.
right();
342 if (!stack_.is_empty())
351 if (!stack_.is_empty() &&
352 stack_.top().left().get_root() != current.
get_root() &&
356 current = stack_.top();
361 stack_.push(current.
right());
366 stack_.push(current.
left());
367 current = current.
left();
373 current = current.
right();
404 stack_.size() == post_order_rhs->
stack_.size())
407 if (stack_.is_empty() && post_order_rhs->
stack_.is_empty())
414 if (stack_.top().get_root() == post_order_rhs->
stack_.top().get_root())
431 return !(*
this == rhs);
469 return queue_.front();
478 return queue_.front();
485 if (!queue_.is_empty())
494 queue_.enqueue(root.
left());
496 queue_.enqueue(root.
right());
525 queue_.size() == level_order_rhs->
queue_.size())
528 if (queue_.is_empty() && level_order_rhs->
queue_.is_empty())
535 if (queue_.front().get_root() ==
536 level_order_rhs->
queue_.front().get_root())
553 return !(*
this == rhs);
virtual ComponentNode * right(void) const
Returns the right expression.
Implementation of the ExpressionTreeIterator pattern that is used to define the various iterations al...
virtual ~ExpressionTreeIteratorImpl(void)
Dtor.
ExpressionTreeIteratorImpl(const ExpressionTree &tree)
Construct an ExpressionTreeIteratorImpl to iterate over a tree.
const ExpressionTree & tree_
The tree we are iterating over.
Encapsulates a MADARA KaRL expression into an evaluatable tree.
ExpressionTree left(void)
Returns the left expression of this tree.
bool is_null(void) const
Checks if root pointer is null.
ExpressionTree right(void)
Returns the right expression of this tree.
ComponentNode * get_root(void)
Returns the root node of the expression tree.
Iterates through an ExpressionTree in in-order.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
InOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an InOrderIteratorImpl.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
virtual ~InOrderIteratorImpl(void)
Dtor.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
Iterates through an ExpressionTree in level-order.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
madara::utility::LQueue< ExpressionTree > queue_
Our current position in the iteration.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
LevelOrderExpressionTreeIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an LevelOrderExpressionTreeIterator.
virtual ~LevelOrderExpressionTreeIteratorImpl()
Dtor.
Iterates through an ExpressionTree in post-order.
virtual ~PostOrderIteratorImpl(void)
Dtor.
PostOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an PostOrderIteratorImpl.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
Iterates through an ExpressionTree in level-order.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
virtual ~PreOrderIteratorImpl()
Dtor.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
PreOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an LevelOrderExpressionTreeIterator.