Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4497 in orxonox.OLD for orxonox/trunk/src/util/common


Ignore:
Timestamp:
Jun 3, 2005, 11:15:53 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: documented the list class

File:
1 edited

Legend:

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

    r4488 r4497  
    9191
    9292
     93/**
     94   \brief the list template class
     95
     96   you will use this as a generic list for all type of objects
     97*/
    9398template<class T> class tList
    9499{
     
    99104  void add(T* entity);
    100105  void remove(T* entity);
    101   void destroy();
     106  void flush();
    102107  T* firstElement();
    103108  T* lastElement();
     
    112117
    113118 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
    118123};
    119124
    120125
     126/**
     127   \brief the constructor
     128*/
    121129template<class T>
    122130inline tList<T>::tList ()
     
    127135}
    128136
     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*/
    129144template<class T>
    130145inline tList<T>::~tList ()
     
    144159
    145160
     161/**
     162   \brief add an entity to the list
     163   \param entity: the entity to add
     164*/
    146165template<class T>
    147166inline void tList<T>::add(T* entity)
     
    161180
    162181
     182/**
     183   \brief remove an entity from the list
     184   \param entity: the entity to be removed
     185*/
    163186template<class T>
    164187inline void tList<T>::remove(T* entity)
     
    185208
    186209
    187 template<class T>
    188 inline void tList<T>::destroy()
     210/**
     211   \brief this will deletes the objects from the list
     212*/
     213template<class T>
     214inline void tList<T>::flush()
    189215{
    190216  this->currentEl = this->first;
     
    192218    {
    193219      listElement<T>* le = this->currentEl->next;
    194       //delete this->currentEl->curr;
     220      delete this->currentEl->curr;
    195221      delete this->currentEl;
    196222      this->currentEl = le;
     
    202228
    203229
     230/**
     231   \brief returns the first element of the list
     232   \returns first element
     233*/
    204234template<class T>
    205235inline T* tList<T>::firstElement()
     
    209239
    210240
     241/**
     242   \brief function returns the last element of the list
     243   \returns the last element
     244*/
    211245template<class T>
    212246inline T* tList<T>::lastElement()
     
    216250
    217251
     252/**
     253   \brief returns true if the list is empty
     254   \returns true if the list is empty
     255*/
    218256template<class T>
    219257inline bool tList<T>::isEmpty()
     
    223261
    224262
     263/**
     264   \brief this returns the number of elements in the list
     265   \returns number of elements
     266*/
    225267template<class T>
    226268inline int tList<T>::getSize()
     
    230272
    231273
    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*/
    244280template<class T>
    245281inline tIterator<T>* tList<T>::getIterator()
     
    250286
    251287
    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 
    263288
    264289/**
    265290   \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
    266293*/
    267294template<class T>
     
    282309
    283310
     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*/
    284317template<class T>
    285318T* tList<T>::toArray()
    286 {}
     319{
     320  return NULL;
     321}
    287322
    288323#endif /* _LIST_H */
Note: See TracChangeset for help on using the changeset viewer.