Changeset 5403 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Oct 19, 2005, 1:00:43 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/list.h
r5400 r5403 37 37 void add(T* entity); 38 38 void addAtBeginning(T* entity); //!< @todo This should be made with an ENUM 39 void addAtIteratorPosition(T* entity, tIterator<T>* itereator); 39 40 void remove(const T* entity); 40 41 void removeFromLast(const T* entity); … … 122 123 { 123 124 if( unlikely(entity == NULL)) return; 125 124 126 listElement<T>* el = new listElement<T>; 125 127 el->next = this->first; … … 134 136 } 135 137 138 /** 139 * add an entity at an iterators position 140 * @param entity the entity to add 141 * @param iterator the iterator get the Positional from 142 * 143 * this works best with an iterator walking with 144 * firstElement() ; nextStep(); 145 * or 146 * lastElement(); prevStep(); 147 */ 148 template<class T> 149 inline void tList<T>::addAtIteratorPosition(T* entity, tIterator<T>* iterator) 150 { 151 // rule out unusable 152 if (unlikely(entity == NULL)) 153 return; 154 // on any error (or next == NULL) add using default add-function 155 if (unlikely(iterator == NULL || iterator->getList() == NULL) || 156 iterator->tmpEl == NULL || iterator->tmpEl->next == NULL) 157 return this->add(entity); 158 // on prev == NULL add with addAtBeginning-function 159 if (unlikely(iterator->tmpEl->prev == NULL)) 160 return addAtBeginning(entity); 161 else 162 { 163 listElement<T>* el = new listElement<T>; 164 el->next = iterator->tmpEl->next; 165 el->curr = entity; 166 el->prev = iterator->tmpEl->prev; 167 168 el->next->prev = el; 169 el->prev->next = el; 170 } 171 } 136 172 137 173 /** … … 370 406 template<class T> class tIterator 371 407 { 408 friend class tList<T>; 372 409 public: 373 410 tIterator(const tList<T>* list); … … 380 417 T* seekElement(const T* element); 381 418 T* iteratorElement(const tIterator<T>* iterator); 382 bool compareListPointer(const tList<T>* list) ;383 419 bool compareListPointer(const tList<T>* list) const; 420 inline const tList<T>* getList() const { return this->list; }; 384 421 /** another way to iterate through the list 385 422 * !! THIS IS NOT MEANT FOR DELETION … … 554 591 555 592 template<class T> 556 bool tIterator<T>::compareListPointer(const tList<T>* list) 593 bool tIterator<T>::compareListPointer(const tList<T>* list) const 557 594 { 558 595 return (this->list == list)?true:false;
Note: See TracChangeset
for help on using the changeset viewer.