Changeset 4574 in orxonox.OLD for orxonox/trunk/src/lib/util
- Timestamp:
- Jun 10, 2005, 1:50:37 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/util/list.h
r4508 r4574 14 14 15 15 16 //! a list element of the tList, 16 //! a list element of the tList, 17 17 template<class T> struct listElement 18 18 { … … 32 32 tIterator(listElement<T>* startElement); 33 33 ~tIterator(); 34 34 35 35 T* nextElement(); 36 36 … … 45 45 \param startElement: the first list element from the tList 46 46 47 normaly you will use it like this: 47 normaly you will use it like this: 48 48 49 49 tIterator<char>* nameIterator = nameList->getIterator(); 50 char name* = nameIterator->nextElement(); 50 char name* = nameIterator->nextElement(); 51 51 while( name != NULL) 52 52 { 53 53 PRINTF(3)("found name: %s in list\n", name); 54 name = nameIterator->nextElement(); 54 name = nameIterator->nextElement(); 55 55 } 56 delete nameIterator; 57 */ 58 template<class T> 59 inline tIterator<T>::tIterator (listElement<T>* startElement) 56 delete nameIterator; 57 */ 58 template<class T> 59 inline tIterator<T>::tIterator (listElement<T>* startElement) 60 60 { 61 61 this->currentEl = startElement; … … 96 96 you will use this as a generic list for all type of objects 97 97 */ 98 template<class T> class tList 98 template<class T> class tList 99 99 { 100 100 public: … … 127 127 */ 128 128 template<class T> 129 inline tList<T>::tList () 129 inline tList<T>::tList () 130 130 { 131 131 this->first = NULL; … … 138 138 \brief the deconstructor 139 139 140 this will delete only the list. ATTENTION: the list is deleted, but the objects in the list will 140 this will delete only the list. ATTENTION: the list is deleted, but the objects in the list will 141 141 not be deleted 142 142 */ 143 143 template<class T> 144 inline tList<T>::~tList () 144 inline tList<T>::~tList () 145 145 { 146 146 this->currentEl = this->first; … … 191 191 { 192 192 if( unlikely(this->currentEl->curr == entity)) 193 { 194 195 196 197 198 199 200 201 202 203 193 { 194 if( unlikely(this->currentEl->prev == NULL)) this->first = this->currentEl->next; 195 else this->currentEl->prev->next = this->currentEl->next; 196 197 if( unlikely(this->currentEl->next == NULL)) this->last = this->currentEl->prev; 198 else this->currentEl->next->prev = this->currentEl->prev; 199 200 delete this->currentEl; 201 this->size--; 202 return; 203 } 204 204 this->currentEl = this->currentEl->next; 205 205 } … … 266 266 template<class T> 267 267 inline bool tList<T>::inList(T* entity) 268 { 268 { 269 269 // pre checks 270 270 if(this->size == 0) return false; … … 277 277 278 278 // post checks 279 if(this->currentEl == NULL) 279 if(this->currentEl == NULL) 280 280 return false; 281 281 else
Note: See TracChangeset
for help on using the changeset viewer.