Changeset 2049435a in tol
- Timestamp:
- Nov 4, 2009, 5:39:43 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 99b1a94
- Parents:
- 11cb1142
- Location:
- tol/btol/set_type
- Files:
-
- 3 edited
-
set.cpp (modified) (6 diffs)
-
setgra.cpp (modified) (2 diffs)
-
tol_bset.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/set_type/set.cpp
r11cb1142 r2049435a 130 130 131 131 //-------------------------------------------------------------------- 132 void BSet::Copy(const BSet& set)132 void BSet::Copy(const BSet& set) 133 133 //-------------------------------------------------------------------- 134 134 { … … 136 136 Delete(); 137 137 array_.ReallocBuffer(set.Card()); 138 bool hasIdx = set.HasIndexByName() ;138 bool hasIdx = set.HasIndexByName()!=0; 139 139 for(n=0; n<array_.Size(); n++) 140 140 { … … 331 331 332 332 //-------------------------------------------------------------------- 333 void BSet::Append(const BSet& set) 334 //-------------------------------------------------------------------- 335 { 333 static bool DoIndexElement(BObjByIdxNameHash** indexByName, 334 BSyntaxObject* obj, 335 int i) 336 //-------------------------------------------------------------------- 337 { 338 bool ok = true; 339 if(indexByName && *indexByName && obj) 340 { 341 const BText& name = obj->Name(); 342 if(name.HasName()) 343 { 344 BObjByIdxNameHash::const_iterator found = (*indexByName)->find(name); 345 if(found!=(*indexByName)->end()) 346 { 347 Error(I2("Duplicated index name ", 348 "Nombre de ᅵndice duplicado ")+ 349 name); 350 ok = false; 351 } 352 (**indexByName)[name] = BIndexedSyntaxObject(i,obj); 353 } 354 else 355 { 356 Error(I2("A indexed by name set cannot have elements without a valid name ", 357 "Un conjunto indexado por nombres no puede tener elementos sin un nombre vᅵlido ") 358 +"'"+name+"'"); 359 ok = false; 360 } 361 if(!ok) { delete *indexByName; *indexByName = NULL; } 362 } 363 return(ok); 364 } 365 366 //-------------------------------------------------------------------- 367 void BSet::Append(const BSet& set, bool incrementalIndex) 368 //-------------------------------------------------------------------- 369 { 370 if(!incrementalIndex && indexByName_) 371 { delete indexByName_; indexByName_ = NULL; } 372 if(incrementalIndex && !array_.Size()) 373 { 374 indexByName_ = new BObjByIdxNameHash; 375 SetEmptyKey((*indexByName_), NULL); 376 } 336 377 int m=Card(), n=set.Card(), i, j=m; 337 378 array_.ReallocBuffer(m+n); … … 340 381 array_[j]=set[i]; 341 382 array_[j]->IncNRefs(); 383 DoIndexElement(&indexByName_,array_[j],j); 342 384 } 343 385 } … … 393 435 SetEmptyKey((*indexByName_), NULL); 394 436 395 BSyntaxObject* obj; 396 int i, j; 437 int i; 397 438 if(!array_.Size()) 398 439 { … … 401 442 return(false); 402 443 } 403 for(i=j=0; i<array_.Size(); i++) 404 { 405 obj = array_[i]; 406 assert(obj); 407 const BText& name = obj->Name(); 408 if(name.HasName()) 409 { 410 if(operator[](name)) 411 { 412 Error(I2("Duplicated index name ", 413 "Nombre de ᅵndice duplicado ")+ 414 name); 415 return(false); 416 } 417 (*indexByName_)[name] = BIndexedSyntaxObject(i,obj); 418 } 419 else 420 { 421 Error(I2("A indexed by name set cannot have elements without a valid name ", 422 "Un conjunto indexado por nombres no puede tener elementos sin un nombre vᅵlido ") 423 +"'"+name+"'"); 424 return(false); 425 } 444 for(i=0; i<array_.Size(); i++) 445 { 446 assert(array_[i]); 447 if(!DoIndexElement(&indexByName_,array_[i],i)) { return(false); } 426 448 } 427 449 return(true); -
tol/btol/set_type/setgra.cpp
r11cb1142 r2049435a 106 106 : BExternalOperator 107 107 ( 108 "Append", GraSet(), "Set Set ", NIL, 2, 2,109 "(Set set1, Set set2 )",108 "Append", GraSet(), "Set Set Real", NIL, 2, 3, 109 "(Set set1, Set set2, [Real incrementalIndexByName=False])", 110 110 I2("Attaches the elements of set2 to the end of set1 without " 111 "eliminating repeated elements and preserving the order.", 111 "eliminating repeated elements and preserving the order.\n" 112 "If incrementalIndexByName is true then the index of names " 113 "will be incremented if original set had an index, or created i" , 112 114 "Concatena los elementos del conjunto set1 al final de set2 " 113 "sin eliminar elementos repetidos y conservando el orden."), 115 "sin eliminar elementos repetidos y conservando el orden.\n" 116 "Si incrementalIndexByName es cierto entonces el índice de " 117 "nombres, se mantendrá incrementalmente, siempre y cuando " 118 "ya existiera previamente y los nuevos elementos sean " 119 "compatibles, o bien se creará un índice nuevo si se parte " 120 "del conjunto vacío."), 114 121 BOperClassify::SetAlgebra_ 115 122 ) … … 122 129 { 123 130 BList* lst = arg; 131 bool incrementalIndexByName = false; 124 132 BUserSet* uSet1 = USet(lst->Car()); lst = lst->Cdr(); 125 133 BUserSet* uSet2 = USet(lst->Car()); lst = lst->Cdr(); 126 uSet1->Contens().Append(uSet2->Contens()); 134 if(lst && lst->Car()) 135 { 136 BUserDat* uDat3 = UDat(lst->Car()); 137 incrementalIndexByName = uDat3->Contens()!=0.0; 138 } 139 uSet1->Contens().Append(uSet2->Contens(),incrementalIndexByName); 127 140 SAFE_DESTROY(arg, uSet1); 128 141 return(uSet1); -
tol/btol/set_type/tol_bset.h
r11cb1142 r2049435a 134 134 void Delete (); 135 135 void PrepareStore(int n) { Alloc(n); Alloc(0); } 136 void Append(const BSet& set );136 void Append(const BSet& set, bool incrementalIndex); 137 137 void AddElement(BSyntaxObject*); 138 138 void PutElement(BList* element = NIL);
Note: See TracChangeset
for help on using the changeset viewer.
