Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_RB_Tree_Iterator_Base Class Template Reference

Implements a common base class for iterators for a Red-Black Tree ADT. More...

#include <RB_Tree.h>

Inheritance diagram for ACE_RB_Tree_Iterator_Base:

Inheritance graph
[legend]
Collaboration diagram for ACE_RB_Tree_Iterator_Base:

Collaboration graph
[legend]
List of all members.

Public Methods

void operator= (const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &iter)
 Assignment operator: copies both the tree reference and the position in the tree. More...

int done (void) const
 Returns 1 when the iteration has completed, otherwise 0. More...

ACE_RB_Tree_Node< EXT_ID,
INT_ID > & 
operator * (void) const
 STL-like iterator dereference operator: returns a reference to the node underneath the iterator. More...

const ACE_RB_Tree< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > & 
tree (void)
 Returns a const reference to the tree over which we're iterating. More...

int operator== (const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &) const
 Comparison operator: returns 1 if both iterators point to the same position, otherwise 0. More...

int operator!= (const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &) const
 Comparison operator: returns 1 if the iterators point to different positions, otherwise 0. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

 ACE_RB_Tree_Iterator_Base (void)
 Create the singular iterator. No valid iterator can be equal to it, it is illegal to dereference a singular iterator, etc. etc. More...

 ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &tree, int set_first)
 ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &tree, ACE_RB_Tree_Node< EXT_ID, INT_ID > *entry)
 ACE_RB_Tree_Iterator_Base (const EXT_ID &key, ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &tree)
 ACE_RB_Tree_Iterator_Base (const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &iter)
 Copy constructor. More...

 ~ACE_RB_Tree_Iterator_Base (void)
 Destructor. More...

int forward_i (void)
 Move forward by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1. More...

int reverse_i (void)
 Move back by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1. More...

void dump_i (void) const
 Dump the state of an object. More...


Protected Attributes

const ACE_RB_Tree< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > * 
tree_
 Reference to the ACE_RB_Tree over which we're iterating. More...

ACE_RB_Tree_Node< EXT_ID,
INT_ID > * 
node_
 Pointer to the node currently under the iterator. More...


Detailed Description

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
class ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >

Implements a common base class for iterators for a Red-Black Tree ADT.

Definition at line 557 of file RB_Tree.h.


Constructor & Destructor Documentation

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base void    [protected]
 

Create the singular iterator. No valid iterator can be equal to it, it is illegal to dereference a singular iterator, etc. etc.

Definition at line 720 of file RB_Tree.i.

References ACE_TRACE.

00721   : tree_ (0), node_ (0)
00722 {
00723   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (void)");
00724 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    tree,
int    set_first
[protected]
 

Constructor. Takes an ACE_RB_Tree over which to iterate, and an integer indicating (if non-zero) to position the iterator at the first element in the tree (if this integer is 0, the iterator is positioned at the last element in the tree).

Definition at line 996 of file RB_Tree.cpp.

References ACE_TRACE, node_, and tree_.

00997   : tree_ (&tree), node_ (0)
00998 {
00999   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (ACE_RB_Tree, int)");
01000 
01001   // Position the iterator at the first (or last) node in the tree.
01002   if (set_first)
01003     node_ = tree_->RB_tree_minimum (tree_->root_);
01004   else
01005     node_ = tree_->RB_tree_maximum (tree_->root_);
01006 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    tree,
ACE_RB_Tree_Node< EXT_ID, INT_ID > *    entry
[protected]
 

Constructor. Takes an ACE_RB_Tree over which to iterate, and a pointer to a node in the tree.

Definition at line 1009 of file RB_Tree.cpp.

References ACE_TRACE, and node_.

01010   : tree_ (&tree), node_ (0)
01011 {
01012   ACE_TRACE ("ACE_RB_Tree_Iterator_Base(const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry)");
01013   node_ = entry;
01014 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base const EXT_ID &    key,
ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    tree
[protected]
 

Constructor. Takes an ACE_RB_Tree over which to iterate, and a key. The key must come first to distinguish the case of EXT_ID == int.

Definition at line 1017 of file RB_Tree.cpp.

References ACE_TRACE, node_, and tree.

01018    : tree_ (&tree), node_ (0)
01019 {
01020   ACE_TRACE("ACE_RB_Tree_Iterator_Base (ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, const EXT_ID& key)");
01021   ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry;
01022   tree.find_i(key, entry);
01023   node_ = entry;
01024 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    iter [protected]
 

Copy constructor.

Definition at line 1029 of file RB_Tree.cpp.

References ACE_TRACE.

01030   : tree_ (iter.tree_),
01031     node_ (iter.node_)
01032 {
01033   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (ACE_RB_Tree_Iterator_Base)");
01034 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::~ACE_RB_Tree_Iterator_Base void    [protected]
 

Destructor.

Definition at line 1052 of file RB_Tree.cpp.

References ACE_TRACE.

01053 {
01054   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator_Base");
01055 }


Member Function Documentation

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::done void    const
 

Returns 1 when the iteration has completed, otherwise 0.

Definition at line 730 of file RB_Tree.i.

References ACE_TRACE, and node_.

00731 {
00732   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::done");
00733 
00734   return node_ ? 0 : 1;
00735 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE void ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::dump_i void    const [protected]
 

Dump the state of an object.

Definition at line 824 of file RB_Tree.i.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

Referenced by ACE_RB_Tree_Reverse_Iterator::dump, and ACE_RB_Tree_Iterator::dump.

00825 {
00826   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump_i");
00827 
00828   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00829   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\nnode_ = %x\n"), this->node_));
00830   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00831 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::forward_i void    [protected]
 

Move forward by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1.

Definition at line 789 of file RB_Tree.i.

References ACE_TRACE, node_, and tree_.

Referenced by ACE_RB_Tree_Iterator::advance, ACE_RB_Tree_Iterator::operator++, and ACE_RB_Tree_Reverse_Iterator::operator--.

00790 {
00791   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::forward_i");
00792 
00793   if (node_)
00794     {
00795       node_ = tree_->RB_tree_successor (node_);
00796     }
00797 
00798   return node_ ? 1 : 0;
00799 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Node< EXT_ID, INT_ID > & ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator * void    const
 

STL-like iterator dereference operator: returns a reference to the node underneath the iterator.

Definition at line 743 of file RB_Tree.i.

References ACE_TRACE, and node_.

00744 {
00745   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator*");
00746   return *(this->node_);
00747 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator!= const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    const
 

Comparison operator: returns 1 if the iterators point to different positions, otherwise 0.

Definition at line 777 of file RB_Tree.i.

References ACE_TRACE.

00778 {
00779   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator!=");
00780   return (this->node_ == rbt.node_) ? 0 : 1;
00781 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
void ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator= const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    iter
 

Assignment operator: copies both the tree reference and the position in the tree.

Definition at line 1039 of file RB_Tree.cpp.

References ACE_TRACE, node_, and tree_.

01040 {
01041   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator=");
01042   if (this != &iter)
01043     {
01044       tree_ = iter.tree_;
01045       node_ = iter.node_;
01046     }
01047 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator== const ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &    const
 

Comparison operator: returns 1 if both iterators point to the same position, otherwise 0.

Definition at line 765 of file RB_Tree.i.

References ACE_TRACE.

00766 {
00767   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator==");
00768   return (this->node_ == rbt.node_) ? 1 : 0;
00769 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::reverse_i void    [protected]
 

Move back by one element in the tree. Returns 0 when there are no more elements in the tree, otherwise 1.

Definition at line 807 of file RB_Tree.i.

References ACE_TRACE, node_, and tree_.

Referenced by ACE_RB_Tree_Reverse_Iterator::advance, ACE_RB_Tree_Reverse_Iterator::operator++, and ACE_RB_Tree_Iterator::operator--.

00808 {
00809   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::reverse_i");
00810 
00811   if (node_)
00812     {
00813       node_ = tree_->RB_tree_predecessor (node_);
00814     }
00815 
00816   return node_ ? 1 : 0;
00817 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > & ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree void   
 

Returns a const reference to the tree over which we're iterating.

Definition at line 753 of file RB_Tree.i.

References ACE_TRACE, and tree_.

Referenced by ACE_RB_Tree_Iterator_Base.

00754 {
00755   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::tree");
00756   return *tree_;
00757 }


Member Data Documentation

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator_Base::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_RB_Tree_Iterator.

Definition at line 584 of file RB_Tree.h.

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Node<EXT_ID, INT_ID>* ACE_RB_Tree_Iterator_Base::node_ [protected]
 

Pointer to the node currently under the iterator.

Definition at line 642 of file RB_Tree.h.

Referenced by ACE_RB_Tree_Iterator_Base, done, ACE_RB_Tree_Iterator::first, forward_i, ACE_RB_Tree_Iterator::is_done, ACE_RB_Tree_Iterator::item, ACE_RB_Tree_Iterator::key, ACE_RB_Tree_Iterator::last, ACE_RB_Tree_Reverse_Iterator::next, ACE_RB_Tree_Iterator::next, operator *, operator=, ACE_RB_Tree_Iterator::previous, and reverse_i.

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
const ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>* ACE_RB_Tree_Iterator_Base::tree_ [protected]
 

Reference to the ACE_RB_Tree over which we're iterating.

Definition at line 639 of file RB_Tree.h.

Referenced by ACE_RB_Tree_Iterator_Base, ACE_RB_Tree_Iterator::first, forward_i, ACE_RB_Tree_Iterator::last, ACE_RB_Tree_Iterator::next, operator=, ACE_RB_Tree_Iterator::previous, reverse_i, and tree.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:54:44 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002