tree< T, tree_node_allocator >::post_order_iterator Class Reference

#include <tree.h>

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

Inheritance graph
[legend]
Collaboration diagram for tree< T, tree_node_allocator >::post_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 >::post_order_iterator

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

Definition at line 179 of file tree.h.


Public Member Functions

 post_order_iterator ()
 post_order_iterator (tree_node *)
 post_order_iterator (const iterator_base &)
 post_order_iterator (const sibling_iterator &)
bool operator== (const post_order_iterator &) const
bool operator!= (const post_order_iterator &) const
post_order_iteratoroperator++ ()
post_order_iteratoroperator-- ()
post_order_iterator operator++ (int)
post_order_iterator operator-- (int)
post_order_iteratoroperator+= (unsigned int)
post_order_iteratoroperator-= (unsigned int)
void descend_all ()
 Set iterator to the first child as deep as possible down the tree.

Constructor & Destructor Documentation

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

Definition at line 2030 of file tree.h.

02031    : iterator_base(0)
02032    {
02033    }

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

Definition at line 2036 of file tree.h.

02037    : iterator_base(tn)
02038    {
02039    }

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

Definition at line 2042 of file tree.h.

02043    : iterator_base(other.node)
02044    {
02045    }

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

Definition at line 2048 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().

02049    : iterator_base(other.node)
02050    {
02051    if(this->node==0) {
02052       if(other.range_last()!=0)
02053          this->node=other.range_last();
02054       else 
02055          this->node=other.parent_;
02056       this->skip_children();
02057       ++(*this);
02058       }
02059    }

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 1830 of file tree.h.

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

01831    {
01832    if(other.node==this->node) return true;
01833    else return false;
01834    }

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

Definition at line 1823 of file tree.h.

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

01824    {
01825    if(other.node!=this->node) return true;
01826    else return false;
01827    }

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

Definition at line 2062 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_.

02063    {
02064    assert(this->node!=0);
02065    if(this->node->next_sibling==0) {
02066       this->node=this->node->parent;
02067       this->skip_current_children_=false;
02068       }
02069    else {
02070       this->node=this->node->next_sibling;
02071       if(this->skip_current_children_) {
02072          this->skip_current_children_=false;
02073          }
02074       else {
02075          while(this->node->first_child)
02076             this->node=this->node->first_child;
02077          }
02078       }
02079    return *this;
02080    }

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

Definition at line 2083 of file tree.h.

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

02084    {
02085    assert(this->node!=0);
02086    if(this->skip_current_children_ || this->node->last_child==0) {
02087       this->skip_current_children_=false;
02088       while(this->node->prev_sibling==0)
02089          this->node=this->node->parent;
02090       this->node=this->node->prev_sibling;
02091       }
02092    else {
02093       this->node=this->node->last_child;
02094       }
02095    return *this;
02096    }

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

Definition at line 2099 of file tree.h.

02100    {
02101    post_order_iterator copy = *this;
02102    ++(*this);
02103    return copy;
02104    }

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

Definition at line 2107 of file tree.h.

02108    {
02109    post_order_iterator copy = *this;
02110    --(*this);
02111    return copy;
02112    }

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

Definition at line 2116 of file tree.h.

02117    {
02118    while(num>0) {
02119       ++(*this);
02120       --num;
02121       }
02122    return (*this);
02123    }

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

Definition at line 2126 of file tree.h.

02127    {
02128    while(num>0) {
02129       --(*this);
02130       --num;
02131       }
02132    return (*this);
02133    }

template<class T, class tree_node_allocator>
void tree< T, tree_node_allocator >::post_order_iterator::descend_all (  )  [inline]

Set iterator to the first child as deep as possible down the tree.

Definition at line 2136 of file tree.h.

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

02137    {
02138    assert(this->node!=0);
02139    while(this->node->first_child)
02140       this->node=this->node->first_child;
02141    }


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