- Timestamp:
- 03/01/14 22:20:08 (11 years ago)
- Location:
- cpp/frams
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/model.cpp
r121 r153 135 135 void Model::clear() 136 136 { 137 Part *p; 138 for (parts.start();p=(Part*)parts();)delete p;139 Joint* j; 140 for (joints.start();j=(Joint*)joints();)delete j;141 Neuro *n; 142 for (neurons.start();n=(Neuro*)neurons();)delete n;137 FOREACH(Part*,p,parts) 138 delete p; 139 FOREACH(Joint*,j,joints) 140 delete j; 141 FOREACH(Neuro*,n,neurons) 142 delete n; 143 143 parts.clear(); joints.clear(); neurons.clear(); 144 144 delMap(); -
cpp/frams/util/list.h
r121 r153 87 87 {return mem[i];} 88 88 bool hasMore() {return pos<size();} 89 T& operator()() ///< return next element90 { return mem[pos++];}91 89 int operator==(const SListTempl<T>& l) const ///< compare list 92 90 { … … 97 95 int find(const T& e) const ///< return position of element, or -1 if not found 98 96 { for (int i=0;i<size();i++) if (mem[i]==e) return i; return -1; } 99 int start() {return pos=0;} ///< start iteration throgh list100 97 void append(const T& data) ///< add 1 element 101 98 {needSize(size()+1); mem[used++]=data;} … … 128 125 { needSize(s); used=s;} 129 126 T& get(int i) const {return operator()(i);} 130 T& get() {return operator()();}131 127 void clear() {used=0;} ///< remove all elements 132 128 void hardclear() {resize(0); used=0;} ///< remove all elements and free mem … … 148 144 }; 149 145 150 #define FOREACH(type,var,list) for(type var=(type)list.start();var=(type)list();) 146 #define FOREACH(type,var,list) for(int _ ## var ## _i_=0,_ ## var ## _tmp_=0; _ ## var ## _i_==0;_ ## var ## _i_++) \ 147 for(type var;((_ ## var ## _tmp_=(_ ## var ## _i_<list.size()))?(var=(type)list(_ ## var ## _i_)):0),_ ## var ## _tmp_;_ ## var ## _i_++) 151 148 152 149 // usage example: FOREACH(char*,t,thelist) printf("t=%s\n",t); … … 155 152 { 156 153 public: 157 T operator()() ///< return next element158 {if (this->pos>=this->size()) return 0; else return159 this->mem[this->pos++];}160 161 154 T operator()(int i) const ///< return element at position i 162 155 {if (i>=this->size()) return 0; else return this->mem[i];} 163 156 164 157 T get(int i) const {return operator()(i);} 165 T get() {return operator()();}166 158 T& getref(int i) const {return SListTempl<T>::get(i);} 167 T& getref() {return SListTempl<T>::get();}168 159 }; 169 160 -
cpp/frams/vm/classes/collectionobj.cpp
r127 r153 248 248 { 249 249 VMVEComparator cmp(jto); 250 ExtValue **first=(ExtValue**)&data.getref( );250 ExtValue **first=(ExtValue**)&data.getref(0); 251 251 std::sort(first,first+data.size(),cmp); 252 252 } … … 255 255 { 256 256 VEComparator cmp; 257 ExtValue **first=(ExtValue**)&data.getref( );257 ExtValue **first=(ExtValue**)&data.getref(0); 258 258 std::sort(first,first+data.size(),cmp); 259 259 }
Note: See TracChangeset
for help on using the changeset viewer.