Public Member Functions | Public Attributes | Private Attributes

ACE_Vector_Iterator< T, DEFAULT_SIZE > Class Template Reference

Implement an iterator over an ACE_Vector. More...

#include <Vector_T.h>

List of all members.

Public Member Functions

 ACE_Vector_Iterator (ACE_Vector< T, DEFAULT_SIZE > &)
int next (T *&next_item)
int advance (void)
int done (void) const
 Returns 1 when all items have been seen, else 0.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Attributes

size_t current_
 Pointer to the current item in the iteration.
ACE_Vector< T, DEFAULT_SIZE > & vector_
 Reference to the vector we're iterating over.

Detailed Description

template<class T, size_t DEFAULT_SIZE = ACE_VECTOR_DEFAULT_SIZE>
class ACE_Vector_Iterator< T, DEFAULT_SIZE >

Implement an iterator over an ACE_Vector.

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

Definition at line 267 of file Vector_T.h.


Constructor & Destructor Documentation

template<class T , size_t DEFAULT_SIZE>
ACE_Vector_Iterator< T, DEFAULT_SIZE >::ACE_Vector_Iterator ( ACE_Vector< T, DEFAULT_SIZE > &  v  ) 

Definition at line 76 of file Vector_T.inl.

    : current_ (0),
      vector_ (v)
{
  // ACE_TRACE ("ACE_Vector_Iterator<T>::ACE_Vector_Iterator");
}


Member Function Documentation

template<class T , size_t DEFAULT_SIZE>
int ACE_Vector_Iterator< T, DEFAULT_SIZE >::advance ( void   ) 

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

Definition at line 84 of file Vector_T.inl.

{
  // ACE_TRACE ("ACE_Vector_Iterator<T>::advance");

  if (this->current_ < vector_.size ())
    {
      ++this->current_;
      return 1;
    }
  else
    // Already finished iterating.
    return 0;
}

template<class T , size_t DEFAULT_SIZE>
int ACE_Vector_Iterator< T, DEFAULT_SIZE >::done ( void   )  const

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

Definition at line 99 of file Vector_T.inl.

{
  ACE_TRACE ("ACE_Vector_Iterator<T>::done");

  return this->current_ >= vector_.size ();
}

template<class T , size_t DEFAULT_SIZE>
void ACE_Vector_Iterator< T, DEFAULT_SIZE >::dump ( void   )  const

Dump the state of an object.

Definition at line 70 of file Vector_T.inl.

{
  // ACE_TRACE ("ACE_Vector_Iterator<T>::dump");
}

template<class T , size_t DEFAULT_SIZE>
int ACE_Vector_Iterator< T, DEFAULT_SIZE >::next ( T *&  next_item  ) 

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

Definition at line 136 of file Vector_T.cpp.

{
  // ACE_TRACE ("ACE_Vector_Iterator<T>::next");

  if (this->done ())
    {
      item = 0;
      return 0;
    }
  else
    {
      item = &vector_[current_];
      return 1;
    }
}


Member Data Documentation

template<class T , size_t DEFAULT_SIZE = ACE_VECTOR_DEFAULT_SIZE>
ACE_Vector_Iterator< T, DEFAULT_SIZE >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 290 of file Vector_T.h.

template<class T , size_t DEFAULT_SIZE = ACE_VECTOR_DEFAULT_SIZE>
size_t ACE_Vector_Iterator< T, DEFAULT_SIZE >::current_ [private]

Pointer to the current item in the iteration.

Definition at line 294 of file Vector_T.h.

template<class T , size_t DEFAULT_SIZE = ACE_VECTOR_DEFAULT_SIZE>
ACE_Vector<T, DEFAULT_SIZE>& ACE_Vector_Iterator< T, DEFAULT_SIZE >::vector_ [private]

Reference to the vector we're iterating over.

Definition at line 297 of file Vector_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines