tree< T, tree_node_allocator >::breadth_first_queued_iterator Class Reference

#include <tree.h>

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

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

Collaboration graph
[legend]

Detailed Description

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

Breadth-first iterator, using a queue.

Definition at line 200 of file tree.h.


Public Member Functions

 breadth_first_queued_iterator ()
 breadth_first_queued_iterator (tree_node *)
 breadth_first_queued_iterator (const iterator_base &)
bool operator== (const breadth_first_queued_iterator &) const
bool operator!= (const breadth_first_queued_iterator &) const
breadth_first_queued_iteratoroperator++ ()
breadth_first_queued_iterator operator++ (int)
breadth_first_queued_iteratoroperator+= (unsigned int)

Private Attributes

std::queue< tree_node * > traversal_queue

Constructor & Destructor Documentation

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

Definition at line 2147 of file tree.h.

02148    : iterator_base()
02149    {
02150    }

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

Definition at line 2153 of file tree.h.

References tree< T, tree_node_allocator >::breadth_first_queued_iterator::traversal_queue.

02154    : iterator_base(tn)
02155    {
02156    traversal_queue.push(tn);
02157    }

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

Definition at line 2160 of file tree.h.

References tree< T, tree_node_allocator >::breadth_first_queued_iterator::traversal_queue.

02161    : iterator_base(other.node)
02162    {
02163    traversal_queue.push(other.node);
02164    }


Member Function Documentation

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

Definition at line 2174 of file tree.h.

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

02175    {
02176    if(other.node==this->node) return true;
02177    else return false;
02178    }

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

Definition at line 2167 of file tree.h.

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

02168    {
02169    if(other.node!=this->node) return true;
02170    else return false;
02171    }

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

Definition at line 2181 of file tree.h.

References tree< T, tree_node_allocator >::iterator_base::begin(), tree< T, tree_node_allocator >::iterator_base::end(), tree< T, tree_node_allocator >::iterator_base::node, and tree< T, tree_node_allocator >::breadth_first_queued_iterator::traversal_queue.

02182    {
02183    assert(this->node!=0);
02184 
02185    // Add child nodes and pop current node
02186    sibling_iterator sib=this->begin();
02187    while(sib!=this->end()) {
02188       traversal_queue.push(sib.node);
02189       ++sib;
02190       }
02191    traversal_queue.pop();
02192    if(traversal_queue.size()>0)
02193       this->node=traversal_queue.front();
02194    else 
02195       this->node=0;
02196    return (*this);
02197    }

Here is the call graph for this function:

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

Definition at line 2200 of file tree.h.

02201    {
02202    breadth_first_queued_iterator copy = *this;
02203    ++(*this);
02204    return copy;
02205    }

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

Definition at line 2208 of file tree.h.

02209    {
02210    while(num>0) {
02211       ++(*this);
02212       --num;
02213       }
02214    return (*this);
02215    }


Field Documentation

template<class T, class tree_node_allocator = std::allocator<tree_node_<T> >>
std::queue<tree_node *> tree< T, tree_node_allocator >::breadth_first_queued_iterator::traversal_queue [private]

Definition at line 213 of file tree.h.

Referenced by tree< T, tree_node_allocator >::breadth_first_queued_iterator::breadth_first_queued_iterator(), and tree< T, tree_node_allocator >::breadth_first_queued_iterator::operator++().


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