- Timestamp:
- Mar 29, 2005, 10:34:25 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/garbage_collector.cc
r3647 r3661 88 88 WorldInterface* wi = WorldInterface::getInstance(); 89 89 tList<WorldEntity>* list = wi->getEntityList(); 90 //WorldEntity* entity = list->enumerate(); 91 // while( entity != NULL) 92 // { 93 // if( entity->isFinalized()) 94 //{ 95 // PRINTF(3)("Finalizing object in list - not yet done realy\n"); 90 91 tIterator<WorldEntity>* iterator = list->getIterator(); 92 WorldEntity* entity = iterator->nextElement(); 93 while( entity != NULL) 94 { 95 if( entity->isFinalized()) 96 { 97 PRINTF(3)("Finalizing object in list - not yet done realy\n"); 96 98 /* first remove out of entity list */ 97 99 //list->remove(entity); 98 100 /* second remove out of pnode tree */ 99 // NullParent* np = NullParent::getInstance();101 //llParent* np = NullParent::getInstance(); 100 102 //np->removeChild(np); 101 103 102 //}103 // entity = list->nextElement();104 //}104 } 105 entity = iterator->nextElement(); 106 } 105 107 106 108 /* reset time to count again up to this->delay */ -
orxonox/trunk/src/lib/util/list.h
r3654 r3661 66 66 listElement<T>* currentEl; 67 67 listElement<T>* firstEl; 68 int counter; 68 69 }; 69 70 … … 74 75 this->currentEl = startElement; 75 76 this->firstEl = startElement; 77 this->counter = -1; 76 78 } 77 79 … … 87 89 inline T* tIterator<T>::nextElement () 88 90 { 89 if( this->currentEl == NULL || this->currentEl->next == NULL) /* don't turn it the other way or it will give segfaults! */90 return NULL;91 if( this->currentEl == this->firstEl)92 {93 this->currentEl = this->currentEl->next;94 return this->firstEl->curr; /* if its the first element, don't return second element*/95 } 91 this->counter++; 92 if( this->counter == 0) 93 return this->firstEl->curr; 94 95 if( this->currentEl->next == NULL || this->currentEl == NULL) 96 return NULL; 97 96 98 this->currentEl = this->currentEl->next; 97 99 return this->currentEl->curr; … … 154 156 155 157 template<class T> 156 void tList<T>::add(T* entity)158 inline void tList<T>::add(T* entity) 157 159 { 158 160 if( entity == NULL) return; … … 171 173 172 174 template<class T> 173 void tList<T>::remove(T* entity)175 inline void tList<T>::remove(T* entity) 174 176 { 175 177 if( entity == NULL) return; -
orxonox/trunk/src/orxonox.cc
r3660 r3661 346 346 347 347 348 #define LIST_MAX 1000 0348 #define LIST_MAX 1000 349 349 #define VECTOR_MAX 1000000 350 350 #define ITERATIONS 10000 … … 635 635 printf(" Generate rot matrix: q->matrix(m)\t%11.2f\n", mi); 636 636 } 637 if( type == 3 || type == -1) 638 { 639 /* list tests*/ 640 printf("\nList operations tests: \t\t\t\t\t%i\n", LIST_MAX); 641 tList<char>* list = new tList<char>(); 642 char* name; 643 644 printf(" Adding[1..10] elements to list, found:\n"); 645 list->add("1"); 646 list->add("2"); 647 list->add("3"); 648 list->add("4"); 649 list->add("5"); 650 list->add("6"); 651 list->add("7"); 652 list->add("8"); 653 list->add("9"); 654 list->add("10"); 655 656 /*give list out */ 657 tIterator<char>* iterator = list->getIterator(); 658 name = iterator->nextElement(); 659 printf(" List Elements: \t\t"); 660 while( name != NULL) 661 { 662 printf("%s,", name); 663 name = iterator->nextElement(); 664 } 665 delete iterator; 666 printf("\n"); 667 668 669 /*removing some elements from the list*/ 670 printf(" Removing elements [2,3,6,8,10], adding [11] now found:\n"); 671 list->remove("2"); 672 list->remove("3"); 673 list->remove("6"); 674 list->remove("8"); 675 list->remove("10"); 676 list->add("11"); 677 /*give list out */ 678 iterator = list->getIterator(); 679 name = iterator->nextElement(); 680 printf(" List Elements: \t\t"); 681 while( name != NULL) 682 { 683 printf("%s,", name); 684 name = iterator->nextElement(); 685 } 686 delete iterator; 687 printf("\n"); 688 689 delete list; 690 printf("\nChecking list performance:\t\t\t\t%i\n", LIST_MAX); 691 692 tList<int>* plist = new tList<int>(); 693 unsigned long mittel, ini, end; 694 float mi; 695 int i = 0; 696 mittel = 0; 697 for(i = 0; i < LIST_MAX; ++i) 698 { 699 rdtscl(ini); 700 701 plist->add(&i); 702 703 rdtscl(end); 704 mittel += (end - ini - dt); 705 } 706 mi = mittel / (float)LIST_MAX; 707 printf(" Adding reference to list:\t\t%11.2f\n", mi); 708 709 mittel = 0; 710 for(i = 0; i < LIST_MAX; ++i) 711 { 712 rdtscl(ini); 713 714 plist->remove(&i); 715 716 rdtscl(end); 717 mittel += (end - ini - dt); 718 } 719 mi = mittel / (float)LIST_MAX; 720 printf(" Removing 1st reference from list:\t%11.2f\n", mi); 721 722 723 724 } 637 725 } 638 726 } -
orxonox/trunk/src/simple_animation.cc
r3573 r3661 111 111 SimpleAnimation::~SimpleAnimation () 112 112 { 113 KeyFrame* frame = this->frames->enumerate(); 113 tIterator<KeyFrame>* iterator = this->frames->getIterator(); 114 KeyFrame* frame = iterator->nextElement(); 114 115 while( frame != NULL) 115 116 { 116 117 delete frame; 117 frame = frames->nextElement();118 frame = iterator->nextElement(); 118 119 } 120 delete iterator; 119 121 delete this->frames; 120 122 } … … 163 165 void SimpleAnimation::reset() 164 166 { 165 KeyFrame* frame = this->frames->enumerate(); 167 tIterator<KeyFrame>* iterator = this->frames->getIterator(); 168 KeyFrame* frame = iterator->nextElement(); 166 169 while( frame != NULL) 167 170 { 168 171 delete frame; 169 frame = frames->nextElement();172 frame = iterator->nextElement(); 170 173 } 174 delete iterator; 171 175 delete this->frames; 172 176 -
orxonox/trunk/src/track_manager.cc
r3608 r3661 70 70 if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin)) 71 71 { 72 TrackElement* enumElem = children->enumerate(); 72 tIterator<TrackElement>* iterator = this->children->getIterator(); 73 TrackElement* enumElem = iterator->nextElement(); 73 74 while (enumElem) 74 75 { 75 76 delete enumElem; 76 enumElem = children->nextElement();77 enumElem = iterator->nextElement(); 77 78 } 79 delete iterator; 78 80 delete this->children; 79 81 } … … 95 97 if (this->childCount > 0) 96 98 { 97 TrackElement* enumElem = this->children->enumerate(); 99 tIterator<TrackElement>* iterator = this->children->getIterator(); 100 TrackElement* enumElem = iterator->nextElement(); 98 101 TrackElement* tmpElem; 99 102 while (enumElem) … … 101 104 if ((tmpElem = enumElem->findByID(trackID))) 102 105 return tmpElem; 103 enumElem = this->children->nextElement();106 enumElem = iterator->nextElement(); 104 107 } 108 delete iterator; 105 109 } 106 110 else … … 120 124 else 121 125 { 122 TrackElement* enumElem = this->children->enumerate(); 126 tIterator<TrackElement>* iterator = this->children->getIterator(); 127 TrackElement* enumElem = iterator->nextElement(); 123 128 while (enumElem) 124 129 { 125 130 if(!enumElem->backLoopCheck(trackElem)) 126 131 return false; 127 enumElem = this->children->nextElement();132 enumElem = iterator->nextElement(); 128 133 } 134 delete iterator; 129 135 130 136 return true;
Note: See TracChangeset
for help on using the changeset viewer.