Changeset 8b7b108 in git
- Timestamp:
- Aug 26, 2014, 12:13:44 PM (9 years ago)
- Branches:
- (u'spielwiese', '91e5db82acc17434e4062bcfa44e6efa7d41fd30')
- Children:
- ffb7320a1e69130b9af44765525d84eab07b5b94
- Parents:
- 98abec57dad14f757407f31931b9555ceee6c4ad
- git-author:
- Martin Lee <martinlee84@web.de>2014-08-26 12:13:44+02:00
- git-committer:
- Martin Lee <martinlee84@web.de>2014-08-26 12:29:12+02:00
- Location:
- factory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/ftmpl_inst.cc
r98abec r8b7b108 151 151 152 152 // 153 template int operator== (const List<CanonicalForm> &, const List<CanonicalForm> &); 153 154 template List<CanonicalForm> Union ( const List<CanonicalForm> &, const List<CanonicalForm> & ); 155 template List<List<CanonicalForm> > Union ( const List<List<CanonicalForm> >&, const List<List<CanonicalForm> >&, int operator== (const List<CanonicalForm> &, const List<CanonicalForm> &)); 154 156 template List<CanonicalForm> Difference ( const List<CanonicalForm> &, const List<CanonicalForm> & ); 157 template List<List<CanonicalForm> > Difference ( const List<List<CanonicalForm> >&, const List<List<CanonicalForm> >&, int operator== (const List<CanonicalForm> &, const List<CanonicalForm> &)); 158 template List<List<CanonicalForm> > Difference ( const List<List<CanonicalForm> >&, const List<CanonicalForm>&, int operator== (const List<CanonicalForm> &, const List<CanonicalForm> &)); 155 159 template CanonicalForm prod ( const List<CanonicalForm> & ); 156 160 template bool find ( const List<CanonicalForm> &, const CanonicalForm&); 161 template bool find ( const List<List<CanonicalForm> >&, const List<CanonicalForm>&, int operator== (const List<CanonicalForm> &, const List<CanonicalForm> &)); 157 162 // place here your own template stuff, not yet instantiated by factory 158 163 // -
factory/include/factory/templates/ftmpl_list.h
r98abec r8b7b108 112 112 113 113 template <class T> 114 int operator== (const List<T>&, const List<T>& ); 115 116 template <class T> 114 117 List<T> Union ( const List<T>&, const List<T>& ); 115 118 116 119 template <class T> 117 120 List<T> Difference ( const List<T>&, const List<T>& ); 121 122 template <class T> 123 List<T> Union ( const List<T> &, const List<T> & , int (*ecmpf)( const T&, const T& )); 124 125 template <class T> 126 List<T> Difference ( const List<T> &, const List<T> & , int (*ecmpf)( const T&, const T& )); 127 128 template <class T> 129 List<T> Difference ( const List<T> & F, const T & G, int (*ecmpf)( const T&, const T& )); 118 130 119 131 template <class T> … … 126 138 bool find (const List<T>&, const T& t); 127 139 140 template <class T> 141 bool find (const List<T> & F, const T& t, int (*ecmpf)( const T&, const T& )); 128 142 #endif /* ! INCL_LIST_H */ -
factory/templates/ftmpl_list.cc
r98abec r8b7b108 101 101 cur = cur->prev; 102 102 while ( cur ) 103 103 { 104 104 first = new ListItem<T>( *(cur->item), first, 0 ); 105 105 first->next->prev = first; … … 144 144 ListItem<T> *dummy; 145 145 while ( first ) 146 146 { 147 147 dummy = first; 148 148 first = first->next; … … 151 151 ListItem<T>* cur = l.last; 152 152 if ( cur ) 153 153 { 154 154 first = new ListItem<T>( *(cur->item), 0, 0 ); 155 155 last = first; 156 156 cur = cur->prev; 157 157 while ( cur ) 158 158 { 159 159 first = new ListItem<T>( *(cur->item), first, 0 ); 160 160 first->next->prev = first; … … 164 164 } 165 165 else 166 166 { 167 167 first = last = 0; 168 168 _length = 0; … … 171 171 } 172 172 return *this; 173 } 174 175 template <class T> 176 int operator== ( const List<T>& l1, const List<T>& l2 ) 177 { 178 if (l1.length() != l2.length()) 179 return 0; 180 ListIterator<T> iter2= l2; 181 for (ListIterator<T> iter1= l1; iter1.hasItem(); iter1++) 182 { 183 if (!(iter1.getItem() == iter2.getItem())) 184 return 0; 185 iter2++; 186 } 187 188 return 1; 173 189 } 174 190 … … 201 217 *cursor->item = t; 202 218 else 203 219 { 204 220 cursor = cursor->prev; 205 221 cursor->next = new ListItem<T>( t, cursor->next, cursor ); … … 227 243 insf( *cursor->item, t ); 228 244 else 229 245 { 230 246 cursor = cursor->prev; 231 247 cursor->next = new ListItem<T>( t, cursor->next, cursor ); … … 275 291 _length--; 276 292 if ( first == last ) 277 293 { 278 294 delete first; 279 295 first = last = 0; 280 296 } 281 297 else 282 298 { 283 299 ListItem<T> *dummy = first; 284 300 first->next->prev = 0; … … 305 321 _length--; 306 322 if ( first == last ) 307 323 { 308 324 delete last; 309 325 first = last = 0; 310 326 } 311 327 else 312 328 { 313 329 ListItem<T> *dummy = last; 314 330 last->prev->next = 0; … … 327 343 int swap; 328 344 do 329 345 { 330 346 swap = 0; 331 347 ListItem<T> *cur = first; 332 348 while ( cur->next ) 333 349 { 334 350 if ( swapit( *(cur->item), *(cur->next->item) ) ) 335 351 { 336 352 T* dummy = cur->item; 337 353 cur->item = cur->next->item; … … 481 497 theList->insert( t ); 482 498 else 483 499 { 484 500 current->prev = new ListItem<T>( t, current, current->prev ); 485 501 current->prev->prev->next = current->prev; … … 498 514 theList->append( t ); 499 515 else 500 516 { 501 517 current->next = new ListItem<T>( t, current->next, current ); 502 518 current->next->next->prev = current->next; … … 514 530 ListItem <T>*dummynext = current->next, *dummyprev = current->prev; 515 531 if ( current->prev ) 516 532 { 517 533 current->prev->next = current->next; 518 534 if ( current->next ) … … 524 540 } 525 541 else 526 542 { 527 543 if ( current->next ) 528 544 current->next->prev = 0; … … 558 574 j = G; 559 575 while ( ( ! iselt ) && j.hasItem() ) 560 576 { 561 577 iselt = f == j.getItem(); 562 578 j++; … … 576 592 for ( i = F; i.hasItem(); ++i ) 577 593 L.insert( i.getItem(), cmpf, insf ); 594 return L; 595 } 596 597 template <class T> 598 List<T> Union ( const List<T> & F, const List<T> & G, int (*ecmpf)( const T&, const T& )) 599 { 600 List<T> L = G; 601 ListIterator<T> i, j; 602 T f; 603 bool iselt; 604 605 for ( i = F; i.hasItem(); i++ ) 606 { 607 f = i.getItem(); 608 iselt = false; 609 j = G; 610 while ( ( ! iselt ) && j.hasItem() ) 611 { 612 iselt = ecmpf (f, j.getItem()); 613 j++; 614 } 615 if ( ! iselt ) 616 L.append( f ); 617 } 578 618 return L; 579 619 } … … 594 634 if ( ! found ) 595 635 L.append( f ); 636 } 637 return L; 638 } 639 640 template <class T> 641 List<T> Difference ( const List<T> & F, const List<T> & G, int (*ecmpf)( const T&, const T& )) 642 { 643 List<T> L; 644 ListIterator<T> i, j; 645 T f; 646 int found; 647 for ( i = F; i.hasItem(); ++i ) 648 { 649 f = i.getItem(); 650 found = 0; 651 for ( j = G; j.hasItem() && (!found); ++j ) 652 found = ecmpf (f, j.getItem()); 653 if ( ! found ) 654 L.append( f ); 655 } 656 return L; 657 } 658 659 template <class T> 660 List<T> Difference ( const List<T> & F, const T & G, int (*ecmpf)( const T&, const T& )) 661 { 662 List<T> L; 663 ListIterator<T> i; 664 int found; 665 for ( i = F; i.hasItem(); ++i ) 666 { 667 found = ecmpf (G, i.getItem()); 668 if ( ! found ) 669 L.append( i.getItem() ); 596 670 } 597 671 return L; … … 621 695 return false; 622 696 } 697 698 template <class T> 699 bool find (const List<T> & F, const T& t, int (*ecmpf)( const T&, const T& )) 700 { 701 if (F.length() == 0) return false; 702 ListIterator<T> J= F; 703 while (J.hasItem()) 704 { 705 if (ecmpf (J.getItem(), t)) 706 return true; 707 J++; 708 } 709 return false; 710 } 711
Note: See TracChangeset
for help on using the changeset viewer.