Changeset 4497 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 3, 2005, 11:15:53 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/common/list.h
r4488 r4497 91 91 92 92 93 /** 94 \brief the list template class 95 96 you will use this as a generic list for all type of objects 97 */ 93 98 template<class T> class tList 94 99 { … … 99 104 void add(T* entity); 100 105 void remove(T* entity); 101 void destroy();106 void flush(); 102 107 T* firstElement(); 103 108 T* lastElement(); … … 112 117 113 118 private: 114 unsigned int size;115 listElement<T>* first;116 listElement<T>* last;117 listElement<T>* currentEl;119 unsigned int size; //!< the size (lenght) of the list 120 listElement<T>* first; //!< pointer to the first element 121 listElement<T>* last; //!< pointer to the last element 122 listElement<T>* currentEl; //!< pointer to the current element 118 123 }; 119 124 120 125 126 /** 127 \brief the constructor 128 */ 121 129 template<class T> 122 130 inline tList<T>::tList () … … 127 135 } 128 136 137 138 /** 139 \brief the deconstructor 140 141 this will delete only the list. ATTENTION: the list is deleted, but the objects in the list will 142 not be deleted 143 */ 129 144 template<class T> 130 145 inline tList<T>::~tList () … … 144 159 145 160 161 /** 162 \brief add an entity to the list 163 \param entity: the entity to add 164 */ 146 165 template<class T> 147 166 inline void tList<T>::add(T* entity) … … 161 180 162 181 182 /** 183 \brief remove an entity from the list 184 \param entity: the entity to be removed 185 */ 163 186 template<class T> 164 187 inline void tList<T>::remove(T* entity) … … 185 208 186 209 187 template<class T> 188 inline void tList<T>::destroy() 210 /** 211 \brief this will deletes the objects from the list 212 */ 213 template<class T> 214 inline void tList<T>::flush() 189 215 { 190 216 this->currentEl = this->first; … … 192 218 { 193 219 listElement<T>* le = this->currentEl->next; 194 //delete this->currentEl->curr;220 delete this->currentEl->curr; 195 221 delete this->currentEl; 196 222 this->currentEl = le; … … 202 228 203 229 230 /** 231 \brief returns the first element of the list 232 \returns first element 233 */ 204 234 template<class T> 205 235 inline T* tList<T>::firstElement() … … 209 239 210 240 241 /** 242 \brief function returns the last element of the list 243 \returns the last element 244 */ 211 245 template<class T> 212 246 inline T* tList<T>::lastElement() … … 216 250 217 251 252 /** 253 \brief returns true if the list is empty 254 \returns true if the list is empty 255 */ 218 256 template<class T> 219 257 inline bool tList<T>::isEmpty() … … 223 261 224 262 263 /** 264 \brief this returns the number of elements in the list 265 \returns number of elements 266 */ 225 267 template<class T> 226 268 inline int tList<T>::getSize() … … 230 272 231 273 232 /* deprecated */ 233 /* 234 template<class T> 235 T* tList<T>::enumerate() 236 { 237 //if( this->last == this->first == NULL) return NULL; 238 if( this->size == 0) return NULL; 239 this->currentEl = this->first; 240 return this->currentEl->curr; 241 } 242 */ 243 274 /** 275 \brief creates an itereator object and returns it 276 \returns the iterator object to this list 277 278 You will use this, if you want to iterate through the list 279 */ 244 280 template<class T> 245 281 inline tIterator<T>* tList<T>::getIterator() … … 250 286 251 287 252 /* deprecated */253 template<class T>254 T* tList<T>::nextElement()255 {256 // if( this->last == this->first == NULL) return NULL;257 if( this->size == 0) return NULL;258 this->currentEl = this->currentEl->next;259 if( this->currentEl == NULL) return NULL;260 return this->currentEl->curr;261 }262 263 288 264 289 /** 265 290 \brief this returns the next element after toEntity or the first if toEntity is last 291 \param toEntity: the entity after which is an entity, that has to be returned, sorry, terrible phrase 292 \returns the element after toEntity 266 293 */ 267 294 template<class T> … … 282 309 283 310 311 /** 312 \brief creates an array out of the list (ATTENTION: not implemented) 313 \returns pointer to the array beginning 314 315 ATTENTION: function is not implemented and wont do anything 316 */ 284 317 template<class T> 285 318 T* tList<T>::toArray() 286 {} 319 { 320 return NULL; 321 } 287 322 288 323 #endif /* _LIST_H */
Note: See TracChangeset
for help on using the changeset viewer.