Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4488 in orxonox.OLD for orxonox/trunk/src/util/common/list.h


Ignore:
Timestamp:
Jun 3, 2005, 1:00:10 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: started cleaning up the list classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/common/list.h

    r4486 r4488  
    1212#endif
    1313
    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,
     17template<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
    5322};
    5423
    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*/
    6429template<class T> class tIterator
    6530{
     
    7136
    7237 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
    7540};
    7641
    7742
     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*/
    7858template<class T>
    7959inline tIterator<T>::tIterator (listElement<T>* startElement)
     
    8464
    8565
     66/**
     67   \brief the destructor
     68*/
    8669template<class T>
    8770inline tIterator<T>::~tIterator ()
     
    9174
    9275
     76/**
     77   \brief use it to iterate through the list
     78   \returns next list element
     79*/
    9380template<class T>
    9481inline T* tIterator<T>::nextElement ()
Note: See TracChangeset for help on using the changeset viewer.