Changeset 3910
 Timestamp:
 Sep 12, 2008, 4:58:10 PM (12 years ago)
 Location:
 toimperative/trunk/opents/samples
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

toimperative/trunk/opents/samples/fff.tcc
r3909 r3910 142 142 //std::istringstream is_c_0("(ABABA(CA(A(AEA)ADA(EA(A))AAA)AC)BA)"); 143 143 //std::istringstream is_c_0("(ACA(ACA)ACA(A))"); 144 _c_0 .init(8).add('A').add('B').add('A').add(145 GExpr( 3).add('A').add('D').add('A')144 _c_0 = GExpr(1).add('A').add('B').add('A').add( 145 GExpr(1).add('A').add('D').add('A') 146 146 ).add('A').add('E').add('A').add( 147 GExpr( 3).add('A').add('F').add('A')147 GExpr(1).add('A').add('F').add('A') 148 148 ); 149 149 
toimperative/trunk/opents/samples/trefal.hh
r3909 r3910 62 62 struct GExpr { 63 63 Term* terms; 64 size_t terms_size; 64 65 size_t size; 65 66 bool need_delete; 66 67 67 GExpr () : terms(0), size(0), need_delete(false) {}68 GExpr () : terms(0), terms_size(0), size(0), need_delete(false) {} 68 69 69 70 inline GExpr (TExpr& _e); 70 71 71 GExpr (int size) : terms(new Term[size]), size(0), need_delete(true) {} 72 73 GExpr& init (int size) { 74 if (terms != 0) // must be uninitialized 75 throw 0; 76 terms = new Term[size]; 77 need_delete = true; 78 return *this; 79 } 72 GExpr (int size) : terms(new Term[size]), terms_size(size), size(0), need_delete(true) {} 80 73 81 74 GExpr& operator= (const GExpr& e) { … … 93 86 94 87 GExpr& add (const Term& t) { 88 if (size == terms_size) { 89 Term* new_terms_array = new Term[2*size]; 90 Term* old_terms = terms; 91 Term* new_terms = new_terms_array; 92 for (size_t i = 0; i < size; i++) 93 *new_terms++ = *old_terms++; 94 delete[] terms; 95 terms = new_terms_array; 96 terms_size = 2*size; 97 } 95 98 terms[size++] = t; 96 99 return *this; … … 388 391 // =================================== GExpr =================================== 389 392 390 inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), size(((Expr&)_e).get_len()), need_delete(false) {}393 inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), terms_size(0), size(((Expr&)_e).get_len()), need_delete(false) {} 391 394 392 395 GExpr& GExpr::add (const GExpr& e) {
Note: See TracChangeset
for help on using the changeset viewer.