tree< T, tree_node_allocator >::sibling_iterator Class Reference

#include <tree.h>

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

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

Collaboration graph
[legend]

Detailed Description

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

Iterator which traverses only the nodes which are siblings of each other.

Definition at line 245 of file tree.h.


Public Member Functions

 sibling_iterator ()
 sibling_iterator (tree_node *)
 sibling_iterator (const sibling_iterator &)
 sibling_iterator (const iterator_base &)
bool operator== (const sibling_iterator &) const
bool operator!= (const sibling_iterator &) const
sibling_iteratoroperator++ ()
sibling_iteratoroperator-- ()
sibling_iterator operator++ (int)
sibling_iterator operator-- (int)
sibling_iteratoroperator+= (unsigned int)
sibling_iteratoroperator-= (unsigned int)
tree_noderange_first () const
tree_noderange_last () const

Data Fields

tree_nodeparent_

Private Member Functions

void set_parent_ ()

Constructor & Destructor Documentation

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

Definition at line 2415 of file tree.h.

References tree< T, tree_node_allocator >::sibling_iterator::set_parent_().

02416    : iterator_base()
02417    {
02418    set_parent_();
02419    }

Here is the call graph for this function:

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

Definition at line 2422 of file tree.h.

References tree< T, tree_node_allocator >::sibling_iterator::set_parent_().

02423    : iterator_base(tn)
02424    {
02425    set_parent_();
02426    }

Here is the call graph for this function:

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

Definition at line 2436 of file tree.h.

02437    : iterator_base(other), parent_(other.parent_)
02438    {
02439    }

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

Definition at line 2429 of file tree.h.

References tree< T, tree_node_allocator >::sibling_iterator::set_parent_().

02430    : iterator_base(other.node)
02431    {
02432    set_parent_();
02433    }

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 1858 of file tree.h.

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

01859    {
01860    if(other.node==this->node) return true;
01861    else return false;
01862    }

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

Definition at line 1851 of file tree.h.

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

01852    {
01853    if(other.node!=this->node) return true;
01854    else return false;
01855    }

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

Definition at line 2451 of file tree.h.

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

02452    {
02453    if(this->node)
02454       this->node=this->node->next_sibling;
02455    return *this;
02456    }

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

Definition at line 2459 of file tree.h.

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

02460    {
02461    if(this->node) this->node=this->node->prev_sibling;
02462    else {
02463       assert(parent_);
02464       this->node=parent_->last_child;
02465       }
02466    return *this;
02467 }

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

Definition at line 2470 of file tree.h.

02471    {
02472    sibling_iterator copy = *this;
02473    ++(*this);
02474    return copy;
02475    }

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

Definition at line 2478 of file tree.h.

02479    {
02480    sibling_iterator copy = *this;
02481    --(*this);
02482    return copy;
02483    }

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

Definition at line 2486 of file tree.h.

02487    {
02488    while(num>0) {
02489       ++(*this);
02490       --num;
02491       }
02492    return (*this);
02493    }

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

Definition at line 2496 of file tree.h.

02497    {
02498    while(num>0) {
02499       --(*this);
02500       --num;
02501       }
02502    return (*this);
02503    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::tree_node * tree< T, tree_node_allocator >::sibling_iterator::range_first (  )  const [inline]

Definition at line 2506 of file tree.h.

References tree_node_< T >::first_child, and tree< T, tree_node_allocator >::sibling_iterator::parent_.

02507    {
02508    tree_node *tmp=parent_->first_child;
02509    return tmp;
02510    }

template<class T, class tree_node_allocator>
tree< T, tree_node_allocator >::tree_node * tree< T, tree_node_allocator >::sibling_iterator::range_last (  )  const [inline]

Definition at line 2513 of file tree.h.

References tree_node_< T >::last_child, and tree< T, tree_node_allocator >::sibling_iterator::parent_.

Referenced by tree< T, tree_node_allocator >::insert(), tree< T, tree_node_allocator >::leaf_iterator::leaf_iterator(), tree< T, tree_node_allocator >::post_order_iterator::post_order_iterator(), and tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator().

02514    {
02515    return parent_->last_child;
02516    }

Here is the caller graph for this function:

template<class T, class tree_node_allocator>
void tree< T, tree_node_allocator >::sibling_iterator::set_parent_ (  )  [inline, private]

Definition at line 2442 of file tree.h.

References tree< T, tree_node_allocator >::iterator_base::node, tree_node_< T >::parent, and tree< T, tree_node_allocator >::sibling_iterator::parent_.

Referenced by tree< T, tree_node_allocator >::sibling_iterator::sibling_iterator().

02443    {
02444    parent_=0;
02445    if(this->node==0) return;
02446    if(this->node->parent!=0)
02447       parent_=this->node->parent;
02448    }

Here is the caller graph for this function:


Field Documentation

template<class T, class tree_node_allocator = std::allocator<tree_node_<T> >>
tree_node* tree< T, tree_node_allocator >::sibling_iterator::parent_

Definition at line 263 of file tree.h.

Referenced by tree< T, tree_node_allocator >::iterator_base::begin(), tree< T, tree_node_allocator >::iterator_base::end(), tree< T, tree_node_allocator >::end(), tree< T, tree_node_allocator >::insert(), tree< T, tree_node_allocator >::leaf_iterator::leaf_iterator(), tree< T, tree_node_allocator >::move_before(), tree< T, tree_node_allocator >::sibling_iterator::operator--(), tree< T, tree_node_allocator >::post_order_iterator::post_order_iterator(), tree< T, tree_node_allocator >::pre_order_iterator::pre_order_iterator(), tree< T, tree_node_allocator >::sibling_iterator::range_first(), tree< T, tree_node_allocator >::sibling_iterator::range_last(), and tree< T, tree_node_allocator >::sibling_iterator::set_parent_().


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