ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > Class Template Reference

Implements an iterator for a Red-Black Tree ADT. More...

#include <RB_Tree.h>

Inheritance diagram for ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >:

Inheritance graph
[legend]
Collaboration diagram for ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_RB_Tree_Iterator (void)
 ACE_RB_Tree_Iterator (const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &tree, int set_first=1)
 ACE_RB_Tree_Iterator (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 (const EXT_ID &key, ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &tree)
 ~ACE_RB_Tree_Iterator (void)
 Destructor.
int advance (void)
void dump (void) const
 Dump the state of an object.
ACE_RB_Tree_Iterator< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > & 
operator++ (void)
 Prefix advance.
ACE_RB_Tree_Iterator< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > 
operator++ (int)
 Postfix advance.
ACE_RB_Tree_Iterator< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > & 
operator-- (void)
 Prefix reverse.
ACE_RB_Tree_Iterator< EXT_ID,
INT_ID, COMPARE_KEYS, ACE_LOCK > 
operator-- (int)
 Postfix reverse.
int next (ACE_RB_Tree_Node< EXT_ID, INT_ID > *&next_entry) const
EXT_ID * key (void)
INT_ID * item (void)
int first (void)
int last (void)
int next (void)
int previous (void)
int is_done (void)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Detailed Description

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

Implements an iterator for a Red-Black Tree ADT.

Definition at line 691 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< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator ( void   ) 

Create the singular iterator. It is illegal to deference the iterator, no valid iterator is equal to a singular iterator, etc. etc.

Definition at line 852 of file RB_Tree.inl.

References ACE_TRACE.

00853   : ACE_RB_Tree_Iterator_Base<EXT_ID,INT_ID,COMPARE_KEYS,ACE_LOCK> ()
00854 {
00855   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (void)");
00856 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator ( const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &  tree,
int  set_first = 1 
)

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

References ACE_TRACE.

01141   : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree, set_first)
01142 {
01143   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
01144 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator ( const ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &  tree,
ACE_RB_Tree_Node< EXT_ID, INT_ID > *  entry 
)

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

Definition at line 1147 of file RB_Tree.cpp.

References ACE_TRACE.

01149   : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> (tree,entry)
01150 {
01151   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
01152 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::ACE_RB_Tree_Iterator ( const EXT_ID &  key,
ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > &  tree 
)

Constructor. Takes an ACE_RB_Tree over which to iterate, and a key; the key comes first in order to distinguish the case of EXT_ID == int.

Definition at line 1155 of file RB_Tree.cpp.

References ACE_TRACE.

01156   : ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>(key,tree)
01157 {
01158   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator");
01159 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::~ACE_RB_Tree_Iterator ( void   ) 

Destructor.

Definition at line 1164 of file RB_Tree.cpp.

References ACE_TRACE.

01165 {
01166   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator");
01167 }


Member Function Documentation

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::advance ( void   ) 

Move forward by one element in the tree. Returns 0 when all elements have been seen, else 1.

Definition at line 863 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::forward_i().

00864 {
00865   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::advance");
00866 
00867   return this->forward_i ();
00868 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE void ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::dump ( void   )  const

Dump the state of an object.

Definition at line 875 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::dump_i().

00876 {
00877 #if defined (ACE_HAS_DUMP)
00878   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump");
00879 
00880   this->dump_i ();
00881 #endif /* ACE_HAS_DUMP */
00882 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::first ( void   ) 

Deprecated:
Move to the first item in the iteration (and in the tree).

Definition at line 991 of file RB_Tree.inl.

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

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

00992 {
00993   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::first");
00994   this->node_ = this->tree_->RB_tree_minimum (this->tree_->root_);
00995   return this->node_ ? 1 : 0;
00996 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::is_done ( void   ) 

Deprecated:
: use the base class <done> method instead. Returns 0 if the iterator is positioned over a valid ACE_RB_Tree node, returns 1 if not.

Definition at line 1042 of file RB_Tree.inl.

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

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

01043 {
01044   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::is_done");
01045   return this->node_ ? 0 : 1;
01046 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE INT_ID * ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::item ( void   ) 

Deprecated:
Accessor for item of node under iterator (if any).

Definition at line 980 of file RB_Tree.inl.

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

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

00981 {
00982   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::item");
00983   return this->node_ ? (&(this->node_->item ())) : 0;
00984 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE EXT_ID * ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::key ( void   ) 

Deprecated:
Accessor for key of node under iterator (if any).

Definition at line 969 of file RB_Tree.inl.

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

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

00970 {
00971   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::key");
00972   return this->node_ ? (&(this->node_->key ())) : 0;
00973 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::last ( void   ) 

Deprecated:
Move to the last item in the iteration (and in the tree).

Definition at line 1003 of file RB_Tree.inl.

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

01004 {
01005   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::last");
01006   this->node_ = this->tree_->RB_tree_maximum (this->tree_->root_);
01007   return this->node_ ? 1 : 0;
01008 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::next ( void   ) 

Deprecated:
Move to the next item in the iteration (and in the tree).

Definition at line 1016 of file RB_Tree.inl.

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

01017 {
01018   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next");
01019   this->node_ = this->tree_->RB_tree_successor (this->node_);
01020   return this->node_ ? 1 : 0;
01021 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::next ( ACE_RB_Tree_Node< EXT_ID, INT_ID > *&  next_entry  )  const

Passes back the <entry> under the iterator. Returns 0 if the iteration has completed, otherwise 1. This method must be declared and defined in both the derived forward and reverse iterator classes rather than in the base iterator class because of a method signature resolution problem caused by the existence of the deprecated next (void) method in the derived forward iterator class. When that deprecated method is removed, this method should be removed from the derived classes and placed in the base class.

Definition at line 951 of file RB_Tree.inl.

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

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

00952 {
00953   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::next");
00954 
00955   if (this->node_)
00956     {
00957       next_entry = this->node_;
00958       return 1;
00959     }
00960 
00961   return 0;
00962 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator++ ( int   ) 

Postfix advance.

Definition at line 902 of file RB_Tree.inl.

References ACE_TRACE.

00903 {
00904   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator++ (int)");
00905 
00906   ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
00907   ++*this;
00908   return retv;
00909 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > & ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator++ ( void   ) 

Prefix advance.

Definition at line 889 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::forward_i().

00890 {
00891   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator++ (void)");
00892 
00893   this->forward_i ();
00894   return *this;
00895 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator-- ( int   ) 

Postfix reverse.

Definition at line 929 of file RB_Tree.inl.

References ACE_TRACE.

00930 {
00931   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator-- (int)");
00932 
00933   ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> retv (*this);
00934   --*this;
00935   return retv;
00936 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK > & ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::operator-- ( void   ) 

Prefix reverse.

Definition at line 916 of file RB_Tree.inl.

References ACE_TRACE, and ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::reverse_i().

00917 {
00918   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK> operator-- (void)");
00919 
00920   this->reverse_i ();
00921   return *this;
00922 }

template<class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
ACE_INLINE int ACE_RB_Tree_Iterator< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::previous ( void   ) 

Deprecated:
Move to the previous item in the iteration (and in the tree).

Definition at line 1029 of file RB_Tree.inl.

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

01030 {
01031   ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::previous");
01032   this->node_ = this->tree_->RB_tree_predecessor (this->node_);
01033   return this->node_ ? 1 : 0;
01034 }


Member Data Documentation

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

Declare the dynamic allocation hooks.

Reimplemented from ACE_RB_Tree_Iterator_Base< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >.

Definition at line 753 of file RB_Tree.h.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:28 2010 for ACE by  doxygen 1.4.7