Changeset 24
- Timestamp:
- 06/28/09 19:40:32 (16 years ago)
- Location:
- cpp/f8-to-f1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/f8-to-f1/conv_f8tof1.cpp
r23 r24 189 189 prodIter != this->productions.end(); prodIter++) { 190 190 vector<SubProduction> *subproductions = &(prodIter->second->subproductions); 191 for (int i = 0; i < subproductions->size(); i++) { 192 if (subproductions->at(i).actions.size() == 0) { 193 subproductions->erase(subproductions->begin() + i); 191 for (vector<SubProduction>::iterator i = subproductions->begin(); i != subproductions->end(); /*nothing*/) { 192 if ((*i).actions.size() == 0) { 193 i = subproductions->erase(i); 194 } else { 195 i++; 194 196 } 195 197 } … … 213 215 subProdIter != subproductions->end(); subProdIter++) { 214 216 SubProduction *sp = &(*subProdIter); 215 for (int actionIter = 0; actionIter < sp->actions.size(); actionIter++) { 216 ActionStrP *actionstrp = &(sp->actions.at(actionIter)); 217 if (actionstrp->action != NULL) { 217 for (vector<ActionStrP>::iterator actionIter = sp->actions.begin(); 218 actionIter != sp->actions.end(); /*nothing*/) { 219 bool deleted = false; 220 if ((*actionIter).action != NULL) { 218 221 vector<SString>::iterator result = find(emptyProductionNames.begin(), emptyProductionNames.end(), 219 actionstrp->action->name);222 (*actionIter).action->name); 220 223 if (result != emptyProductionNames.end()) { //emptyProductionNames contains the action name 221 sp->actions.erase(sp->actions.begin() + actionIter); 222 } 224 actionIter = sp->actions.erase(actionIter); 225 deleted = true; 226 } 227 } 228 if (!deleted) { 229 actionIter++; 223 230 } 224 231 } … … 702 709 subProdIter != prodIter->second->subproductions.end(); subProdIter++) { 703 710 SubProduction subProduction = *subProdIter; 704 for (int i = 0; i < subProduction.actions.size(); i++) { 705 if (subProduction.actions.at(i).action == NULL) { 706 subProduction.actions.erase(subProduction.actions.begin() + i); 711 for (vector<ActionStrP>::iterator i = subProduction.actions.begin(); 712 i != subProduction.actions.end(); /*nothing*/) { 713 if ((*i).action == NULL) { 714 i = subProduction.actions.erase(i); 715 } else { 716 i++; 707 717 } 708 718 } -
cpp/f8-to-f1/geno_f8.cpp
r23 r24 774 774 for (vector<SubProduction>::iterator subProdIter = randomProduction->subproductions.begin(); 775 775 subProdIter != randomProduction->subproductions.end(); subProdIter++) { 776 for (int condIter = 0; condIter < (*subProdIter).conditions.size(); condIter++) { 777 Condition c = (*subProdIter).conditions[condIter]; 778 if (c.parameter == paramName) { 779 (*subProdIter).conditions.erase((*subProdIter).conditions.begin() + condIter); 776 for (vector<Condition>::iterator condIter = (*subProdIter).conditions.begin(); 777 condIter != (*subProdIter).conditions.end(); /*nothing*/) { 778 if ((*condIter).parameter == paramName) { 779 condIter = (*subProdIter).conditions.erase(condIter); 780 } else { 781 condIter++; 780 782 } 781 783 } … … 798 800 subProdIter != subproductions->end(); subProdIter++) { 799 801 SubProduction *sp = &(*subProdIter); 800 for ( int actionIter = 0; actionIter < sp->actions.size(); actionIter++) {801 ActionStrP *actionstrp = &(sp->actions.at(actionIter));802 if ( actionstrp->action != NULL) {803 if ( actionstrp->action->name == prodName && actionstrp->params.size() > paramIndex - 1) {802 for (vector<ActionStrP>::iterator actionIter = sp->actions.begin(); 803 actionIter != sp->actions.end(); actionIter++) { 804 if ((*actionIter).action != NULL) { 805 if ((*actionIter).action->name == prodName && (*actionIter).params.size() > paramIndex - 1) { 804 806 change += paramName.len(); //more less 805 actionstrp->params.erase(actionstrp->params.begin() + (paramIndex - 1));807 (*actionIter).params.erase((*actionIter).params.begin() + (paramIndex - 1)); 806 808 } 807 809 } … … 1136 1138 1137 1139 //actions 1138 for (int i = 0; i < (*subprodIter).actions.size(); i++) { 1139 if ((*subprodIter).actions.at(i).action == NULL) { 1140 for (vector<ActionStrP>::iterator i = (*subprodIter).actions.begin(); 1141 i != (*subprodIter).actions.end(); /*nothing*/) { 1142 bool deleted = false; 1143 if ((*i).action == NULL) { 1140 1144 continue; 1141 1145 } 1142 SString &actionName = (* subprodIter).actions.at(i).action->name;1146 SString &actionName = (*i).action->name; 1143 1147 if (actionName[0] == 'n') { 1144 1148 if (paramNames.size() > 0) { … … 1147 1151 if (searchIter != paramNames.end()) { //valid name 1148 1152 //ensure it is linked to the correct production 1149 (* subprodIter).actions.at(i).action = newLsystem->getParamProduction(actionName);1153 (*i).action = newLsystem->getParamProduction(actionName); 1150 1154 } else { 1151 1155 //link to random parameter prodution 1152 1156 SString name = paramNames[randomN(paramNames.size())]; 1153 (* subprodIter).actions.at(i).action = newLsystem->getParamProduction(name);1157 (*i).action = newLsystem->getParamProduction(name); 1154 1158 } 1155 1159 } else { //no params, so delete this param production 1156 (*subprodIter).actions.erase((*subprodIter).actions.begin() + i); 1160 i = (*subprodIter).actions.erase(i); 1161 deleted = true; 1157 1162 } 1158 1163 } else if (actionName[0] == 'P') { 1159 1164 if (newLsystem->productions.find(sstringToString(actionName)) != newLsystem->productions.end()) { 1160 1165 //ensure it is linked to the correct production 1161 (* subprodIter).actions.at(i).action = newLsystem->productions[sstringToString(actionName)];1166 (*i).action = newLsystem->productions[sstringToString(actionName)]; 1162 1167 } else { 1163 1168 //delete this action 1164 (*subprodIter).actions.erase((*subprodIter).actions.begin() + i); 1169 i = (*subprodIter).actions.erase(i); 1170 deleted = true; 1165 1171 } 1172 } 1173 if (!deleted) { 1174 i++; 1166 1175 } 1167 1176 }
Note: See TracChangeset
for help on using the changeset viewer.