Changeset 5cea7a in git for gfanlib/gfanlib_vector.h
- Timestamp:
- Aug 2, 2016, 6:08:41 PM (7 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
- Children:
- fbaeb59f9025699b9055c1091c0deef1925dbb40
- Parents:
- 6a97c544535256c37da0f10bcb6821b592546c68
- git-author:
- Yue <ren@mathematik.uni-kl.de>2016-08-02 18:08:41+02:00
- git-committer:
- Yue <ren@mathematik.uni-kl.de>2016-08-05 18:10:20+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gfanlib/gfanlib_vector.h
r6a97c54 r5cea7a 72 72 // Access 73 73 //-------- 74 typ& operator[](int n) 74 typ& operator[](int n)__attribute__((always_inline)) 75 75 { 76 76 if(!(n>=0 && n<(int)v.size()))outOfRange(n,v.size()); 77 77 return (v[n]); 78 78 } 79 const typ& operator[](int n)const{assert(n>=0 && n<(int)v.size());return (v[n]);} 80 const typ& UNCHECKEDACCESS(int n)const{return (v[n]);} 79 const typ& operator[](int n)const __attribute__((always_inline)){assert(n>=0 && n<(int)v.size());return (v[n]);} 80 typ& UNCHECKEDACCESS(int n)__attribute__((always_inline)){return (v[n]);} 81 const typ& UNCHECKEDACCESS(int n)const __attribute__((always_inline)){return (v[n]);} 81 82 82 83 //------------- … … 85 86 unsigned int size()const{return v.size();}; 86 87 void resize(int n){v.resize(n,typ());}; 87 void grow(int i){if( (int)size()<i)resize(i);}88 void grow(int i){if(size()<i)resize(i);} 88 89 void push_back(typ a) 89 90 { … … 293 294 std::string toString()const 294 295 { 295 296 297 296 std::stringstream f; 297 f<<*this; 298 return f.str(); 298 299 } 299 300 300 301 typ gcd()const 301 302 { 303 typ temp1,temp2; 302 304 typ ret(1); 303 305 for(unsigned i=0;i<size();i++) 304 ret=typ::gcd(ret,v[i] );306 ret=typ::gcd(ret,v[i],temp1,temp2); 305 307 return ret; 306 308 } … … 309 311 assert(!typ::isField()); 310 312 return (*this)/gcd(); 311 }312 313 void debugPrint()const314 {315 std::stringstream s;316 s<<"(";317 for(typename std::vector<typ>::const_iterator i=this->v.begin();i!=this->v.end();i++)318 {319 if(i!=this->v.begin()) s<<",";320 s<<*i;321 }322 s<<")"<<std::endl;323 std::cout << s.str();324 return;325 313 } 326 314 }; … … 415 403 416 404 return ret; 417 } ;418 419 } ;405 } 406 407 } 420 408 421 409 #endif /* LIB_ZVECTOR_H_ */
Note: See TracChangeset
for help on using the changeset viewer.