Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

NodeIterator Class Template Reference
[NodeIterator]

This iterator iterates in preorder over all nodes that belong to a given node (have the same root). More...

#include <nodeiterator.h>

Inheritance diagram for NodeIterator:

Inheritance graph
[legend]
Collaboration diagram for NodeIterator:

Collaboration graph
[legend]
List of all members.

Public Types

typedef NodeTraits< _Node
>::_NonConstNode 
_NonConstNode
typedef NodeIterator< _Node > iterator
typedef NodeIterator< const
_Node > 
const_iterator
typedef NodeIterator< _Node,
_Ref, _Ptr > 
_Self
typedef std::forward_iterator_tag iterator_category
typedef _Node value_type
typedef _Ptr pointer
typedef _Ref reference
typedef size_t size_type
typedef ptrdiff_t difference_type

Public Methods

 NodeIterator ()
 The default constructor makes a 'past the end NodeIterator'.

 NodeIterator (_Node *start)
 Construct a NodeIterator beginning at the given Node.

virtual _Selfconstruct () const
virtual _Selfclone (_Node *start=0) const
 Copy constructor.

virtual ~NodeIterator ()
virtual reference operator * () const
 Dereference operator.

virtual pointer operator-> () const
 Dereference operator.

virtual pointer operator() () const
 use like this:
 

virtual bool operator== (const _Self &rhs)
 Equality operator.

virtual bool operator!= (const _Self &rhs)
 Inequality operator.

virtual _Self operator++ (int)
 Postfix proceed operator.

virtual _Selfoperator++ ()
 Prefix proceed operator.

const bool & isEnd () const
virtual void setStart (_Node *start)
 Set start node for next iteration.


Protected Methods

void setEnd (bool end=true)
void addToNodeList (const std::list< _NonConstNode * > *values)
 Add Nodes from a NodeList to the list, if they aren't already visited.


Protected Attributes

_Node * m_currentNode
_Node * m_root
std::list< _Node * > m_nodeList
std::set< _Node * > m_seenNodeSet

Detailed Description

template<class _Node, class _Ref = _Node&, class _Ptr = _Node*>
class treecomp::NodeIterator< _Node, _Ref, _Ptr >

This iterator iterates in preorder over all nodes that belong to a given node (have the same root).

That means, it visits first a root node and then its children. It doesn't iterate over subtree nodes. The default constructor makes a 'past the end NodeIterator'. It is the base class of all iterators and inherits from forward_iterator. Template-parameter _TContent: see Node class.

Definition at line 62 of file nodeiterator.h.


Member Typedef Documentation

typedef NodeTraits<_Node>::_NonConstNode _NonConstNode
 

Reimplemented in PostOrderNodeIterator.

Definition at line 65 of file nodeiterator.h.

typedef NodeIterator<_Node, _Ref,_Ptr> _Self
 

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 69 of file nodeiterator.h.

Referenced by NodeIterator::clone(), and NodeIterator< Node< value_type > >::construct().

typedef NodeIterator<const _Node > const_iterator
 

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 68 of file nodeiterator.h.

typedef ptrdiff_t difference_type
 

Definition at line 77 of file nodeiterator.h.

typedef NodeIterator<_Node> iterator
 

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 67 of file nodeiterator.h.

typedef std::forward_iterator_tag iterator_category
 

Definition at line 72 of file nodeiterator.h.

typedef _Ptr pointer
 

Definition at line 74 of file nodeiterator.h.

Referenced by NodeIterator< Node< value_type > >::operator()(), and NodeIterator< Node< value_type > >::operator->().

typedef _Ref reference
 

Definition at line 75 of file nodeiterator.h.

Referenced by NodeIterator< Node< value_type > >::operator *().

typedef size_t size_type
 

Definition at line 76 of file nodeiterator.h.

typedef _Node value_type
 

Definition at line 73 of file nodeiterator.h.


Constructor & Destructor Documentation

NodeIterator   [inline]
 

The default constructor makes a 'past the end NodeIterator'.

Definition at line 80 of file nodeiterator.h.

NodeIterator _Node *    start [inline]
 

Construct a NodeIterator beginning at the given Node.

Parameters:
start  The Node to start at

Definition at line 86 of file nodeiterator.h.

virtual ~NodeIterator   [inline, virtual]
 

Definition at line 89 of file nodeiterator.h.


Member Function Documentation

void addToNodeList const std::list< _NonConstNode * > *    values [protected]
 

Add Nodes from a NodeList to the list, if they aren't already visited.

Parameters:
values  NodeList to add to the list

Definition at line 369 of file nodeiterator.h.

References NodeIterator::m_nodeList, and NodeIterator::m_seenNodeSet.

Referenced by AllNodeIterator::operator++(), LeaveIterator::operator++(), VariableNodeIterator::operator++(), and NodeIterator::operator++().

NodeIterator< _Node, _Ref, _Ptr >::_Self * clone _Node *    start = 0 const [virtual]
 

Copy constructor.

Parameters:
start  Node to start with (if not given make identical copy)

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 275 of file nodeiterator.h.

References NodeIterator::_Self.

virtual _Self* construct   const [inline, virtual]
 

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 87 of file nodeiterator.h.

const bool& isEnd   const [inline]
 

Definition at line 101 of file nodeiterator.h.

Referenced by AllNodeIterator::operator!=(), LeaveIterator::operator!=(), VariableNodeIterator::operator!=(), PostOrderNodeIterator::operator!=(), NodeIterator::operator!=(), AllNodeIterator::operator==(), LeaveIterator::operator==(), VariableNodeIterator::operator==(), PostOrderNodeIterator::operator==(), and NodeIterator::operator==().

virtual reference operator *   const [inline, virtual]
 

Dereference operator.

Definition at line 92 of file nodeiterator.h.

bool operator!= const _Self   rhs [virtual]
 

Inequality operator.

Warning:
Compares only 'past the end'

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 319 of file nodeiterator.h.

References NodeIterator::isEnd().

virtual pointer operator()   const [inline, virtual]
 

use like this:

Definition at line 96 of file nodeiterator.h.

NodeIterator< _Node, _Ref, _Ptr >::_Self & operator++   [virtual]
 

Prefix proceed operator.

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 329 of file nodeiterator.h.

References NodeIterator::addToNodeList(), NodeIterator::m_currentNode, NodeIterator::m_nodeList, NodeIterator::m_root, and NodeIterator::setEnd().

Referenced by NodeIterator::operator++().

NodeIterator< _Node, _Ref, _Ptr >::_Self operator++ int    n [virtual]
 

Postfix proceed operator.

Definition at line 352 of file nodeiterator.h.

References NodeIterator::operator++().

virtual pointer operator->   const [inline, virtual]
 

Dereference operator.

Definition at line 94 of file nodeiterator.h.

bool operator== const _Self   rhs [virtual]
 

Equality operator.

Warning:
Compares only 'past the end'

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, LeaveIterator, and AllNodeIterator.

Definition at line 308 of file nodeiterator.h.

References NodeIterator::isEnd().

void setEnd bool    end = true [inline, protected]
 

Definition at line 111 of file nodeiterator.h.

Referenced by AllNodeIterator::operator++(), LeaveIterator::operator++(), VariableNodeIterator::operator++(), PostOrderNodeIterator::operator++(), and NodeIterator::operator++().

void setStart _Node *    start [virtual]
 

Set start node for next iteration.

Parameters:
start  The Node to start at

Reimplemented in PostOrderNodeIterator, VariableNodeIterator, and LeaveIterator.

Definition at line 289 of file nodeiterator.h.

References NodeIterator::m_currentNode, NodeIterator::m_nodeList, NodeIterator::m_root, and NodeIterator::m_seenNodeSet.

Referenced by AllNodeIterator::AllNodeIterator(), and NodeIterator< Node< value_type > >::NodeIterator().


Member Data Documentation

_Node* m_currentNode [protected]
 

Definition at line 106 of file nodeiterator.h.

Referenced by NodeIterator< Node< value_type > >::NodeIterator(), NodeIterator< Node< value_type > >::operator *(), NodeIterator< Node< value_type > >::operator()(), AllNodeIterator::operator++(), LeaveIterator::operator++(), VariableNodeIterator::operator++(), PostOrderNodeIterator::operator++(), NodeIterator::operator++(), NodeIterator< Node< value_type > >::operator->(), PostOrderNodeIterator::setStart(), and NodeIterator::setStart().

std::list<_Node*> m_nodeList [protected]
 

Definition at line 108 of file nodeiterator.h.

Referenced by NodeIterator::addToNodeList(), AllNodeIterator::operator++(), LeaveIterator::operator++(), VariableNodeIterator::operator++(), NodeIterator::operator++(), and NodeIterator::setStart().

_Node* m_root [protected]
 

Definition at line 107 of file nodeiterator.h.

Referenced by NodeIterator< Node< value_type > >::NodeIterator(), VariableNodeIterator::operator++(), PostOrderNodeIterator::operator++(), NodeIterator::operator++(), and NodeIterator::setStart().

std::set<_Node*> m_seenNodeSet [protected]
 

Definition at line 109 of file nodeiterator.h.

Referenced by NodeIterator::addToNodeList(), and NodeIterator::setStart().


The documentation for this class was generated from the following file:
Generated on Mon Jan 6 12:02:22 2003 for TreeComp by doxygen1.2.17