w_list_i< T, LOCK > Class Template Reference

Inherits w_base_t.

Inherited by w_list_const_i< T, LOCK >.

Inheritance diagram for w_list_i< T, LOCK >:

Inheritance graph
[legend]
Collaboration diagram for w_list_i< T, LOCK >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T, class LOCK>
class w_list_i< T, LOCK >

Iterator for a list.

Attention:
This iterator is not thread-safe. It is up to the user to provide thread-safety for the list.

Modifying the list while iterating over it: You can remove items from the list while iterating over it thus:

 while(iter.next()) {
    item = iter.curr();
    \< Now you can remove the item. \>
 }
Adding elements to the list while iterating yields undefined behavior.
Example of use:
 w_list_t<sthread_t*> thread_list;
 w_list_i<sthread_t*> i(thread_list);

 while(i.next()) {
    sthread_t *t = i.curr();
    if (t-> .....) ....
 }

Definition at line 438 of file w_list.h.

Public Member Functions

NORET w_list_i ()
NORET w_list_i (const w_list_t< T, LOCK > &l, bool backwards=false)
NORET ~w_list_i ()
void reset (const w_list_t< T, LOCK > &l, bool backwards=false)
T * next ()
T * curr () const
 Return the current item in the list.

Protected Attributes

const w_list_t< T, LOCK > * _list


Constructor & Destructor Documentation

template<class T, class LOCK>
NORET w_list_i< T, LOCK >::w_list_i (  )  [inline]

Create a forward iterator. Since the list to be iterated isn't given, you must call reset() before you can use this iterator.

Definition at line 443 of file w_list.h.

template<class T, class LOCK>
NORET w_list_i< T, LOCK >::w_list_i ( const w_list_t< T, LOCK > &  l,
bool  backwards = false 
) [inline]

Create a forward or backward iterator iterator for the given list. Don't allow updating of the list while iterating.

Definition at line 448 of file w_list.h.


Member Function Documentation

template<class T, class LOCK>
void w_list_i< T, LOCK >::reset ( const w_list_t< T, LOCK > &  l,
bool  backwards = false 
) [inline]

Make an iterator usable (possibly again), for the given list, backward or forward.

Definition at line 457 of file w_list.h.

Referenced by w_list_const_i< T, LOCK >::reset().

Here is the caller graph for this function:

template<class T, class LOCK>
T* w_list_i< T, LOCK >::next (  )  [inline]

Adjust the iterator to point to the next item in the list and return a pointer to that next item. Returns NULL if there is no next item. Note that this depends on the results of the previous next() call, but what we do with curr() from the prior call is immaterial.

Reimplemented in w_list_const_i< T, LOCK >.

Definition at line 469 of file w_list.h.

Referenced by sthread_t::check_all_stacks(), option_group_t::check_required(), sthread_t::collect(), sthread_t::dumpall(), sthread_t::for_each_thread(), w_hash_t< T, LOCK, K >::lookup(), option_group_t::lookup(), w_list_const_i< T, LOCK >::next(), operator<<(), option_group_t::print_usage(), option_group_t::print_values(), w_hash_t< T, LOCK, K >::remove(), and option_group_t::~option_group_t().

Here is the caller graph for this function:

template<class T, class LOCK>
T* w_list_i< T, LOCK >::curr (  )  const [inline]

Return the current item in the list.

Returns NULL if there is no current item. There is no current item until next() is called at least once, thus, one must call next() to get the first item.

Reimplemented in w_list_const_i< T, LOCK >.

Definition at line 488 of file w_list.h.

Referenced by sthread_t::check_all_stacks(), sthread_t::collect(), w_list_const_i< T, LOCK >::curr(), sthread_t::dumpall(), sthread_t::for_each_thread(), option_group_t::lookup(), operator<<(), option_group_t::print_usage(), option_group_t::print_values(), w_hash_t< T, LOCK, K >::remove(), and option_group_t::~option_group_t().

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7