2 #ifndef _TREE_ITERATOR_IMPL_CPP 3 #define _TREE_ITERATOR_IMPL_CPP 5 #ifndef _MADARA_NO_KARL_ 41 stack_.push (const_cast <ExpressionTree &> (tree));
44 while (!
stack_.top ().left ().is_null ())
82 if (!
stack_.top ().right ().is_null ())
89 while (!
stack_.top ().left ().is_null ())
123 if (t1.
get_root () == t2.get_root ()
127 if (
stack_.is_empty () && in_order_rhs->
stack_.is_empty ())
134 if (
stack_.top ().get_root () ==
135 in_order_rhs->
stack_.top ().get_root ())
153 return ! (*
this == rhs);
176 stack_.push (const_cast <ExpressionTree &> (tree));
252 pre_order_rhs->
tree_);
254 if (t1.
get_root () == t2.get_root ()
258 if (
stack_.is_empty () && pre_order_rhs->
stack_.is_empty ())
265 if (
stack_.top ().get_root () ==
266 pre_order_rhs->
stack_.top ().get_root ())
284 return ! (*
this == rhs);
325 current = current.
left ();
330 current = current.
right ();
391 current = current.
left ();
397 current = current.
right ();
427 post_order_rhs->
tree_);
429 if (t1.
get_root () == t2.get_root ()
433 if (
stack_.is_empty () && post_order_rhs->
stack_.is_empty ())
440 if (
stack_.top ().get_root () ==
441 post_order_rhs->
stack_.top ().get_root ())
459 return ! (*
this == rhs);
482 queue_.enqueue (const_cast <ExpressionTree &> (tree));
555 level_order_rhs->
tree_);
557 if (t1.
get_root () == t2.get_root ()
561 if (
queue_.is_empty () && level_order_rhs->
queue_.is_empty ())
568 if (
queue_.front ().get_root () ==
569 level_order_rhs->
queue_.front ().get_root ())
587 return !(*
this == rhs);
600 #endif // _MADARA_NO_KARL_ PreOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an LevelOrderExpressionTreeIterator.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
Encapsulates a MADARA KaRL expression into an evaluatable tree.
madara::utility::LQueue< ExpressionTree > queue_
Our current position in the iteration.
bool is_null(void) const
Checks if root pointer is null.
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
Iterates through an ExpressionTree in in-order.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
LevelOrderExpressionTreeIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an LevelOrderExpressionTreeIterator.
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
virtual ~LevelOrderExpressionTreeIteratorImpl()
Dtor.
virtual ~ExpressionTreeIteratorImpl(void)
Dtor.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
Iterates through an ExpressionTree in post-order.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
virtual void operator++(void)
Increment operator (used for both pre- and post-increment).
madara::utility::LStack< ExpressionTree > stack_
Our current position in the iteration.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
ComponentNode * get_root(void)
Returns the root node of the expression tree.
Iterates through an ExpressionTree in level-order.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
ExpressionTree left(void)
Returns the left expression of this tree.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
ExpressionTree right(void)
Returns the right expression of this tree.
virtual ExpressionTree operator*(void)
Dereference operator returns a reference to the item contained at the current position.
virtual bool operator!=(const ExpressionTreeIteratorImpl &lhs) const
Nonequality operator.
Iterates through an ExpressionTree in level-order.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
ExpressionTreeIteratorImpl(const ExpressionTree &tree)
Construct an ExpressionTreeIteratorImpl to iterate over a tree.
virtual ~PostOrderIteratorImpl(void)
Dtor.
InOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an InOrderIteratorImpl.
Implementation of the ExpressionTreeIterator pattern that is used to define the various iterations al...
virtual ~PreOrderIteratorImpl()
Dtor.
virtual ExpressionTreeIteratorImpl * clone(void)
Method for cloning an impl. Necessary for post increments.
PostOrderIteratorImpl(const ExpressionTree &tree, bool end_iter=false)
Construct an PostOrderIteratorImpl.
const ExpressionTree & tree_
The tree we are iterating over.
virtual bool operator==(const ExpressionTreeIteratorImpl &rhs) const
Equality operator.
virtual ~InOrderIteratorImpl(void)
Dtor.