Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5110 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Aug 23, 2005, 11:07:40 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: changed the behaviour of the iterator.
Now it is soon possible to walk through a List from front and back, and tell the Iterator from where to seek

@patrick: i had to disable your Collision-Detection algorithms, because they had a seekElement inside, that i did not entirely grasp the meaning of….
trying to fix this now

Location:
trunk/src
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_detection/cd_engine.cc

    r5047 r5110  
    8080  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
    8181  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
    82   WorldEntity* entity1 = iterator1->nextElement();
     82  WorldEntity* entity1 = iterator1->firstElement();
    8383  WorldEntity* entity2 = iterator2->seekElement(entity1);
    8484  PRINTF(3)("checking for collisions\n");
    85   while( entity1 != NULL)
     85/*  while( entity1 != NULL)
    8686  {
    8787    if( likely(entity1 != this->terrain))
     
    101101    entity2 = iterator2->seekElement(entity1);
    102102
    103   }
     103  }*/
    104104  delete iterator1;
    105105  delete iterator2;
     
    133133
    134134  tIterator<WorldEntity>* iterator = entityList->getIterator();
    135   WorldEntity* entity = iterator->nextElement();
     135  WorldEntity* entity = iterator->firstElement();
    136136  while( entity != NULL)
    137137  {
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r5046 r5110  
    574574
    575575  iterator = partition1.getIterator();
    576   element = iterator->nextElement();
     576  element = iterator->firstElement();
    577577  index = 0;
    578578  while( element != NULL)
     
    592592
    593593  iterator = partition2.getIterator();
    594   element = iterator->nextElement();
     594  element = iterator->firstElement();
    595595  index = 0;
    596596  while( element != NULL)
  • trunk/src/lib/coord/p_node.cc

    r5108 r5110  
    7979{
    8080  tIterator<PNode>* iterator = this->children->getIterator();
    81   PNode* pn = iterator->nextElement();
     81  PNode* pn = iterator->firstElement();
    8282  while( pn != NULL)
    8383    {
     
    435435
    436436  tIterator<PNode>* iterator = this->children->getIterator();
    437   PNode* pn = iterator->nextElement();
     437  PNode* pn = iterator->firstElement();
    438438
    439439  while( pn != NULL)
     
    605605    {
    606606      tIterator<PNode>* iterator = this->children->getIterator();
    607       PNode* pn = iterator->nextElement();
     607      PNode* pn = iterator->firstElement();
    608608      while( pn != NULL)
    609609      {
     
    615615
    616616        pn->update(dt);
    617           //pn = this->children->nextElement();
    618617        pn = iterator->nextElement();
    619618      }
     
    656655    tIterator<PNode>* iterator = this->children->getIterator();
    657656      //PNode* pn = this->children->enumerate ();
    658     PNode* pn = iterator->nextElement();
     657    PNode* pn = iterator->firstElement();
    659658    while( pn != NULL)
    660659    {
     
    722721  if (depth >= 2 || depth == 0)
    723722  {
     723    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
     724
    724725    tIterator<PNode>* iterator = this->children->getIterator();
    725       //PNode* pn = this->children->enumerate ();
    726     Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
    727     PNode* pn = iterator->nextElement();
     726    PNode* pn = iterator->firstElement();
    728727    while( pn != NULL)
    729728    {
  • trunk/src/lib/graphics/importer/model.cc

    r4844 r5110  
    192192
    193193    tIterator<Material>* tmpIt = this->materialList->getIterator();
    194     Material* material = tmpIt->nextElement();
     194    Material* material = tmpIt->firstElement();
    195195  //! @todo do we really have to delete this material??
    196196    while(material)
     
    413413{
    414414  tIterator<Material>* tmpIt = this->materialList->getIterator();
    415   Material* material = tmpIt->nextElement();
     415  Material* material = tmpIt->firstElement();
    416416  while(material)
    417417    {
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5108 r5110  
    5555
    5656  tIterator<Element2D>* iterator = this->children->getIterator();
    57   Element2D* pn = iterator->nextElement();
     57  Element2D* pn = iterator->firstElement();
    5858  while( pn != NULL)
    5959  {
     
    479479{
    480480  tIterator<Element2D>* iterator = this->children->getIterator();
    481   Element2D* pn = iterator->nextElement();
     481  Element2D* pn = iterator->firstElement();
    482482
    483483  while( pn != NULL)
     
    687687  {
    688688    tIterator<Element2D>* iterator = this->children->getIterator();
    689     Element2D* pn = iterator->nextElement();
     689    Element2D* pn = iterator->firstElement();
    690690    while( pn != NULL)
    691691    {
     
    697697
    698698      pn->update2D(dt);
    699           //pn = this->children->nextElement();
    700699      pn = iterator->nextElement();
    701700    }
     
    735734  {
    736735    tIterator<Element2D>* iterator = this->children->getIterator();
    737     Element2D* pn = iterator->nextElement();
     736    Element2D* pn = iterator->firstElement();
    738737    while( pn != NULL)
    739738    {
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5078 r5110  
    105105  {
    106106    tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
    107     Element2D* elem = iterator->nextElement();
     107    Element2D* elem = iterator->firstElement();
    108108    while (elem != NULL)
    109109    {
     
    131131    {
    132132      tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
    133       Element2D* elem = iterator->nextElement();
     133      Element2D* elem = iterator->firstElement();
    134134      while (elem != NULL)
    135135      {
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r5075 r5110  
    253253  counter = 0;
    254254  iterator = listA->getIterator();
    255   tempTri = iterator->nextElement();
     255  tempTri = iterator->firstElement();
    256256  while( tempTri)
    257257  {
     
    262262  counter = 0;
    263263  iterator = listB->getIterator();
    264   tempTri = iterator->nextElement();
     264  tempTri = iterator->firstElement();
    265265  while( tempTri)
    266266  {
     
    271271  counter = 0;
    272272  iterator = listC->getIterator();
    273   tempTri = iterator->nextElement();
     273  tempTri = iterator->firstElement();
    274274  while( tempTri)
    275275  {
     
    280280  counter = 0;
    281281  iterator = listD->getIterator();
    282   tempTri = iterator->nextElement();
     282  tempTri = iterator->firstElement();
    283283  while( tempTri)
    284284  {
  • trunk/src/lib/graphics/text_engine.cc

    r5106 r5110  
    845845
    846846  tIterator<BaseObject>* textIterator = ClassList::getList(CL_TEXT)->getIterator();
    847   Text* text = dynamic_cast<Text*>(textIterator->nextElement());
     847  Text* text = dynamic_cast<Text*>(textIterator->firstElement());
    848848  while( text != NULL)
    849849    {
  • trunk/src/lib/lang/class_list.cc

    r5106 r5110  
    208208      {
    209209        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    210         BaseObject* enumBO = iterator->nextElement();
     210        BaseObject* enumBO = iterator->firstElement();
    211211        const char* tmpName;
    212212        while (enumBO != NULL)
     
    249249      {
    250250        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    251         BaseObject* enumBO = iterator->nextElement();
     251        BaseObject* enumBO = iterator->firstElement();
    252252        while (enumBO != NULL)
    253253        {
     
    362362        PRINT(0)("|  Listing Instances:\n");
    363363        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    364         BaseObject* enumBO = iterator->nextElement();
     364        BaseObject* enumBO = iterator->firstElement();
    365365        while (enumBO)
    366366        {
  • trunk/src/lib/particles/particle_engine.cc

    r4836 r5110  
    5353  // delete all remaining systems
    5454  tIterator<ParticleSystem>* sysIt = this->systemList->getIterator();
    55   ParticleSystem* tmpSys = sysIt->nextElement();
     55  ParticleSystem* tmpSys = sysIt->firstElement();
    5656  while(tmpSys)
    5757    {
     
    6464  // delete all remaining emitters
    6565  tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
    66   ParticleEmitter* tmpEmit = emitIt->nextElement();
     66  ParticleEmitter* tmpEmit = emitIt->firstElement();
    6767  while(tmpEmit)
    6868    {
     
    147147  // look, if we have already added this connection
    148148  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    149   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     149  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    150150  while(tmpConnection)
    151151    {
     
    178178  // remove any connections, that have this system within
    179179  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    180   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     180  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    181181  while(tmpConnection)
    182182    {
     
    199199  // remove any connections, that have this emitter within
    200200  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    201   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     201  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    202202  while(tmpConnection)
    203203    {
     
    224224  // look, if we have already added this connection
    225225  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    226   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     226  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    227227  while(tmpConnection)
    228228    {
     
    260260  // ticks all the ParticleSystems
    261261  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    262   ParticleSystem* tmpSys = tmpIt->nextElement();
     262  ParticleSystem* tmpSys = tmpIt->firstElement();
    263263  while(tmpSys)
    264264    {
     
    270270  // add new Particles to each System connected to an Emitter.
    271271  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    272   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     272  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    273273  while(tmpConnection)
    274274    {
     
    285285{
    286286  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    287   ParticleSystem* tmpSys = tmpIt->nextElement();
     287  ParticleSystem* tmpSys = tmpIt->firstElement();
    288288  while(tmpSys)
    289289    {
     
    302302{
    303303  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    304   ParticleSystem* tmpSys = tmpIt->nextElement();
     304  ParticleSystem* tmpSys = tmpIt->firstElement();
    305305  while(tmpSys)
    306306    {
     
    324324  int count = 0;
    325325  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    326   ParticleSystem* tmpSys = tmpIt->nextElement();
     326  ParticleSystem* tmpSys = tmpIt->firstElement();
    327327  while(tmpSys)
    328328    {
     
    346346{
    347347  tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    348   ParticleEmitter* tmpEmit = tmpIt->nextElement();
     348  ParticleEmitter* tmpEmit = tmpIt->firstElement();
    349349  while(tmpEmit)
    350350    {
     
    369369  int count = 0;
    370370  tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    371   ParticleEmitter* tmpEmit = tmpIt->nextElement();
     371  ParticleEmitter* tmpEmit = tmpIt->firstElement();
    372372  while(tmpEmit)
    373373    {
     
    402402
    403403    tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    404     ParticleConnection* tmpConnection = tmpConIt->nextElement();
     404    ParticleConnection* tmpConnection = tmpConIt->firstElement();
    405405    while(tmpConnection)
    406406    {
     
    414414  {
    415415    tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    416     ParticleSystem* tmpSys = tmpIt->nextElement();
     416    ParticleSystem* tmpSys = tmpIt->firstElement();
    417417    while(tmpSys)
    418418    {
     
    429429  {
    430430    tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    431     ParticleEmitter* tmpEmit = tmpIt->nextElement();
     431    ParticleEmitter* tmpEmit = tmpIt->firstElement();
    432432    while(tmpEmit)
    433433    {
  • trunk/src/lib/physics/physics_engine.cc

    r4836 r5110  
    5252{
    5353  // delete all PhysicsConnections that are still in existence
    54   tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    55   PhysicsConnection* enumPC = itPC->nextElement();
    56   while (enumPC)
    57   {
    58     delete enumPC;
    59     enumPC = itPC->nextElement();
    60   }
    61   delete itPC;
    62   delete this->connections;
    63 
    64   // delete all PhysicsInterfaces, still in existence (this could be dangerous)
    65   tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
    66   PhysicsInterface* enumPI = itPI->nextElement();
    67   while (enumPI)
    68   {
    69     delete enumPI;
    70 
    71     enumPI = itPI->nextElement();
    72   }
    73   delete itPI;
    74   delete this->interfaces;
    75 
    76   // delete all PhysicsFields, still in existence (this could be dangerous)
    77   tIterator<Field>* itF = this->fields->getIterator();
    78   Field* enumF = itF->nextElement();
    79   while (enumF)
    80   {
    81     delete enumF;
    82 
    83     enumF = itF->nextElement();
    84   }
    85   delete itF;
    86   delete this->fields;
     54//   tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
     55//   PhysicsConnection* enumPC = itPC->firstElement();
     56//   while (enumPC)
     57//   {
     58//     delete enumPC;
     59//     enumPC = itPC->nextElement();
     60//   }
     61//   delete itPC;
     62//   delete this->connections;
     63//
     64//   // delete all PhysicsInterfaces, still in existence (this could be dangerous)
     65//   tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
     66//   PhysicsInterface* enumPI = itPI->firstElement();
     67//   while (enumPI)
     68//   {
     69//     delete enumPI;
     70//
     71//     enumPI = itPI->nextElement();
     72//   }
     73//   delete itPI;
     74//   delete this->interfaces;
     75//
     76//   // delete all PhysicsFields, still in existence (this could be dangerous)
     77//   tIterator<Field>* itF = this->fields->getIterator();
     78//   Field* enumF = itF->firstElement();
     79//   while (enumF)
     80//   {
     81//     delete enumF;
     82//
     83//     enumF = itF->nextElement();
     84//   }
     85//   delete itF;
     86//   delete this->fields;
    8787
    8888
     
    163163{
    164164  tIterator<PhysicsInterface>* tmpIt = interfaces->getIterator();
    165   PhysicsInterface* tmpInt = tmpIt->nextElement();
     165  PhysicsInterface* tmpInt = tmpIt->firstElement();
    166166  while(tmpInt)
    167167  {
     
    206206{
    207207  tIterator<Field>* tmpIt = fields->getIterator();
    208   Field* tmpField = tmpIt->nextElement();
     208  Field* tmpField = tmpIt->firstElement();
    209209  while(tmpField)
    210210  {
     
    251251{
    252252  tIterator<PhysicsConnection>* tmpIt = connections->getIterator();
    253   PhysicsConnection* tmpConn = tmpIt->nextElement();
     253  PhysicsConnection* tmpConn = tmpIt->firstElement();
    254254  while(tmpConn)
    255255  {
     
    278278  meaning let the fields work */
    279279  tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    280   PhysicsConnection* enumPC = itPC->nextElement();
     280  PhysicsConnection* enumPC = itPC->firstElement();
    281281  while (enumPC)
    282282    {
     
    289289  /* actually tick all the PhysicsInterfaces. Move the objects around */
    290290  tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
    291   PhysicsInterface* enumPI = itPI->nextElement();
     291  PhysicsInterface* enumPI = itPI->firstElement();
    292292  while (enumPI)
    293293    {
  • trunk/src/lib/physics/physics_interface.cc

    r4836 r5110  
    6868
    6969    tIterator<PNode>* iterator = massCalcPNode->children->getIterator();
    70     PNode* pn = iterator->nextElement();
     70    PNode* pn = iterator->firstElement();
    7171    while( pn != NULL)
    7272    {
  • trunk/src/lib/sound/sound_engine.cc

    r4986 r5110  
    215215  {
    216216    tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    217     SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     217    SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    218218    while (enumSource)
    219219    {
     
    228228  {
    229229    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    230     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     230    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    231231    while (enumBuffer)
    232232    {
     
    298298  // look if there are any sources that have the buffer still loaded
    299299  tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    300   SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     300  SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    301301  while (enumSource)
    302302    {
     
    345345  {
    346346    tIterator<BaseObject>* iterator = this->sourceList->getIterator();
    347     SoundSource* enumSource = (SoundSource*)iterator->nextElement();
     347    SoundSource* enumSource = (SoundSource*)iterator->firstElement();
    348348    while (enumSource)
    349349    {
     
    373373  {
    374374    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    375     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     375    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    376376    while (enumBuffer)
    377377    {
    378378      tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    379       SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     379      SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    380380      while (enumSource)
    381381      {
     
    401401  {
    402402    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    403     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     403    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    404404    while (enumBuffer)
    405405    {
     
    419419  {
    420420    tIterator<BaseObject>* Iterator = this->sourceList->getIterator();
    421     SoundSource* enumSource = (SoundSource*)Iterator->nextElement();
     421    SoundSource* enumSource = (SoundSource*)Iterator->firstElement();
    422422    while (enumSource)
    423423    {
  • trunk/src/lib/util/ini_parser.cc

    r5031 r5110  
    5858  {
    5959    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    60     IniSection* sectionEnum = sectionIt->nextElement();
     60    IniSection* sectionEnum = sectionIt->firstElement();
    6161    while (sectionEnum)
    6262    {
    6363      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    64       IniEntry* entryEnum = entryIt->nextElement();
     64      IniEntry* entryEnum = entryIt->firstElement();
    6565      while (entryEnum)
    6666      {
     
    192192    {
    193193      tIterator<IniSection>* sectionIt = this->sections->getIterator();
    194       IniSection* sectionEnum = sectionIt->nextElement();
     194      IniSection* sectionEnum = sectionIt->firstElement();
    195195      while (sectionEnum)
    196196      {
     
    198198
    199199        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    200         IniEntry* entryEnum = entryIt->nextElement();
     200        IniEntry* entryEnum = entryIt->firstElement();
    201201        while (entryEnum)
    202202        {
     
    246246{
    247247  tIterator<IniSection>* sectionIt = this->sections->getIterator();
    248   IniSection* sectionEnum = sectionIt->nextElement();
     248  IniSection* sectionEnum = sectionIt->firstElement();
    249249  while (sectionEnum)
    250250  {
     
    347347  {
    348348    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    349     IniSection* sectionEnum = sectionIt->nextElement();
     349    IniSection* sectionEnum = sectionIt->firstElement();
    350350    while (sectionEnum)
    351351    {
     
    395395  {
    396396    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    397     IniSection* sectionEnum = sectionIt->nextElement();
     397    IniSection* sectionEnum = sectionIt->firstElement();
    398398    while (sectionEnum)
    399399    {
     
    401401      {
    402402        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    403         IniEntry* entryEnum = entryIt->nextElement();
     403        IniEntry* entryEnum = entryIt->firstElement();
    404404        while (entryEnum)
    405405        {
     
    452452  {
    453453    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    454     IniSection* sectionEnum = sectionIt->nextElement();
     454    IniSection* sectionEnum = sectionIt->firstElement();
    455455    while (sectionEnum)
    456456    {
     
    458458
    459459      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    460       IniEntry* entryEnum = entryIt->nextElement();
     460      IniEntry* entryEnum = entryIt->firstElement();
    461461      while (entryEnum)
    462462      {
  • trunk/src/lib/util/list.h

    r5103 r5110  
    1212#endif
    1313
    14 
     14template<class T> class tIterator;
    1515
    1616//! a list element of the tList,
     
    2323
    2424/**
    25  *  an iterator class
    26 
    27    this enables the user to iterate through a list very easely
    28 */
    29 template<class T> class tIterator
    30 {
    31  public:
    32   tIterator(listElement<T>* startElement);
    33   ~tIterator();
    34 
    35   T* nextElement();
    36   T* seekElement(T* element);
    37 
    38  private:
    39   listElement<T>*    currentEl;                      //!< pointer to the current list element in the iterator
    40   listElement<T>*    tmpEl;                          //!< temp listElemnt pointer
    41   listElement<T>*    startElement;                   //!< pointer to the start of the list
    42 };
    43 
    44 
    45 /**
    46  *  iterator constructor
    47  * @param startElement:  the first list element from the tList
    48 
    49    normaly you will use it like this:
    50 
    51    tIterator<char>* nameIterator = nameList->getIterator();
    52    char name* = nameIterator->nextElement();
    53    while( name != NULL)
    54    {
    55      PRINTF(3)("found name: %s in list\n", name);
    56      name = nameIterator->nextElement();
    57    }
    58    delete nameIterator;
    59 */
    60 template<class T>
    61 inline tIterator<T>::tIterator (listElement<T>* startElement)
    62 {
    63   this->currentEl = startElement;
    64   this->tmpEl = NULL;
    65   this->startElement = startElement;
    66 }
    67 
    68 
    69 /**
    70  *  the destructor
    71 */
    72 template<class T>
    73 inline tIterator<T>::~tIterator ()
    74 {
    75   this->currentEl = NULL;
    76 }
    77 
    78 
    79 /**
    80  *  use it to iterate through the list
    81  * @returns next list element
    82 */
    83 template<class T>
    84 inline T* tIterator<T>::nextElement ()
    85 {
    86   if( this->currentEl == NULL)
    87     return NULL;
    88 
    89   this->tmpEl = this->currentEl;
    90   this->currentEl = this->currentEl->next;
    91   return this->tmpEl->curr;
    92 }
    93 
    94 /**
    95  *  gets the element after the selected one, sets the iterator to this point in the list
    96  * @param element the element to seek
    97  * @returns next list element
    98 
    99   Attention: if you seek an element, the iterator pointer will point to the NEXT listelement after the argument!
    100  */
    101 template<class T>
    102 inline T* tIterator<T>::seekElement (T* element)
    103 {
    104   for(this->tmpEl = this->startElement; this->tmpEl != NULL; this->tmpEl = this->tmpEl->next)
    105   {
    106     if( unlikely(this->tmpEl->curr == element))
    107     {
    108       if( this->tmpEl->next != NULL)
    109       {
    110         this->currentEl = this->tmpEl->next->next;
    111         return this->tmpEl->next->curr;
    112       }
    113       return NULL;
    114     }
    115   }
    116   return NULL;
    117 }
    118 
    119 
    120 
    121 /**
    12225 *  the list template class
    12326
     
    12629template<class T> class tList
    12730{
     31  friend class tIterator<T>;
     32
    12833 public:
    12934  tList ();
     
    374279inline tIterator<T>* tList<T>::getIterator() const
    375280{
    376   tIterator<T>* iterator = new tIterator<T>(this->first);
    377   return iterator;
     281  return new tIterator<T>(this);
    378282}
    379283
     
    414318}
    415319
     320
     321
     322
     323/**
     324 *  an iterator class
     325
     326   this enables the user to iterate through a list very easely
     327 */
     328template<class T> class tIterator
     329{
     330  public:
     331    tIterator(const tList<T>* list);
     332    ~tIterator();
     333
     334    T* firstElement();
     335    T* nextElement();
     336    T* seekElement(T* element);
     337
     338  private:
     339    listElement<T>*    currentEl;                      //!< pointer to the current list element in the iterator
     340    listElement<T>*    tmpEl;                          //!< temp listElemnt pointer
     341    const tList<T>*    list;                           //!< The List, that we want to iterate through
     342};
     343
     344
     345/**
     346 *  iterator constructor
     347 * @param startElement:  the first list element from the tList
     348
     349   normaly you will use it like this:
     350
     351   tIterator<char>* nameIterator = nameList->getIterator();
     352                char name* = nameIterator->nextElement();
     353                while( name != NULL)
     354{
     355                PRINTF(3)("found name: %s in list\n", name);
     356                name = nameIterator->nextElement();
     357}
     358                delete nameIterator;
     359 */
     360                template<class T>
     361                inline tIterator<T>::tIterator (const tList<T>* list)
     362{
     363  this->currentEl = list->first;
     364  this->tmpEl = NULL;
     365  this->list = list;
     366}
     367
     368
     369/**
     370 *  the destructor
     371 */
     372template<class T>
     373    inline tIterator<T>::~tIterator ()
     374{
     375  this->currentEl = NULL;
     376}
     377
     378template<class T>
     379    inline T* tIterator<T>::firstElement ()
     380{
     381  this->currentEl = this->list->first;
     382  if (this->currentEl == NULL)
     383    return NULL;
     384  else
     385    return this->currentEl->curr;
     386}
     387
     388
     389/**
     390 *  use it to iterate through the list
     391 * @returns next list element
     392 */
     393template<class T>
     394    inline T* tIterator<T>::nextElement ()
     395{
     396  if( this->currentEl == NULL || this->currentEl->next == NULL)
     397  {
     398    this->currentEl = NULL;
     399    return NULL;
     400  }
     401
     402  this->currentEl = this->currentEl->next;
     403  return this->currentEl->curr;
     404}
     405
     406/**
     407 *  gets the element after the selected one, sets the iterator to this point in the list
     408 * @param element the element to seek
     409 * @returns next list element
     410
     411  Attention: if you seek an element, the iterator pointer will point to the NEXT listelement after the argument!
     412 */
     413template<class T>
     414    inline T* tIterator<T>::seekElement (T* element)
     415{
     416  for(this->tmpEl = this->list->first; this->tmpEl != NULL; this->tmpEl = this->tmpEl->next)
     417  {
     418    if( unlikely(this->tmpEl->curr == element))
     419    {
     420      if( this->tmpEl->next != NULL)
     421      {
     422        this->currentEl = this->tmpEl;
     423        return this->tmpEl->next->curr;
     424      }
     425      return NULL;
     426    }
     427  }
     428  return NULL;
     429}
     430
    416431#endif /* _LIST_H */
  • trunk/src/story_entities/campaign.cc

    r4836 r5110  
    154154    */
    155155    tIterator<StoryEntity>* it = this->entities->getIterator();
    156     se = it->nextElement();
     156    se = it->firstElement();
    157157    while( se != NULL)
    158158    {
     
    284284
    285285  tIterator<StoryEntity>* iterator = this->entities->getIterator();
    286   StoryEntity* entity = iterator->nextElement();
     286  StoryEntity* entity = iterator->firstElement();
    287287  while( entity != NULL)
    288288    {
  • trunk/src/story_entities/world.cc

    r5098 r5110  
    864864
    865865      tIterator<WorldEntity>* iterator = this->entities->getIterator();
    866       WorldEntity* entity = iterator->nextElement();
     866      WorldEntity* entity = iterator->firstElement();
    867867      while( entity != NULL)
    868868        {
     
    951951  glLoadIdentity();
    952952  tIterator<WorldEntity>* iterator = this->entities->getIterator();
    953   entity = iterator->nextElement();
     953  entity = iterator->firstElement();
    954954  while( entity != NULL )
    955955  {
  • trunk/src/subprojects/benchmark.cc

    r4942 r5110  
    352352      /*give list out */
    353353      tIterator<char>* iterator = list->getIterator();
    354       name = iterator->nextElement();
     354      name = iterator->firstElement();
    355355      printf("  List Elements: \t\t");
    356356      while( name != NULL)
     
    373373      /*give list out */
    374374      iterator = list->getIterator();
    375       name = iterator->nextElement();
     375      name = iterator->firstElement();
    376376      printf("  List Elements: \t\t");
    377377      while( name != NULL)
     
    433433      /*give list out */
    434434      iterator = list->getIterator();
    435       name = iterator->nextElement();
     435      name = iterator->firstElement();
    436436      printf("  List Elements: \t\t");
    437437      while( name != NULL)
  • trunk/src/subprojects/collision_detection/collision_detection.cc

    r5034 r5110  
    235235
    236236  tIterator<WorldEntity>* iterator = entityList->getIterator();
    237   WorldEntity* entity = iterator->nextElement();
     237  WorldEntity* entity = iterator->firstElement();
    238238  while( entity != NULL)
    239239  {
     
    251251
    252252  tIterator<WorldEntity>* iterator = entityList->getIterator();
    253   WorldEntity* entity = iterator->nextElement();
     253  WorldEntity* entity = iterator->firstElement();
    254254  while( entity != NULL)
    255255  {
  • trunk/src/util/animation/animation3d.cc

    r5062 r5110  
    5858  // delete all the KeyFrames
    5959  tIterator<KeyFrame3D>* itKF = keyFrameList->getIterator();
    60   KeyFrame3D*  enumKF = itKF->nextElement();
     60  KeyFrame3D*  enumKF = itKF->firstElement();
    6161  while (enumKF)
    6262    {
  • trunk/src/util/animation/animation_player.cc

    r4836 r5110  
    8686  // deleting the Animation List AND all the elements of the List
    8787  tIterator<Animation>* animIt = this->animationList->getIterator();
    88   Animation* anim = animIt->nextElement();
     88  Animation* anim = animIt->firstElement();
    8989  while( anim != NULL)
    9090    {
     
    109109      // iterate through all the animations and tick them.
    110110      tIterator<Animation>* animIt = this->animationList->getIterator();
    111       Animation* anim = animIt->nextElement();
     111      Animation* anim = animIt->firstElement();
    112112      while( anim != NULL)
    113113        {
     
    147147{
    148148  tIterator<Animation>* animIt = this->animationList->getIterator();
    149   Animation* anim = animIt->nextElement();
     149  Animation* anim = animIt->firstElement();
    150150  while( anim != NULL)
    151151    {
     
    176176  // Per ANIMATION DEBUG
    177177  tIterator<Animation>* animIt = this->animationList->getIterator();
    178   Animation* anim = animIt->nextElement();
     178  Animation* anim = animIt->firstElement();
    179179  while( anim != NULL)
    180180    {
  • trunk/src/util/animation/t_animation.h

    r5039 r5110  
    108108  // delete all the KeyFrames
    109109  tIterator<KeyFrameF>* itKF = keyFrameList->getIterator();
    110   KeyFrameF*  enumKF = itKF->nextElement();
     110  KeyFrameF*  enumKF = itKF->firstElement();
    111111  while (enumKF)
    112112    {
  • trunk/src/util/garbage_collector.cc

    r4979 r5110  
    156156//
    157157//   tIterator<WorldEntity>* iterator = list->getIterator();
    158 //   WorldEntity* entity = iterator->nextElement();
     158//   WorldEntity* entity = iterator->firstElement();
    159159//   while( entity != NULL)
    160160//     {
  • trunk/src/util/loading/load_param.cc

    r5102 r5110  
    295295
    296296  tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
    297   LoadParamDescription* enumParamDesc = iterator->nextElement();
     297  LoadParamDescription* enumParamDesc = iterator->firstElement();
    298298  while (enumParamDesc)
    299299    {
     
    314314{
    315315  tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    316   LoadClassDescription* enumClassDesc = iterator->nextElement();
     316  LoadClassDescription* enumClassDesc = iterator->firstElement();
    317317  while (enumClassDesc)
    318318    {
     
    336336{
    337337  tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
    338   LoadParamDescription* enumParamDesc = iterator->nextElement();
     338  LoadParamDescription* enumParamDesc = iterator->firstElement();
    339339  while (enumParamDesc)
    340340    {
     
    362362  PRINT(3)(" Listing all the Loadable Options (loaded since Game started).\n\n");
    363363  tIterator<LoadClassDescription>* classIT = LoadClassDescription::classList->getIterator();
    364   LoadClassDescription* enumClassDesc = classIT->nextElement();
     364  LoadClassDescription* enumClassDesc = classIT->firstElement();
    365365  while (enumClassDesc)
    366366    {
    367367      PRINT(3)("<%s>\n", enumClassDesc->className);
    368368      tIterator<LoadParamDescription>* paramIT = enumClassDesc->paramList->getIterator();
    369       LoadParamDescription* enumParamDesc = paramIT->nextElement();
     369      LoadParamDescription* enumParamDesc = paramIT->firstElement();
    370370      while (enumParamDesc)
    371371        {
     
    394394
    395395  tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    396   LoadClassDescription* enumClassDesc = iterator->nextElement();
     396  LoadClassDescription* enumClassDesc = iterator->firstElement();
    397397  while (enumClassDesc)
    398398  {
     
    412412// {
    413413//   tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    414 //   LoadClassDescription* enumClassDesc = iterator->nextElement();
     414//   LoadClassDescription* enumClassDesc = iterator->firstElement();
    415415//   while (enumClassDesc)
    416416//   {
  • trunk/src/util/resource_manager.cc

    r5101 r5110  
    7474  // deleting the Directorie Lists
    7575  tIterator<char>* tmpIt = imageDirs->getIterator();
    76   char* tmpDir = tmpIt->nextElement();
     76  char* tmpDir = tmpIt->firstElement();
    7777  while(tmpDir)
    7878    {
     
    144144      // check if the Directory has been added before
    145145      tIterator<char>* tmpImageDirs = imageDirs->getIterator();
    146       char* tmpDir = tmpImageDirs->nextElement();
     146      char* tmpDir = tmpImageDirs->firstElement();
    147147      while(tmpDir)
    148148        {
     
    363363            {
    364364              tIterator<char>* iterator = imageDirs->getIterator();
    365               tmpDir = iterator->nextElement();
    366               //tmpDir = imageDirs->enumerate();
     365              tmpDir = iterator->firstElement();
    367366              while(tmpDir)
    368367                {
     
    492491{
    493492  tIterator<Resource>* iterator = resourceList->getIterator();
    494   Resource* enumRes = iterator->nextElement();
     493  Resource* enumRes = iterator->firstElement();
    495494  while (enumRes)
    496495    {
     
    521520  //  Resource* enumRes = resourceList->enumerate();
    522521  tIterator<Resource>* iterator = resourceList->getIterator();
    523   Resource* enumRes = iterator->nextElement();
     522  Resource* enumRes = iterator->firstElement();
    524523  while (enumRes)
    525524    {
     
    603602  //  Resource* enumRes = resourceList->enumerate();
    604603  tIterator<Resource>* iterator = resourceList->getIterator();
    605   Resource* enumRes = iterator->nextElement();
     604  Resource* enumRes = iterator->firstElement();
    606605  while (enumRes)
    607606    {
     
    799798  PRINT(0)(" List of Image-Directories: ");
    800799  tIterator<char>* tmpIt = imageDirs->getIterator();
    801   char* tmpDir = tmpIt->nextElement();
     800  char* tmpDir = tmpIt->firstElement();
    802801  while(tmpDir)
    803802    {
     
    810809  PRINT(0)("List of all stored Resources:\n");
    811810  tIterator<Resource>* iterator = resourceList->getIterator();
    812   Resource* enumRes = iterator->nextElement();
     811  Resource* enumRes = iterator->firstElement();
    813812  while (enumRes)
    814813    {
  • trunk/src/util/shell.cc

    r5108 r5110  
    9191  // delete all the Chars in the Buffers
    9292  tIterator<char>* charIterator = this->buffer->getIterator();
    93   char* charElem = charIterator->nextElement();
     93  char* charElem = charIterator->firstElement();
    9494  while (charElem != NULL)
    9595  {
     
    191191  // delete all the Chars in the Buffers
    192192  tIterator<char>* charIterator = this->buffer->getIterator();
    193   char* charElem = charIterator->nextElement();
     193  char* charElem = charIterator->firstElement();
    194194
    195195  while (charElem != NULL)
     
    289289{
    290290  tIterator<char>* charIterator = this->buffer->getIterator();
    291   char* charElem = charIterator->nextElement();
     291  char* charElem = charIterator->firstElement();
    292292
    293293  int i = 1;
     
    606606    addLength = strlen(addString);
    607607  tIterator<const char>* charIterator = stringList->getIterator();
    608   const char* charElem = charIterator->nextElement();
     608  const char* charElem = charIterator->firstElement();
    609609  while (charElem != NULL)
    610610  {
     
    655655
    656656  tIterator<const char>* iterator = inputList->getIterator();
    657   const char* enumString = iterator->nextElement();
     657  const char* enumString = iterator->firstElement();
    658658  while (enumString != NULL)
    659659  {
     
    687687
    688688  tIterator<BaseObject>* iterator = inputList->getIterator();
    689   BaseObject* enumBO = iterator->nextElement();
     689  BaseObject* enumBO = iterator->firstElement();
    690690  while (enumBO != NULL)
    691691  {
  • trunk/src/util/track/track_manager.cc

    r5079 r5110  
    7979    {
    8080      tIterator<TrackElement>* iterator = this->children->getIterator();
    81       TrackElement* enumElem = iterator->nextElement();
     81      TrackElement* enumElem = iterator->firstElement();
    8282      while (enumElem)
    8383        {
     
    104104    {
    105105      tIterator<TrackElement>* iterator = this->children->getIterator();
    106       TrackElement* enumElem = iterator->nextElement();
     106      TrackElement* enumElem = iterator->firstElement();
    107107      TrackElement* tmpElem;
    108108      while (enumElem)
     
    133133    {
    134134      tIterator<TrackElement>* iterator = this->children->getIterator();
    135       TrackElement* enumElem = iterator->nextElement();
     135      TrackElement* enumElem = iterator->firstElement();
    136136      TrackElement* tmpElem;
    137137      while (enumElem)
     
    179179    {
    180180      tIterator<TrackElement>* iterator = this->children->getIterator();
    181       TrackElement* enumElem = iterator->nextElement();
     181      TrackElement* enumElem = iterator->firstElement();
    182182      while (enumElem)
    183183        {
     
    206206
    207207  tIterator<TrackElement>* iterator = this->children->getIterator();
    208   TrackElement* enumElem = iterator->nextElement();
     208  TrackElement* enumElem = iterator->firstElement();
    209209  for (int i = 0; i < childCount; i++)
    210210    enumElem = iterator->nextElement();
     
    234234      //TrackElement* enumElem = this->children->enumerate();
    235235      tIterator<TrackElement>* iterator = this->children->getIterator();
    236       TrackElement* enumElem = iterator->nextElement();
     236      TrackElement* enumElem = iterator->firstElement();
    237237      while (enumElem)
    238238        {
     
    331331  //TrackElement* enumElem = this->children->enumerate();
    332332  tIterator<TrackElement>* iterator = this->children->getIterator();
    333   TrackElement* enumElem = iterator->nextElement();
     333  TrackElement* enumElem = iterator->firstElement();
    334334  while (enumElem)
    335335    {
     
    975975      //TrackElement* enumElem = firstJoint->children->enumerate();
    976976      tIterator<TrackElement>* iterator = firstJoint->children->getIterator();
    977       TrackElement* enumElem = iterator->nextElement();
     977      TrackElement* enumElem = iterator->firstElement();
    978978      while (enumElem)
    979979        {
     
    10011001        {
    10021002          tIterator<TrackElement>* iterator = tmpElem->children->getIterator();
    1003           TrackElement* enumElem = iterator->nextElement();
     1003          TrackElement* enumElem = iterator->firstElement();
    10041004          //TrackElement* enumElem = tmpElem->children->enumerate();
    10051005          while (enumElem)
Note: See TracChangeset for help on using the changeset viewer.