Changeset 61e1b40 in tol
- Timestamp:
- Nov 17, 2010, 3:17:12 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 3fab862
- Parents:
- 9338a3e
- Location:
- tol/btol/set_type
- Files:
-
- 3 edited
-
set.cpp (modified) (1 diff)
-
setgra.cpp (modified) (2 diffs)
-
tol_bset.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/set_type/set.cpp
r9338a3e r61e1b40 389 389 } 390 390 391 //-------------------------------------------------------------------- 392 void BSet::Remove(int n, bool deleteOld) 393 //-------------------------------------------------------------------- 394 { 395 int s = array_.Size(); 396 if((n<0)||(n>=s)) { return; } 397 BSyntaxObject* found = array_[n]; 398 int i; 399 for(i=n; i<s-1; i++) 400 { 401 array_[i] = array_[i+1]; 402 } 403 array_.ReallocBuffer(s-1); 404 found->DecNRefs(); 405 if(deleteOld) { DESTROY(found); } 406 } 407 408 //-------------------------------------------------------------------- 409 void BSet::Replace(int n, BSyntaxObject* newObject, bool deleteOld) 410 //-------------------------------------------------------------------- 411 { 412 int s = array_.Size(); 413 if((n<0)||(n>=s)) { return; } 414 BSyntaxObject* found = array_[n]; 415 newObject->IncNRefs(); 416 array_[n] = newObject; 417 found->DecNRefs(); 418 if(deleteOld) { DESTROY(found); } 419 } 391 420 392 421 //-------------------------------------------------------------------- -
tol/btol/set_type/setgra.cpp
r9338a3e r61e1b40 149 149 }; 150 150 151 //-------------------------------------------------------------------- 152 class BSetRemove: public BExternalOperator 153 //-------------------------------------------------------------------- 154 { 155 public: 156 BSetRemove() 157 : BExternalOperator 158 ( 159 "Remove", GraSet(), "Set Real", NIL, 2, 2, 160 "(Set set, Real n)", 161 I2("Removes the n-th element of a set and tries to delete it " 162 "from memory. Returns the own set with the rest of elements." , 163 "Elimina el n-esimo elemento de un conjunto e intenta " 164 "borrarlo de la memoria. Devuelve el propio conjunto con " 165 "el resto de elementos."), 166 BOperClassify::SetAlgebra_ 167 ) 168 { 169 } 170 171 ~BSetRemove() {} 172 173 BSyntaxObject* Evaluator(BList* arg) const 174 { 175 if(CheckNonDeclarativeAction("Remove")) { return(NULL); } 176 BList* lst = arg; 177 bool incrementalIndexByName = false; 178 BUserSet* uSet = USet(lst->Car()); lst = lst->Cdr(); 179 BUserDat* uDat = UDat(lst->Car()); lst = lst->Cdr(); 180 BUserDat* uDel = UDat(lst->Car()); 181 uSet->Contens().Remove( 182 (int)(uDat->Contens().Value())-1, 183 uDel->Contens().Value()!=0.0); 184 SAFE_DESTROY(arg, uSet); 185 return(uSet); 186 } 187 private: 188 DeclareClassNewDelete(BSetRemove); 189 }; 190 191 //-------------------------------------------------------------------- 192 class BSetReplace: public BExternalOperator 193 //-------------------------------------------------------------------- 194 { 195 public: 196 BSetReplace() 197 : BExternalOperator 198 ( 199 "Replace", GraSet(), "Set Real Anything Real", NIL, 4, 4, 200 "(Set set, Real n, Anything new, Real deleteOld)", 201 I2("Replaces the n-th element of a set by a another new one " 202 "and tries to delete the old one from memory if deleteOld " 203 "is true. Returns the own set with the new changed element.", 204 "Reemplaza el n-ésimo elemento de un conjunto por otro " 205 "nuevo e intenta borrar el viejo de la memoria si deleteOld " 206 "es cierto. Devuelve el propio conjunto con el elemento " 207 "cambiado."), 208 BOperClassify::SetAlgebra_ 209 ) 210 { 211 } 212 213 ~BSetReplace() {} 214 215 BSyntaxObject* Evaluator(BList* arg) const 216 { 217 if(CheckNonDeclarativeAction("Replace")) { return(NULL); } 218 BList* lst = arg; 219 bool incrementalIndexByName = false; 220 BUserSet* uSet = USet(lst->Car()); lst = lst->Cdr(); 221 BUserDat* uDat = UDat(lst->Car()); lst = lst->Cdr(); 222 BSyntaxObject* uNew = (BSyntaxObject*)(lst->Car()); lst = lst->Cdr(); 223 BUserDat* uDel = UDat(lst->Car()); 224 uSet->Contens().Replace( 225 (int)(uDat->Contens().Value())-1, 226 uNew, 227 uDel->Contens().Value()!=0.0); 228 SAFE_DESTROY(arg, uSet); 229 return(uSet); 230 } 231 private: 232 DeclareClassNewDelete(BSetReplace); 233 }; 234 151 235 152 236 //-------------------------------------------------------------------- … … 166 250 OwnGrammar()->PutDefect(empty1_); 167 251 BSetAppend* BSetAppend_instance = new BSetAppend; 252 BSetRemove* BSetRemove_instance = new BSetRemove; 253 BSetReplace* BSetReplace_instance = new BSetReplace; 168 254 } 169 255 -
tol/btol/set_type/tol_bset.h
r9338a3e r61e1b40 135 135 void PrepareStore(int n) { Alloc(n); Alloc(0); } 136 136 void Append(const BSet& set, bool incrementalIndex); 137 void Remove(int n, bool deleteOld); 138 void Replace(int n, BSyntaxObject* newObject, bool deleteOld); 137 139 void AddElement(BSyntaxObject*); 138 140 void PutElement(BList* element = NIL);
Note: See TracChangeset
for help on using the changeset viewer.
