Zero  0.1.0
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
w_list_i< T, LOCK > Class Template Reference

Iterator for a list. More...

#include <w_list.h>

Inheritance diagram for w_list_i< T, LOCK >:
w_base_t w_list_const_i< T, LOCK >

Public Member Functions

 w_list_i ()
 
 w_list_i (const w_list_t< T, LOCK > &l, bool backwards=false)
 
virtual ~w_list_i ()
 
void reset (const w_list_t< T, LOCK > &l, bool backwards=false)
 
Tnext ()
 
Tcurr () const
 Return the current item in the list. More...
 

Protected Attributes

const w_list_t< T, LOCK > * _list
 

Private Member Functions

 w_list_i (w_list_i< T, LOCK > &)
 
w_list_i< T, LOCK > & operator= (w_list_i< T, LOCK > &)
 

Private Attributes

w_link_t_next
 
T_curr
 
bool _backwards
 

Additional Inherited Members

- Public Types inherited from w_base_t
enum  CompareOp {
  badOp = 0x0, eqOp = 0x1, gtOp = 0x2, geOp = 0x3,
  ltOp = 0x4, leOp = 0x5, NegInf = 0x100, eqNegInf,
  gtNegInf, geNegInf, ltNegInf, leNegInf,
  PosInf = 0x400, eqPosInf, gtPosInf, gePosInf,
  ltPosInf, lePosInf
}
 Comparison Operators. More...
 
typedef unsigned char u_char
 
typedef unsigned short u_short
 
typedef unsigned long u_long
 
typedef uint64_t large_stat_t
 
typedef int32_t base_stat_t
 
typedef float base_float_t
 
typedef float f4_t
 
typedef double f8_t
 
- Static Public Member Functions inherited from w_base_t
static bool is_aligned (size_t sz)
 
static bool is_aligned (const void *s)
 
static bool is_big_endian ()
 
static bool is_little_endian ()
 
static int64_t strtoi8 (const char *, char **end=0, int base=0)
 Convert string to 8-byte integer. More...
 
static uint64_t strtou8 (const char *, char **end=0, int base=0)
 Convert string to 8-byte unsigned integer. More...
 
static bool is_finite (const f8_t x)
 
static bool is_infinite (const f8_t x)
 
static bool is_nan (const f8_t x)
 
static bool is_infinite_or_nan (const f8_t x)
 
static uint16_t w_ntohs (uint16_t)
 
static uint16_t w_htons (uint16_t)
 
static uint32_t w_ntohl (uint32_t)
 
static uint32_t w_htonl (uint32_t)
 
static void assert_failed (const char *desc, const char *file, uint32_t line)
 print a message and abort More...
 
static void abort ()
 dump core More...
 
- Static Public Attributes inherited from w_base_t
static const int8_t int1_max = 0x7f
 
static const int8_t int1_min = (int8_t)0x80u
 
static const int16_t int2_max = 0x7fff
 
static const int16_t int2_min = (int16_t)0x8000u
 
static const int32_t int4_max = 0x7fffffff
 
static const int32_t int4_min = 0x80000000
 
static const int64_t int8_max
 
static const int64_t int8_min
 
static const uint8_t uint1_max = 0xff
 
static const uint8_t uint1_min = 0x0
 
static const uint16_t uint2_max = 0xffff
 
static const uint16_t uint2_min = 0x0
 
static const uint32_t uint4_max = 0xffffffff
 
static const uint32_t uint4_min = 0x0
 
static const uint64_t uint8_max
 
static const uint64_t uint8_min
 

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_i<sthread_t*> i(thread_list);
while(i.next()) {
sthread_t *t = i.curr();
if (t-> .....) ....
}

Constructor & Destructor Documentation

§ w_list_i() [1/3]

template<class T, class LOCK>
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.

§ w_list_i() [2/3]

template<class T, class LOCK>
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.

§ ~w_list_i()

template<class T, class LOCK>
virtual w_list_i< T, LOCK >::~w_list_i ( )
inlinevirtual

§ w_list_i() [3/3]

template<class T, class LOCK>
w_list_i< T, LOCK >::w_list_i ( w_list_i< T, LOCK > &  )
private

Member Function Documentation

§ curr()

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.

§ next()

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.

§ operator=()

template<class T, class LOCK>
w_list_i<T, LOCK>& w_list_i< T, LOCK >::operator= ( w_list_i< T, LOCK > &  )
private

§ reset()

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.

Member Data Documentation

§ _backwards

template<class T, class LOCK>
bool w_list_i< T, LOCK >::_backwards
private

§ _curr

template<class T, class LOCK>
T* w_list_i< T, LOCK >::_curr
private

§ _list

template<class T, class LOCK>
const w_list_t<T, LOCK>* w_list_i< T, LOCK >::_list
protected

§ _next

template<class T, class LOCK>
w_link_t* w_list_i< T, LOCK >::_next
private

The documentation for this class was generated from the following file: