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

ACE_Array_Iterator Class Template Reference

Implement an iterator over an ACE_Array. More...

#include <Array_Base.h>

Collaboration diagram for ACE_Array_Iterator:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Array_Iterator (ACE_Array_Base< T > &)
int next (T *&next_item)
 Pass back the <next_item> that hasn't been seen in the Array. Returns 0 when all items have been seen, else 1. More...

int advance (void)
 Move forward by one element in the Array. Returns 0 when all the items in the Array have been seen, else 1. More...

int done (void) const
 Returns 1 when all items have been seen, else 0. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Attributes

size_t current_
 Pointer to the current item in the iteration. More...

ACE_Array_Base< T > & array_
 Pointer to the Array we're iterating over. More...


Detailed Description

template<class T>
class ACE_Array_Iterator< T >

Implement an iterator over an ACE_Array.

This iterator is safe in the face of array element deletions. But it is NOT safe if the array is resized (via the ACE_Array assignment operator) during iteration. That would be very odd, and dangerous.

Definition at line 163 of file Array_Base.h.


Constructor & Destructor Documentation

template<class T>
ACE_INLINE ACE_Array_Iterator< T >::ACE_Array_Iterator ACE_Array_Base< T > &   
 

Definition at line 54 of file Array_Base.inl.

00055     : current_ (0),
00056       array_ (a)
00057 {
00058   // ACE_TRACE ("ACE_Array_Iterator<T>::ACE_Array_Iterator");
00059 }


Member Function Documentation

template<class T>
ACE_INLINE int ACE_Array_Iterator< T >::advance void   
 

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

Definition at line 62 of file Array_Base.inl.

References array_, and current_.

00063 {
00064   // ACE_TRACE ("ACE_Array_Iterator<T>::advance");
00065 
00066   if (this->current_ < array_.size ())
00067     {
00068       ++this->current_;
00069       return 1;
00070     }
00071   else
00072     {
00073       // Already finished iterating.
00074       return 0;
00075     }
00076 }

template<class T>
ACE_INLINE int ACE_Array_Iterator< T >::done void    const
 

Returns 1 when all items have been seen, else 0.

Definition at line 79 of file Array_Base.inl.

References ACE_TRACE, array_, and current_.

Referenced by next.

00080 {
00081   ACE_TRACE ("ACE_Array_Iterator<T>::done");
00082 
00083   return this->current_ >= array_.size ();
00084 }

template<class T>
ACE_INLINE void ACE_Array_Iterator< T >::dump void    const
 

Dump the state of an object.

Definition at line 48 of file Array_Base.inl.

00049 {
00050   // ACE_TRACE ("ACE_Array_Iterator<T>::dump");
00051 }

template<class T>
int ACE_Array_Iterator< T >::next T *&    next_item
 

Pass back the <next_item> that hasn't been seen in the Array. Returns 0 when all items have been seen, else 1.

Definition at line 188 of file Array_Base.cpp.

References array_, current_, and done.

00189 {
00190   // ACE_TRACE ("ACE_Array_Iterator<T>::next");
00191 
00192   if (this->done ())
00193     {
00194       item = 0;
00195       return 0;
00196     }
00197   else
00198     {
00199       item = &array_[current_];
00200       return 1;
00201     }
00202 }


Member Data Documentation

template<class T>
ACE_Array_Iterator::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 186 of file Array_Base.h.

template<class T>
ACE_Array_Base<T>& ACE_Array_Iterator::array_ [private]
 

Pointer to the Array we're iterating over.

Definition at line 193 of file Array_Base.h.

Referenced by advance, done, and next.

template<class T>
size_t ACE_Array_Iterator::current_ [private]
 

Pointer to the current item in the iteration.

Definition at line 190 of file Array_Base.h.

Referenced by advance, done, and next.


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