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

ACE_Double_Linked_List_Iterator Class Template Reference

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

#include <Containers_T.h>

Inheritance diagram for ACE_Double_Linked_List_Iterator:

Inheritance graph
[legend]
Collaboration diagram for ACE_Double_Linked_List_Iterator:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Double_Linked_List_Iterator (const 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_Iterator<
T > & 
operator++ (void)
 Prefix advance. More...

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

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

ACE_Double_Linked_List_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_Iterator< T >

Implements an iterator for a double linked list ADT.

Iterate thru the double-linked list. This class provides an interface that let users access the internal element addresses directly. 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 653 of file Containers_T.h.


Constructor & Destructor Documentation

template<class T>
ACE_Double_Linked_List_Iterator< T >::ACE_Double_Linked_List_Iterator const ACE_Double_Linked_List< T > &   
 

Definition at line 448 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::current_.

00449   : ACE_Double_Linked_List_Iterator_Base <T> (dll)
00450 {
00451   this->current_ = ACE_static_cast (T*, dll.head_->next_);
00452   // Advance current_ out of the null area and onto the first item in
00453   // the list
00454 }


Member Function Documentation

template<class T>
int ACE_Double_Linked_List_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_Iterator.

Definition at line 472 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_advance.

Referenced by ACE_Thread_Manager::apply_all, ACE_Thread_Manager::apply_grp, ACE_Thread_Manager::apply_task, ACE_Double_Linked_List::copy_nodes, ACE_Thread_Manager::dump, ACE_Thread_Manager::find_hthread, ACE_Thread_Manager::find_task, ACE_Thread_Manager::find_thread, ACE_Double_Linked_List::get, ACE_Thread_Manager::hthread_grp_list, ACE_Thread_Manager::hthread_list, ACE_Thread_Manager::hthread_within, ACE_Thread_Manager::join, ACE_Thread_Manager::num_tasks_in_group, ACE_Thread_Manager::num_threads_in_task, ACE_Thread_Manager::set_grp, ACE_Thread_Manager::task_all_list, ACE_Thread_Manager::task_list, ACE_Thread_Manager::thread_all_list, ACE_Thread_Manager::thread_grp_list, ACE_Thread_Manager::thread_list, ACE_Thread_Manager::thread_within, ACE_Thread_Manager::wait, ACE_Thread_Manager::wait_grp, and ACE_Thread_Manager::wait_task.

00473 {
00474   return this->do_advance () ? 1 : 0;
00475 }

template<class T>
T * ACE_Double_Linked_List_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 478 of file Containers_T.cpp.

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

Referenced by ACE_Thread_Manager::join, ACE_Thread_Manager::wait_grp, and ACE_Thread_Manager::wait_task.

00479 {
00480   T* item = 0;
00481   if (dont_remove)
00482     this->do_advance ();
00483   else
00484     {
00485       item = this->next ();
00486       this->do_advance ();
00487       // It seems dangerous to remove nodes in an iterator, but so it goes...
00488       ACE_Double_Linked_List<T> *dllist = ACE_const_cast (ACE_Double_Linked_List<T> *, this->dllist_);
00489       dllist->remove (item);
00490     }
00491   return item;
00492 }

template<class T>
void ACE_Double_Linked_List_Iterator< T >::dump void    const
 

Dump the state of an object.

Reimplemented in ACE_DLList_Iterator.

Definition at line 495 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::dump_i.

00496 {
00497   this->dump_i ();
00498 }

template<class T>
int ACE_Double_Linked_List_Iterator< T >::first void   
 

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

Definition at line 466 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::go_head.

00467 {
00468   return this->go_head ();
00469 }

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

Postfix advance.

Definition at line 515 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_advance.

00516 {
00517   ACE_Double_Linked_List_Iterator<T> retv (*this);
00518   this->do_advance ();
00519   return retv;
00520 }

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

Prefix advance.

Definition at line 504 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_advance.

00505 {
00506   this->do_advance ();
00507   return *this;
00508 }

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

Postfix reverse.

Definition at line 538 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat.

00539 {
00540   ACE_Double_Linked_List_Iterator<T> retv (*this);
00541   this->do_retreat ();
00542   return retv;
00543 }

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

Prefix reverse.

Definition at line 527 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::do_retreat.

00528 {
00529   this->do_retreat ();
00530   return *this;
00531 }

template<class T>
void ACE_Double_Linked_List_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 457 of file Containers_T.cpp.

References ACE_Double_Linked_List_Iterator_Base::current_.

00458 {
00459   this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
00460   this->current_ = ACE_static_cast (T*, dll.head_->next_);
00461   // Advance current_ out of the null area and onto the first item in
00462   // the list
00463 }


Member Data Documentation

template<class T>
ACE_Double_Linked_List_Iterator::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Double_Linked_List_Iterator_Base.

Definition at line 704 of file Containers_T.h.


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