Public Member Functions | Public Attributes

ACE_Double_Linked_List_Reverse_Iterator< T > Class Template Reference

Implements a reverse iterator for a double linked list ADT. More...

#include <Containers_T.h>

Inheritance diagram for ACE_Double_Linked_List_Reverse_Iterator< T >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Double_Linked_List_Reverse_Iterator< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List< T > &)
void reset (ACE_Double_Linked_List< T > &)
int first (void)
int advance (void)
T * advance_and_remove (bool dont_remove)
ACE_Double_Linked_List_Reverse_Iterator
< T > & 
operator++ (void)
 Prefix advance.
ACE_Double_Linked_List_Reverse_Iterator
< T > 
operator++ (int)
 Postfix advance.
ACE_Double_Linked_List_Reverse_Iterator
< T > & 
operator-- (void)
 Prefix reverse.
ACE_Double_Linked_List_Reverse_Iterator
< T > 
operator-- (int)
 Postfix reverse.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Detailed Description

template<class T>
class ACE_Double_Linked_List_Reverse_Iterator< T >

Implements a reverse iterator for a double linked list ADT.

Iterate backwards over the double-linked list. This class provide an interface that let users access the internal element addresses directly, which seems to break the encapsulation. Notice {class T} must declare ACE_Double_Linked_List<T>, ACE_Double_Linked_List_Iterator_Base <T> and ACE_Double_Linked_List_Iterator as friend classes and class T should also have data members T* next_ and T* prev_.

Definition at line 723 of file Containers_T.h.


Constructor & Destructor Documentation

Definition at line 559 of file Containers_T.cpp.

  : ACE_Double_Linked_List_Iterator_Base <T> (dll)
{
  this->current_ = static_cast<T*> (dll.head_->prev_);
  // Advance current_ out of the null area and onto the last item in
  // the list
}


Member Function Documentation

template<class T >
int ACE_Double_Linked_List_Reverse_Iterator< T >::advance ( void   ) 

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

Reimplemented in ACE_DLList_Reverse_Iterator< T >.

Definition at line 583 of file Containers_T.cpp.

{
  return this->do_retreat () ? 1 : 0;
}

template<class T >
T * ACE_Double_Linked_List_Reverse_Iterator< T >::advance_and_remove ( bool  dont_remove  ) 

Advance the iterator while removing the original item from the list. Return a pointer points to the original (removed) item. If dont_remove equals false, this function behaves like {advance} but return 0 (NULL) instead.

Definition at line 589 of file Containers_T.cpp.

{
  T* item = 0;
  if (dont_remove)
    {
      this->do_retreat ();
    }
  else
    {
      item = this->next ();
      this->do_retreat ();
      // It seems dangerous to remove nodes in an iterator, but so it goes...
      ACE_Double_Linked_List<T> *dllist =
        const_cast<ACE_Double_Linked_List<T> *> (this->dllist_);
      dllist->remove (item);
    }
  return item;
}

template<class T >
void ACE_Double_Linked_List_Reverse_Iterator< T >::dump ( void   )  const

Dump the state of an object.

Reimplemented in ACE_DLList_Reverse_Iterator< T >.

Definition at line 609 of file Containers_T.cpp.

{
#if defined (ACE_HAS_DUMP)
  this->dump_i ();
#endif /* ACE_HAS_DUMP */
}

template<class T >
int ACE_Double_Linked_List_Reverse_Iterator< T >::first ( void   ) 

Move to the first element in the list. Returns 0 if the list is empty, else 1.

Definition at line 577 of file Containers_T.cpp.

{
  return this->go_tail ();
}

template<class T >
ACE_Double_Linked_List_Reverse_Iterator< T > & ACE_Double_Linked_List_Reverse_Iterator< T >::operator++ ( void   ) 

Prefix advance.

Definition at line 620 of file Containers_T.cpp.

{
  this->do_retreat ();
  return *this;
}

template<class T >
ACE_Double_Linked_List_Reverse_Iterator< T > ACE_Double_Linked_List_Reverse_Iterator< T >::operator++ ( int   ) 

Postfix advance.

Definition at line 631 of file Containers_T.cpp.

{
  ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
  this->do_retreat ();
  return retv;
}

template<class T >
ACE_Double_Linked_List_Reverse_Iterator< T > ACE_Double_Linked_List_Reverse_Iterator< T >::operator-- ( int   ) 

Postfix reverse.

Definition at line 654 of file Containers_T.cpp.

{
  ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
  this->do_advance ();
  return retv;
}

template<class T >
ACE_Double_Linked_List_Reverse_Iterator< T > & ACE_Double_Linked_List_Reverse_Iterator< T >::operator-- ( void   ) 

Prefix reverse.

Definition at line 643 of file Containers_T.cpp.

{
  this->do_advance ();
  return *this;
}

template<class T>
void ACE_Double_Linked_List_Reverse_Iterator< T >::reset ( ACE_Double_Linked_List< T > &  dll  ) 

Retasks the iterator to iterate over a new Double_Linked_List. This allows clients to reuse an iterator without incurring the constructor overhead. If you do use this, be aware that if there are more than one reference to this iterator, the other "clients" may be very bothered when their iterator changes. @ Here be dragons. Comments?

Reimplemented from ACE_Double_Linked_List_Iterator_Base< T >.

Definition at line 568 of file Containers_T.cpp.

{
  this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
  this->current_ = static_cast<T*> (dll.head_->prev_);
  // Advance current_ out of the null area and onto the last item in
  // the list
}


Member Data Documentation

Declare the dynamic allocation hooks.

Reimplemented from ACE_Double_Linked_List_Iterator_Base< T >.

Definition at line 774 of file Containers_T.h.


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