This is Unofficial EPICS BASE Doxygen Site
tsDLList< T > Class Template Reference

#include "tsDLList.h"

Public Member Functions

 tsDLList ()
 
unsigned count () const
 
void add (T &item)
 
void add (tsDLList< T > &addList)
 
void push (T &item)
 
void push (tsDLList< T > &pushList)
 
void remove (T &item)
 
void removeAll (tsDLList< T > &destination)
 
T * get ()
 
T * pop ()
 
void insertAfter (T &item, T &itemBefore)
 
void insertBefore (T &item, T &itemAfter)
 
int find (const T &item) const
 
T * first (void) const
 
T * last (void) const
 
tsDLIterConst< T > firstIter () const
 
tsDLIter< T > firstIter ()
 
tsDLIterConst< T > lastIter () const
 
tsDLIter< T > lastIter ()
 

Static Public Member Functions

static tsDLIterConst< T > invalidConstIter ()
 
static tsDLIter< T > invalidIter ()
 

Detailed Description

template<class T>
class tsDLList< T >

Definition at line 21 of file tsDLList.h.

Constructor & Destructor Documentation

template<class T >
tsDLList< T >::tsDLList ( )
inline

Definition at line 170 of file tsDLList.h.

171 {
172  this->clear ();
173 }

Member Function Documentation

template<class T>
void tsDLList< T >::add ( T &  item)
inline

Definition at line 313 of file tsDLList.h.

314 {
315  tsDLNode<T> &theNode = item;
316 
317  theNode.pNext = 0;
318  theNode.pPrev = this->pLast;
319 
320  if ( this->itemCount ) {
321  tsDLNode<T> &lastNode = *this->pLast;
322  lastNode.pNext = &item;
323  }
324  else {
325  this->pFirst = &item;
326  }
327 
328  this->pLast = &item;
329 
330  this->itemCount++;
331 }
Internal: bucket item structure.
Definition: bucketLib.h:40
template<class T>
void tsDLList< T >::add ( tsDLList< T > &  addList)
inline

Definition at line 289 of file tsDLList.h.

290 {
291  if ( addList.itemCount != 0u ) {
292  if ( this->itemCount == 0u ) {
293  this->pFirst = addList.pFirst;
294  }
295  else {
296  tsDLNode<T> *pLastNode = this->pLast;
297  tsDLNode<T> *pAddListFirstNode = addList.pFirst;
298  pLastNode->pNext = addList.pFirst;
299  pAddListFirstNode->pPrev = addList.pLast;
300  }
301  this->pLast = addList.pLast;
302  this->itemCount += addList.itemCount;
303  addList.clear();
304  }
305 }
template<class T >
unsigned tsDLList< T >::count ( ) const
inline

Definition at line 181 of file tsDLList.h.

182 {
183  return this->itemCount;
184 }
template<class T>
int tsDLList< T >::find ( const T &  item) const

Definition at line 442 of file tsDLList.h.

443 {
444  tsDLIterConst < T > thisItem ( &item );
445  tsDLIterConst < T > iter ( this->first () );
446  int itemNo = 0;
447 
448  while ( iter.valid () ) {
449  if ( iter == thisItem ) {
450  return itemNo;
451  }
452  itemNo++;
453  iter++;
454  }
455  return -1;
456 }
Internal: bucket item structure.
Definition: bucketLib.h:40
T * first(void) const
Definition: tsDLList.h:190
template<class T >
T * tsDLList< T >::first ( void  ) const
inline

Definition at line 190 of file tsDLList.h.

191 {
192  return this->pFirst;
193 }
template<class T >
tsDLIterConst< T > tsDLList< T >::firstIter ( ) const
inline

Definition at line 459 of file tsDLList.h.

460 {
461  return tsDLIterConst < T > ( this->pFirst );
462 }
template<class T >
tsDLIter< T > tsDLList< T >::firstIter ( )
inline

Definition at line 465 of file tsDLList.h.

466 {
467  return tsDLIter < T > ( this->pFirst );
468 }
template<class T >
T * tsDLList< T >::get ( )
inline

Definition at line 261 of file tsDLList.h.

262 {
263  T *pItem = this->pFirst;
264 
265  if ( pItem ) {
266  this->remove ( *pItem );
267  }
268 
269  return pItem;
270 }
template<class T>
void tsDLList< T >::insertAfter ( T &  item,
T &  itemBefore 
)
inline

Definition at line 339 of file tsDLList.h.

340 {
341  tsDLNode<T> &nodeItem = item;
342  tsDLNode<T> &nodeBefore = itemBefore;
343 
344  nodeItem.pPrev = &itemBefore;
345  nodeItem.pNext = nodeBefore.pNext;
346  nodeBefore.pNext = &item;
347 
348  if (nodeItem.pNext) {
349  tsDLNode<T> *pNextNode = nodeItem.pNext;
350  pNextNode->pPrev = &item;
351  }
352  else {
353  this->pLast = &item;
354  }
355 
356  this->itemCount++;
357 }
Internal: bucket item structure.
Definition: bucketLib.h:40
template<class T>
void tsDLList< T >::insertBefore ( T &  item,
T &  itemAfter 
)
inline

Definition at line 365 of file tsDLList.h.

366 {
367  tsDLNode<T> &node = item;
368  tsDLNode<T> &nodeAfter = itemAfter;
369 
370  node.pNext = &itemAfter;
371  node.pPrev = nodeAfter.pPrev;
372  nodeAfter.pPrev = &item;
373 
374  if (node.pPrev) {
375  tsDLNode<T> &prevNode = *node.pPrev;
376  prevNode.pNext = &item;
377  }
378  else {
379  this->pFirst = &item;
380  }
381 
382  this->itemCount++;
383 }
Internal: bucket item structure.
Definition: bucketLib.h:40
template<class T >
tsDLIterConst< T > tsDLList< T >::invalidConstIter ( )
inlinestatic

Definition at line 483 of file tsDLList.h.

484 {
485  return tsDLIterConst < T > ( 0 );
486 }
template<class T >
tsDLIter< T > tsDLList< T >::invalidIter ( )
inlinestatic

Definition at line 489 of file tsDLList.h.

490 {
491  return tsDLIter < T > ( 0 );
492 }
template<class T >
T * tsDLList< T >::last ( void  ) const
inline

Definition at line 199 of file tsDLList.h.

200 {
201  return this->pLast;
202 }
template<class T >
tsDLIterConst< T > tsDLList< T >::lastIter ( ) const
inline

Definition at line 471 of file tsDLList.h.

472 {
473  return tsDLIterConst < T > ( this->pLast );
474 }
template<class T >
tsDLIter< T > tsDLList< T >::lastIter ( )
inline

Definition at line 477 of file tsDLList.h.

478 {
479  return tsDLIter < T > ( this->pLast );
480 }
template<class T >
T * tsDLList< T >::pop ( )
inline

Definition at line 277 of file tsDLList.h.

278 {
279  return this->get ();
280 }
template<class T>
void tsDLList< T >::push ( T &  item)
inline

Definition at line 416 of file tsDLList.h.

417 {
418  tsDLNode<T> &theNode = item;
419  theNode.pPrev = 0;
420  theNode.pNext = this->pFirst;
421 
422  if ( this->itemCount ) {
423  tsDLNode<T> *pFirstNode = this->pFirst;
424  pFirstNode->pPrev = & item;
425  }
426  else {
427  this->pLast = & item;
428  }
429 
430  this->pFirst = &item;
431 
432  this->itemCount++;
433 }
Internal: bucket item structure.
Definition: bucketLib.h:40
template<class T>
void tsDLList< T >::push ( tsDLList< T > &  pushList)
inline

Definition at line 392 of file tsDLList.h.

393 {
394  if ( pushList.itemCount != 0u ) {
395  if ( this->itemCount ) {
396  tsDLNode<T> * pFirstNode = this->pFirst;
397  tsDLNode<T> * pAddListLastNode = pushList.pLast;
398  pFirstNode->pPrev = pushList.pLast;
399  pAddListLastNode->pNext = this->pFirst;
400  }
401  else {
402  this->pLast = pushList.pLast;
403  }
404  this->pFirst = pushList.pFirst;
405  this->itemCount += pushList.itemCount;
406  pushList.clear();
407  }
408 }
template<class T>
void tsDLList< T >::remove ( T &  item)
inline

Definition at line 219 of file tsDLList.h.

220 {
221  tsDLNode<T> &theNode = item;
222 
223  if ( this->pLast == &item ) {
224  this->pLast = theNode.pPrev;
225  }
226  else {
227  tsDLNode<T> &nextNode = *theNode.pNext;
228  nextNode.pPrev = theNode.pPrev;
229  }
230 
231  if ( this->pFirst == &item ) {
232  this->pFirst = theNode.pNext;
233  }
234  else {
235  tsDLNode<T> &prevNode = *theNode.pPrev;
236  prevNode.pNext = theNode.pNext;
237  }
238 
239  this->itemCount--;
240 }
Internal: bucket item structure.
Definition: bucketLib.h:40
template<class T>
void tsDLList< T >::removeAll ( tsDLList< T > &  destination)
inline

Definition at line 246 of file tsDLList.h.

248 {
249  destination.pFirst = this->pFirst;
250  destination.pLast = this->pLast;
251  destination.itemCount = this->itemCount;
252  this->pFirst = 0;
253  this->pLast = 0;
254  this->itemCount = 0;
255 }

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