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

ACE_Double_Linked_List_Reverse_Iterator 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:

Inheritance graph
[legend]
Collaboration diagram for ACE_Double_Linked_List_Reverse_Iterator:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List< T > &)
void reset (ACE_Double_Linked_List< T > &)
int first (void)
 Move to the first element in the list. Returns 0 if the list is empty, else 1. More...

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

T * advance_and_remove (int dont_remove)
ACE_Double_Linked_List_Reverse_Iterator<
T > & 
operator++ (void)
 Prefix advance. More...

ACE_Double_Linked_List_Reverse_Iterator<
T > 
operator++ (int)
 Postfix advance. More...

ACE_Double_Linked_List_Reverse_Iterator<
T > & 
operator-- (void)
 Prefix reverse. More...

ACE_Double_Linked_List_Reverse_Iterator<
T > 
operator-- (int)
 Postfix reverse. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


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 722 of file Containers_T.h.


Constructor & Destructor Documentation

template<class T>
ACE_Double_Linked_List_Reverse_Iterator< T >::ACE_Double_Linked_List_Reverse_Iterator ACE_Double_Linked_List< T > &   
 

Definition at line 550 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::current_.

00551   : ACE_Double_Linked_List_Iterator_Base <T> (dll)
00552 {
00553   this->current_ = ACE_static_cast (T*, dll.head_->prev_);
00554   // Advance current_ out of the null area and onto the last item in
00555   // the list
00556 }


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.

Definition at line 574 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat.

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

template<class T>
T * ACE_Double_Linked_List_Reverse_Iterator< T >::advance_and_remove int    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 0, this function behaves like <advance> but return 0 (NULL) instead.

Definition at line 580 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat, ACE_Double_Linked_List_Iterator_Base::next, and ACE_Double_Linked_List::remove.

00581 {
00582   T* item = 0;
00583   if (dont_remove)
00584     this->do_retreat ();
00585   else
00586     {
00587       item = this->next ();
00588       this->do_retreat ();
00589       // It seems dangerous to remove nodes in an iterator, but so it goes...
00590       ACE_Double_Linked_List<T> *dllist = ACE_const_cast (ACE_Double_Linked_List<T> *, this->dllist_);
00591       dllist->remove (item);
00592     }
00593   return item;
00594 }

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.

Definition at line 597 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::dump_i.

00598 {
00599   this->dump_i ();
00600 }

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 568 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::go_tail.

00569 {
00570   return this->go_tail ();
00571 }

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

Postfix advance.

Definition at line 617 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat.

00618 {
00619   ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
00620   this->do_retreat ();
00621   return retv;
00622 }

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

Prefix advance.

Definition at line 606 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat.

00607 {
00608   this->do_retreat ();
00609   return *this;
00610 }

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

Postfix reverse.

Definition at line 640 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_advance.

00641 {
00642   ACE_Double_Linked_List_Reverse_Iterator<T> retv (*this);
00643   this->do_advance ();
00644   return retv;
00645 }

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

Prefix reverse.

Definition at line 629 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_advance.

00630 {
00631   this->do_advance ();
00632   return *this;
00633 }

template<class T>
void ACE_Double_Linked_List_Reverse_Iterator< T >::reset ACE_Double_Linked_List< T > &   
 

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.

Definition at line 559 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::current_.

00560 {
00561   this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
00562   this->current_ = ACE_static_cast (T*, dll.head_->prev_);
00563   // Advance current_ out of the null area and onto the last item in
00564   // the list
00565 }


Member Data Documentation

template<class T>
ACE_Double_Linked_List_Reverse_Iterator::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Double_Linked_List_Iterator_Base.

Definition at line 773 of file Containers_T.h.


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