Changeset 4488 in orxonox.OLD for orxonox/trunk/src/util
- Timestamp:
- Jun 3, 2005, 1:00:10 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/common/list.h
r4486 r4488 12 12 #endif 13 13 14 //! An enum to list all the modes available when adding an object to a List 15 //enum ADDMODE {LIST_ADD_FIRST, LIST_ADD_LAST}; 16 //! An enum to list the two searching directions available when removing an object from a List 17 //enum FINDMODE {LIST_FIND_BW, LIST_FIND_FW}; 18 19 20 21 class WorldEntity; 22 23 class List { 24 25 public: 26 List (); 27 ~List (); 28 29 void add(WorldEntity* entity); 30 void remove(WorldEntity* entity); 31 void destroy(); 32 WorldEntity* firstElement(); 33 bool isEmpty(); 34 int getSize(); 35 WorldEntity* enumerate(); 36 WorldEntity* nextElement(); 37 WorldEntity* toArray(); 38 void debug(); 39 40 private: 41 struct listElement 42 { 43 listElement* prev; 44 WorldEntity* curr; 45 listElement* next; 46 }; 47 unsigned int size; 48 listElement* first; 49 listElement* last; 50 listElement* currentEl; 51 52 14 15 16 //! a list element of the tList, 17 template<class T> struct listElement 18 { 19 listElement* prev; //!< pointer to the previous listElement in the list 20 T* curr; //!< pointer to the list payload/container 21 listElement* next; //!< pointer to the next listElement 53 22 }; 54 23 55 56 57 template<class T> struct listElement 58 { 59 listElement* prev; 60 T* curr; 61 listElement* next; 62 }; 63 24 /** 25 \brief an iterator class 26 27 this enables the user to iterate through a list very easely 28 */ 64 29 template<class T> class tIterator 65 30 { … … 71 36 72 37 private: 73 listElement<T>* currentEl;74 listElement<T>* tmpEl;38 listElement<T>* currentEl; //!< pointer to the current list element in the iterator 39 listElement<T>* tmpEl; //!< temp listElemnt pointer 75 40 }; 76 41 77 42 43 /** 44 \brief iterator constructor 45 \param startElement: the first list element from the tList 46 47 normaly you will use it like this: 48 49 tIterator<char>* nameIterator = nameList->getIterator(); 50 char name* = nameIterator->nextElement(); 51 while( name != NULL) 52 { 53 PRINTF(3)("found name: %s in list\n", name); 54 name = nameIterator->nextElement(); 55 } 56 delete nameIterator; 57 */ 78 58 template<class T> 79 59 inline tIterator<T>::tIterator (listElement<T>* startElement) … … 84 64 85 65 66 /** 67 \brief the destructor 68 */ 86 69 template<class T> 87 70 inline tIterator<T>::~tIterator () … … 91 74 92 75 76 /** 77 \brief use it to iterate through the list 78 \returns next list element 79 */ 93 80 template<class T> 94 81 inline T* tIterator<T>::nextElement ()
Note: See TracChangeset
for help on using the changeset viewer.