Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3654 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Mar 25, 2005, 6:47:26 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: altered the list function to make it more performant the world now uses iterators everywhere.

File:
1 edited

Legend:

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

    r3653 r3654  
    8787inline T* tIterator<T>::nextElement ()
    8888{
    89   if( this->currentEl == NULL)
    90     {
    91       PRINTF(1)("Iterator has not been initialized - there is no currentEl\n");
     89  if( this->currentEl == NULL || this->currentEl->next == NULL) /* don't turn it the other way or it will give segfaults! */
    9290      return NULL;
    93     }
    9491  if( this->currentEl == this->firstEl)
    9592    {
    9693      this->currentEl = this->currentEl->next;
    97       return this->firstEl->curr;
    98     }
    99   if( this->currentEl->next == NULL)
    100     return NULL;
     94      return this->firstEl->curr; /* if its the first element, don't return second element*/
     95    }
    10196  this->currentEl = this->currentEl->next;
    10297  return this->currentEl->curr;
     
    126121
    127122 private:
    128 
    129123  Uint32 size;
    130124  listElement<T>* first;
    131125  listElement<T>* last;
    132126  listElement<T>* currentEl;
    133 
    134127};
    135128
     
    255248inline tIterator<T>* tList<T>::getIterator()
    256249{
    257   if( this->size == 0) return NULL;
    258250  tIterator<T>* iterator = new tIterator<T>(this->first);
    259251  return iterator;
Note: See TracChangeset for help on using the changeset viewer.