Changeset 3746 in orxonox.OLD for orxonox/branches/levelloader/src/lib/util
- Timestamp:
- Apr 7, 2005, 3:54:49 PM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/lib/util
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/lib/util/list.h
r3605 r3746 46 46 }; 47 47 48 class Iterator 49 { 50 48 49 50 template<class T> struct listElement 51 { 52 listElement* prev; 53 T* curr; 54 listElement* next; 55 }; 56 57 template<class T> class tIterator 58 { 51 59 public: 52 bool hasNext(); 53 WorldEntity* next(); 60 tIterator(listElement<T>* startElement); 61 ~tIterator(); 62 63 T* nextElement(); 54 64 55 65 private: 56 57 }; 66 listElement<T>* currentEl; 67 listElement<T>* tmpEl; 68 }; 69 70 71 template<class T> 72 inline tIterator<T>::tIterator (listElement<T>* startElement) 73 { 74 this->currentEl = startElement; 75 this->tmpEl = NULL; 76 } 77 78 79 template<class T> 80 tIterator<T>::~tIterator () 81 { 82 this->currentEl = NULL; 83 } 84 85 86 template<class T> 87 inline T* tIterator<T>::nextElement () 88 { 89 if( this->currentEl == NULL) 90 return NULL; 91 92 this->tmpEl = this->currentEl; 93 this->currentEl = this->currentEl->next; 94 return this->tmpEl->curr; 95 } 96 58 97 59 98 60 99 template<class T> class tList 61 100 { 62 private:63 struct listElement64 {65 listElement* prev;66 T* curr;67 listElement* next;68 };69 70 Uint32 size;71 listElement* first;72 listElement* last;73 listElement* currentEl;74 75 101 public: 76 102 tList (); 77 103 ~tList (); 78 79 104 80 105 void add(T* entity); … … 85 110 int getSize(); 86 111 T* enumerate(); 112 tIterator<T>* getIterator(); 87 113 T* nextElement(); 88 114 T* nextElement(T* toEntity); 89 115 T* toArray(); 90 116 void debug(); 117 118 private: 119 Uint32 size; 120 listElement<T>* first; 121 listElement<T>* last; 122 listElement<T>* currentEl; 91 123 }; 92 124 … … 106 138 while(this->currentEl != NULL) 107 139 { 108 listElement * le = this->currentEl->next;140 listElement<T>* le = this->currentEl->next; 109 141 //delete this->currentEl->curr; 110 142 delete this->currentEl; … … 118 150 119 151 template<class T> 120 void tList<T>::add(T* entity)152 inline void tList<T>::add(T* entity) 121 153 { 122 154 if( entity == NULL) return; 123 listElement * el = new listElement;155 listElement<T>* el = new listElement<T>; 124 156 el->prev = this->last; 125 157 el->curr = entity; … … 135 167 136 168 template<class T> 137 void tList<T>::remove(T* entity)169 inline void tList<T>::remove(T* entity) 138 170 { 139 171 if( entity == NULL) return; 140 172 this->currentEl = this->first; 141 listElement * te;173 listElement<T>* te; 142 174 while( this->currentEl != NULL) 143 175 { … … 150 182 else this->currentEl->next->prev = this->currentEl->prev; 151 183 152 te = this->currentEl->next; // for what am i doing this?184 //te = this->currentEl->next; // for what am i doing this? 153 185 delete this->currentEl; 154 this->currentEl = te; 186 //this->currentEl = te; 187 this->currentEl = NULL; 155 188 this->size--; 156 189 return; … … 167 200 while(this->currentEl != NULL) 168 201 { 169 listElement * le = this->currentEl->next;202 listElement<T>* le = this->currentEl->next; 170 203 //delete this->currentEl->curr; 171 204 delete this->currentEl; … … 203 236 { 204 237 //if( this->last == this->first == NULL) return NULL; 205 if( this->size == 0) return NULL;238 if( this->size == 0) return NULL; 206 239 this->currentEl = this->first; 207 240 return this->currentEl->curr; … … 210 243 211 244 template<class T> 245 inline tIterator<T>* tList<T>::getIterator() 246 { 247 tIterator<T>* iterator = new tIterator<T>(this->first); 248 return iterator; 249 } 250 251 252 template<class T> 212 253 T* tList<T>::nextElement() 213 254 { 214 255 // if( this->last == this->first == NULL) return NULL; 215 if( this->size == 0) return NULL;256 if( this->size == 0) return NULL; 216 257 this->currentEl = this->currentEl->next; 217 if( this->currentEl == NULL) return NULL;258 if( this->currentEl == NULL) return NULL; 218 259 return this->currentEl->curr; 219 260 } -
orxonox/branches/levelloader/src/lib/util/resource_manager.cc
r3742 r3746 391 391 \param directoryName the Directory to check for 392 392 \returns true if it is a directory/symlink false otherwise 393 \todo implement for win32 usage too 394 \bug does return false by default on win32 393 395 */ 394 396 bool ResourceManager::isDir(const char* directoryName) 395 397 { 398 #ifdef __WIN32__ 399 return false; 400 #elif 396 401 struct stat status; 397 402 stat(directoryName, &status); … … 400 405 else 401 406 return false; 407 #endif 402 408 } 403 409 … … 406 412 \param fileName the File to check for 407 413 \returns true if it is a regular file/symlink, false otherwise 414 \todo implement fo win32 usage too 415 \bug does return false by default on win32 408 416 */ 409 417 bool ResourceManager::isFile(const char* fileName) 410 418 { 419 #ifdef __WIN32__ 420 return false; 421 #elif 411 422 struct stat status; 412 423 stat(fileName, &status); … … 415 426 else 416 427 return false; 428 #endif 417 429 } 418 430
Note: See TracChangeset
for help on using the changeset viewer.