Changeset 3661 in orxonox.OLD for orxonox/trunk/src/lib/util
- Timestamp:
- Mar 29, 2005, 10:34:25 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/util/list.h
r3654 r3661 66 66 listElement<T>* currentEl; 67 67 listElement<T>* firstEl; 68 int counter; 68 69 }; 69 70 … … 74 75 this->currentEl = startElement; 75 76 this->firstEl = startElement; 77 this->counter = -1; 76 78 } 77 79 … … 87 89 inline T* tIterator<T>::nextElement () 88 90 { 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 96 98 this->currentEl = this->currentEl->next; 97 99 return this->currentEl->curr; … … 154 156 155 157 template<class T> 156 void tList<T>::add(T* entity)158 inline void tList<T>::add(T* entity) 157 159 { 158 160 if( entity == NULL) return; … … 171 173 172 174 template<class T> 173 void tList<T>::remove(T* entity)175 inline void tList<T>::remove(T* entity) 174 176 { 175 177 if( entity == NULL) return;
Note: See TracChangeset
for help on using the changeset viewer.