Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3661 in orxonox.OLD for orxonox/trunk/src/lib/util/list.h


Ignore:
Timestamp:
Mar 29, 2005, 10:34:25 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some changes in the benchmark routines and in the list. list is now more efficent than ever and is integrated in the benchmark system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/util/list.h

    r3654 r3661  
    6666  listElement<T>* currentEl;
    6767  listElement<T>* firstEl;
     68  int counter;
    6869};
    6970
     
    7475  this->currentEl = startElement;
    7576  this->firstEl = startElement;
     77  this->counter = -1;
    7678}
    7779
     
    8789inline T* tIterator<T>::nextElement ()
    8890{
    89   if( this->currentEl == NULL || this->currentEl->next == NULL) /* don't turn it the other way or it will give segfaults! */
    90       return NULL;
    91   if( this->currentEl == this->firstEl)
    92     {
    93       this->currentEl = this->currentEl->next;
    94       return this->firstEl->curr; /* if its the first element, don't return second element*/
    95     }
     91  this->counter++;
     92  if( this->counter == 0)
     93    return this->firstEl->curr;
     94 
     95  if( this->currentEl->next == NULL || this->currentEl == NULL)
     96    return NULL;
     97
    9698  this->currentEl = this->currentEl->next;
    9799  return this->currentEl->curr;
     
    154156
    155157template<class T>
    156 void tList<T>::add(T* entity)
     158inline void tList<T>::add(T* entity)
    157159{
    158160  if( entity == NULL) return;
     
    171173
    172174template<class T>
    173 void tList<T>::remove(T* entity)
     175inline void tList<T>::remove(T* entity)
    174176{
    175177  if( entity == NULL) return;
Note: See TracChangeset for help on using the changeset viewer.