Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5073 in orxonox.OLD for trunk/src/lib/util


Ignore:
Timestamp:
Aug 19, 2005, 1:06:28 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added new Function addFirst to list, that adds an entity at the beginning of the List

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/list.h

    r5068 r5073  
    131131
    132132  void add(T* entity);
     133  void addFirst(T* entity);
    133134  void remove(T* entity);
    134135  void removeLast();
     
    203204  if( unlikely(el->prev == NULL)) this->first = el; /* if first element */
    204205  else el->prev->next = el;
     206  this->size++;
     207}
     208
     209/**
     210 *  add an entity to the list
     211 * @param entity: the entity to add
     212 */
     213template<class T>
     214    inline void tList<T>::addFirst(T* entity)
     215{
     216  if( unlikely(entity == NULL)) return;
     217  listElement<T>* el = new listElement<T>;
     218  el->next = this->first;
     219  el->curr = entity;
     220  el->prev = NULL;
     221
     222  this->first = el;
     223
     224  if( unlikely(el->next == NULL)) this->first = el; /* if first element */
     225  else el->next->prev = el;
    205226  this->size++;
    206227}
Note: See TracChangeset for help on using the changeset viewer.