tree< T, tree_node_allocator >::pre_order_iterator Class Reference

#include <tree.h>

Inheritance diagram for tree< T, tree_node_allocator >::pre_order_iterator:

Inheritance graph
[legend]
Collaboration diagram for tree< T, tree_node_allocator >::pre_order_iterator:

Collaboration graph
[legend]

Detailed Description

template<class T, class tree_node_allocator = std::allocator<tree_node_<T> >>
class tree< T, tree_node_allocator >::pre_order_iterator

Depth-first iterator, first accessing the node, then its children.

Definition at line 161 of file tree.h.


Public Member Functions

 pre_order_iterator ()
 pre_order_iterator (tree_node *)
 pre_order_iterator (const iterator_base &)
 pre_order_iterator (const sibling_iterator &)
bool operator== (const pre_order_iterator &) const
bool operator!= (const pre_order_iterator &) const
pre_order_iteratoroperator++ ()
pre_order_iteratoroperator-- ()
pre_order_iterator operator++ (int)
pre_order_iterator operator-- (int)
pre_order_iteratoroperator+= (unsigned int)
pre_order_iteratoroperator-= (unsigned int)

Constructor & Destructor Documentation

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator (  )  [inline]

Definition at line 1922 of file tree.h.

01923    : iterator_base(0)
01924    {
01925    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator ( tree_node tn  )  [inline]

Definition at line 1928 of file tree.h.

01929    : iterator_base(tn)
01930    {
01931    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator ( const iterator_base other  )  [inline]

Definition at line 1934 of file tree.h.

01935    : iterator_base(other.node)
01936    {
01937    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator ( const sibling_iterator other  )  [inline]

Definition at line 1940 of file tree.h.

References tree< T, tree_node_allocator >::iterator_base::node, tree< T, tree_node_allocator >::sibling_iterator::parent_, tree< T, tree_node_allocator >::sibling_iterator::range_last(), and tree< T, tree_node_allocator >::iterator_base::skip_children().

01941    : iterator_base(other.node)
01942    {
01943    if(this->node==0) {
01944       if(other.range_last()!=0)
01945          this->node=other.range_last();
01946       else 
01947          this->node=other.parent_;
01948       this->skip_children();
01949       ++(*this);
01950       }
01951    }

Here is the call graph for this function:


Member Function Documentation

template<class T, class tree_node_allocator>
bool tree< T, tree_node_allocator >::pre_order_iterator::operator== ( const pre_order_iterator other  )  const [inline]

Definition at line 1844 of file tree.h.

References tree< T, tree_node_allocator >::iterator_base::node.

01845    {
01846    if(other.node==this->node) return true;
01847    else return false;
01848    }

template<class T, class tree_node_allocator>
bool tree< T, tree_node_allocator >::pre_order_iterator::operator!= ( const pre_order_iterator other  )  const [inline]

Definition at line 1837 of file tree.h.

References tree< T, tree_node_allocator >::iterator_base::node.

01838    {
01839    if(other.node!=this->node) return true;
01840    else return false;
01841    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator & tree< T, tree_node_allocator >::pre_order_iterator::operator++ (  )  [inline]

Definition at line 1954 of file tree.h.

References tree_node_< T >::first_child, tree_node_< T >::next_sibling, tree< T, tree_node_allocator >::iterator_base::node, tree_node_< T >::parent, and tree< T, tree_node_allocator >::iterator_base::skip_current_children_.

01955    {
01956    assert(this->node!=0);
01957    if(!this->skip_current_children_ && this->node->first_child != 0) {
01958       this->node=this->node->first_child;
01959       }
01960    else {
01961       this->skip_current_children_=false;
01962       while(this->node->next_sibling==0) {
01963          this->node=this->node->parent;
01964          if(this->node==0)
01965             return *this;
01966          }
01967       this->node=this->node->next_sibling;
01968       }
01969    return *this;
01970    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator & tree< T, tree_node_allocator >::pre_order_iterator::operator-- (  )  [inline]

Definition at line 1973 of file tree.h.

References tree_node_< T >::last_child, tree< T, tree_node_allocator >::iterator_base::node, tree_node_< T >::parent, and tree_node_< T >::prev_sibling.

01974    {
01975    assert(this->node!=0);
01976    if(this->node->prev_sibling) {
01977       this->node=this->node->prev_sibling;
01978       while(this->node->last_child)
01979          this->node=this->node->last_child;
01980       }
01981    else {
01982       this->node=this->node->parent;
01983       if(this->node==0)
01984          return *this;
01985       }
01986    return *this;
01987 }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator tree< T, tree_node_allocator >::pre_order_iterator::operator++ ( int  n  )  [inline]

Definition at line 1990 of file tree.h.

01991    {
01992    pre_order_iterator copy = *this;
01993    ++(*this);
01994    return copy;
01995    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator tree< T, tree_node_allocator >::pre_order_iterator::operator-- ( int  n  )  [inline]

Definition at line 1998 of file tree.h.

01999 {
02000   pre_order_iterator copy = *this;
02001   --(*this);
02002   return copy;
02003 }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator & tree< T, tree_node_allocator >::pre_order_iterator::operator+= ( unsigned int  num  )  [inline]

Definition at line 2006 of file tree.h.

02007    {
02008    while(num>0) {
02009       ++(*this);
02010       --num;
02011       }
02012    return (*this);
02013    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::pre_order_iterator & tree< T, tree_node_allocator >::pre_order_iterator::operator-= ( unsigned int  num  )  [inline]

Definition at line 2016 of file tree.h.

02017    {
02018    while(num>0) {
02019       --(*this);
02020       --num;
02021       }
02022    return (*this);
02023    }


The documentation for this class was generated from the following file:
Generated on Wed Feb 27 20:32:44 2008 for php.ast.svn.src. by  doxygen 1.5.3