Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7162 in orxonox.OLD for trunk/src/lib/lang


Ignore:
Timestamp:
Feb 18, 2006, 3:58:03 PM (19 years ago)
Author:
bensch
Message:

using vector instead of list in classList

Location:
trunk/src/lib/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/class_list.cc

    r7125 r7162  
    5353
    5454//! a List of all known Classes.
    55 std::list<ClassList>* ClassList::classList = NULL;
     55std::vector<ClassList>* ClassList::classList = NULL;
    5656
    5757//! a List of all strings of all classes, that have registered so far.
     
    7070{
    7171  if (unlikely(classList == NULL))
    72     ClassList::classList = new list<ClassList>();
     72    ClassList::classList = new std::vector<ClassList>();
    7373
    7474  PRINTF(5)("subscribe a '%s'\n", className );
     
    9494void ClassList::removeFromClassList(BaseObject* objectPointer)
    9595{
    96   list<ClassList>::iterator cl;
    97   for(cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    98   {
    99     if (objectPointer->isA((*cl).classID))
    100     {
    101       std::list<BaseObject*>::iterator bo = std::find ((*cl).objectList.begin(), (*cl).objectList.end(), objectPointer);
    102       if (bo != (*cl).objectList.end())
    103           (*cl).objectList.erase(bo);
     96  for(unsigned int cl= 0; cl < ClassList::classList->size(); cl++)
     97  {
     98    if (objectPointer->isA((*ClassList::classList)[cl].classID))
     99    {
     100      std::list<BaseObject*>::iterator bo =
     101          std::find ((*ClassList::classList)[cl].objectList.begin(),
     102                       (*ClassList::classList)[cl].objectList.end(),
     103                     objectPointer);
     104      if (bo != (*ClassList::classList)[cl].objectList.end())
     105        (*ClassList::classList)[cl].objectList.erase(bo);
    104106    }
    105107  }
     
    119121      ClassList::classNames.clear();
    120122
    121       list<ClassList>::const_iterator cl;
    122       for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    123         ClassList::classNames.push_back((*cl).className);
     123      for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++)
     124        ClassList::classNames.push_back((*ClassList::classList)[cl].className);
    124125  }
    125126
     
    181182ClassList* ClassList::getClassList(ClassID classID)
    182183{
    183   std::list<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), classID);
     184  std::vector<ClassList>::iterator classIT = find (ClassList::classList->begin(), ClassList::classList->end(), classID);
    184185  return (likely(classIT != classList->end()))? &(*classIT) : NULL;
    185186}
     
    195196  if (className == NULL)
    196197    return NULL;
    197   std::list<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className);
     198  std::vector<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className);
    198199  return (likely(classIT != classList->end()))? &(*classIT) : NULL;
    199200}
     
    222223  else
    223224  {
    224     list<ClassList>::iterator cl;
    225     for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    226     {
    227       std::list<BaseObject*>::iterator bo;
    228       for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)
     225    std::list<BaseObject*>::iterator bo;
     226    for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++)
     227    {
     228      for (bo = (*ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++)
    229229        if ((*bo)->getName() != NULL && !strcmp((*bo)->getName(), objectName))
    230230          return (*bo);
     
    255255  else
    256256  {
    257     list<ClassList>::iterator cl;
    258     for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    259     {
    260       std::list<BaseObject*>::const_iterator bo = find ((*cl).objectList.begin(), (*cl).objectList.end(), object);
    261       if (bo != (*cl).objectList.end())
     257    for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++)
     258    {
     259      std::list<BaseObject*>::const_iterator bo =
     260          find ((*ClassList::classList)[cl].objectList.begin(),
     261          (*ClassList::classList)[cl].objectList.end(), object);
     262      if (bo != (*ClassList::classList)[cl].objectList.end())
    262263        return true;
    263264    }
     
    272273void ClassList::whatIs(const BaseObject* object)
    273274{
    274   list<ClassList>::iterator cl;
    275   for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    276     if (object->isA((*cl).classID))
    277   {
    278     PRINT(0)("=%s::0x%.8X=-", (*cl).className, (*cl).classID);
     275  for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++)
     276    if (object->isA((*ClassList::classList)[cl].classID))
     277  {
     278    PRINT(0)("=%s::0x%.8X=-",
     279    (*ClassList::classList)[cl].className,
     280    (*ClassList::classList)[cl].classID);
    279281  }
    280282}
     
    333335  unsigned int lenCount = 0;
    334336
    335   list<ClassList>::iterator cl;
    336   for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++)
    337   {
    338     if ((debugLevel >= 1 || (*cl).objectList.size() > 0 ) &&
    339          (classID == CL_NULL || unlikely (classID == (*cl).classID)))
     337  for (unsigned int cl = 0; cl < ClassList::classList->size(); cl++)
     338  {
     339    if ((debugLevel >= 1 || (*ClassList::classList)[cl].objectList.size() > 0 ) &&
     340         (classID == CL_NULL || unlikely (classID == (*ClassList::classList)[cl].classID)))
    340341    {
    341342      lenCount = 1;
    342       while (pow(10, lenCount) <= (*cl).objectList.size())
     343      while (pow(10, lenCount) <= (*ClassList::classList)[cl].objectList.size())
    343344        ++lenCount;
    344       for (int i=0; i < 30-strlen((*cl).className) - lenCount; i++)
     345      for (int i=0; i < 30-strlen((*ClassList::classList)[cl].className) - lenCount; i++)
    345346        (niceString[i]) = ' ';
    346       niceString[30-strlen((*cl).className) - lenCount] = '\0';
    347 
    348       PRINT(0)("| CLASS %s::%s %d\n", (*cl).className, niceString, (*cl).objectList.size());
    349 
    350       if (debugLevel >=2 && (*cl).objectList.size() > 0)
     347      niceString[30-strlen((*ClassList::classList)[cl].className) - lenCount] = '\0';
     348
     349      PRINT(0)("| CLASS %s::%s %d\n", (*ClassList::classList)[cl].className, niceString,
     350            (*ClassList::classList)[cl].objectList.size());
     351
     352      if (debugLevel >=2 && (*ClassList::classList)[cl].objectList.size() > 0)
    351353      {
    352354        PRINT(0)("|  Listing Instances:\n");
    353355        list<BaseObject*>::const_iterator bo;
    354         for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++)
     356        for (bo = (*ClassList::classList)[cl].objectList.begin(); bo != (*ClassList::classList)[cl].objectList.end(); bo++)
    355357        {
    356358          PRINT(0)("|   %s::%s::(0x%.8X->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo)->getClassID(), (*bo));
  • trunk/src/lib/lang/class_list.h

    r6280 r7162  
    1010#include "class_id.h"
    1111#include <list>
     12#include <vector>
    1213#ifndef NULL
    1314#define NULL     0    //!< NULL
     
    7374
    7475    // STATIC MEMBERS
    75     static std::list<ClassList>*    classList;              //!< The first Class in the List
     76    static std::vector<ClassList>*  classList;              //!< The list of ClassLists.
    7677    static std::list<const char*>   classNames;             //!< a List of all Names of all classes, that have registered so far.
    7778};
Note: See TracChangeset for help on using the changeset viewer.