libcsdbg  1.28
C++ exception (and generic) stack trace debug library
template<class T>
chain< T > & csdbg::chain< T >::foreach ( void(*)(u32, T *)  pfunc) const
virtual

Traverse the chain with a callback for each node.

Parameters
[in]pfuncthe callback
Returns
*this

Definition at line 473 of file chain.hpp.

References __D_ASSERT, likely, csdbg::node< T >::link(), csdbg::node< T >::m_data, and unlikely.

474 {
475  __D_ASSERT(pfunc != NULL);
476  if ( unlikely(pfunc == NULL) )
477  return const_cast<chain<T>&> (*this);
478 
479  u32 i = 0;
480  node<T> *cur = m_head, *prev = NULL, *next;
481  while ( likely(cur != NULL) ) {
482  pfunc(i++, cur->m_data);
483 
484  next = cur->link(prev);
485  prev = cur;
486  cur = next;
487  }
488 
489  return const_cast<chain<T>&> (*this);
490 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
node< T > * m_head
Chain head.
Definition: chain.hpp:39
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the call graph for this function: