ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > 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< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

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.

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

ACE_RB_Tree_Node< EXT_ID,
INT_ID > & 
operator * (void) const
ACE_RB_Tree_Node< EXT_ID,
INT_ID > * 
operator-> (void) const
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.

bool 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.

bool 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.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

 ACE_RB_Tree_Iterator_Base (void)
 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.

 ~ACE_RB_Tree_Iterator_Base (void)
 Destructor.

int forward_i (void)
int reverse_i (void)
void dump_i (void) const
 Dump the state of an object.


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.

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


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 592 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 733 of file RB_Tree.inl.

References ACE_TRACE.

00734   : tree_ (0), node_ (0)
00735 {
00736   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (void)");
00737 }

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 1056 of file RB_Tree.cpp.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_.

01057   : tree_ (&tree), node_ (0)
01058 {
01059   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator_Base (ACE_RB_Tree, int)");
01060 
01061   // Position the iterator at the first (or last) node in the tree.
01062   if (set_first)
01063     node_ = tree_->RB_tree_minimum (tree_->root_);
01064   else
01065     node_ = tree_->RB_tree_maximum (tree_->root_);
01066 }

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 1069 of file RB_Tree.cpp.

References ACE_TRACE.

01070   : tree_ (&tree), node_ (0)
01071 {
01072   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)");
01073   node_ = entry;
01074 }

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 1077 of file RB_Tree.cpp.

References ACE_TRACE, and ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::find_i().

01078    : tree_ (&tree), node_ (0)
01079 {
01080   ACE_TRACE("ACE_RB_Tree_Iterator_Base (ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> &tree, const EXT_ID& key)");
01081   ACE_RB_Tree_Node<EXT_ID, INT_ID>* entry = 0;
01082   tree.find_i(key, entry);
01083   node_ = entry;
01084 }

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 1089 of file RB_Tree.cpp.

References ACE_TRACE.

01090   : tree_ (iter.tree_),
01091     node_ (iter.node_)
01092 {
01093   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)");
01094 }

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 1112 of file RB_Tree.cpp.

References ACE_TRACE.

01113 {
01114   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator_Base");
01115 }


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 743 of file RB_Tree.inl.

References ACE_TRACE.

00744 {
00745   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::done");
00746 
00747   return node_ ? 0 : 1;
00748 }

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 >::dump_i void   )  const [protected]
 

Dump the state of an object.

Definition at line 1121 of file RB_Tree.cpp.

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

Referenced by ACE_RB_Tree_Reverse_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::dump(), and ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::dump().

01122 {
01123   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump_i");
01124 
01125   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01126   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\nnode_ = %x\n"), this->node_));
01127   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01128 }

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 814 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_.

Referenced by ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::advance(), ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator++(), and ACE_RB_Tree_Reverse_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator--().

00815 {
00816   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::forward_i");
00817 
00818   if (node_)
00819     {
00820       node_ = tree_->RB_tree_successor (node_);
00821     }
00822 
00823   return node_ ? 1 : 0;
00824 }

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 756 of file RB_Tree.inl.

References ACE_TRACE.

00757 {
00758   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator*");
00759   return *(this->node_);
00760 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE bool 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 802 of file RB_Tree.inl.

References ACE_TRACE.

00803 {
00804   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator!=");
00805   return (this->node_ == rbt.node_) ? false : true;
00806 }

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 pointer to the node underneath the iterator.

Definition at line 768 of file RB_Tree.inl.

References ACE_TRACE.

00769 {
00770   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator->");
00771   return this->node_;
00772 }

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 1099 of file RB_Tree.cpp.

References ACE_TRACE, ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::node_, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_.

01100 {
01101   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator=");
01102   if (this != &iter)
01103     {
01104       tree_ = iter.tree_;
01105       node_ = iter.node_;
01106     }
01107 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE bool 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 790 of file RB_Tree.inl.

References ACE_TRACE.

00791 {
00792   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::operator==");
00793   return (this->node_ == rbt.node_) ? true : false;
00794 }

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 832 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_.

Referenced by ACE_RB_Tree_Reverse_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::advance(), ACE_RB_Tree_Reverse_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator++(), and ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator--().

00833 {
00834   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::reverse_i");
00835 
00836   if (node_)
00837     {
00838       node_ = tree_->RB_tree_predecessor (node_);
00839     }
00840 
00841   return node_ ? 1 : 0;
00842 }

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 778 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_.

00779 {
00780   ACE_TRACE ("ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::tree");
00781   return *tree_;
00782 }


Member Data Documentation

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_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented in ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >, and ACE_RB_Tree_Reverse_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >.

Definition at line 623 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< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::node_ [protected]
 

Pointer to the node currently under the iterator.

Definition at line 681 of file RB_Tree.h.

Referenced by ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator=().

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< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree_ [protected]
 

Reference to the ACE_RB_Tree over which we're iterating.

Definition at line 678 of file RB_Tree.h.

Referenced by ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator_Base(), ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::forward_i(), ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator=(), ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::reverse_i(), and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::tree().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:27:34 2006 for ACE by doxygen 1.3.6