Changeset 7cc3fd in git for gfanlib/gfanlib_vector.h
- Timestamp:
- Aug 8, 2016, 2:16:42 PM (8 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 0d1bcb7165ef371658ad444b7547d9fdf53d7136
- Parents:
- 6a97c544535256c37da0f10bcb6821b592546c6815813d0947d4221b8c060256fd6994a48e3c6605
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gfanlib/gfanlib_vector.h
r6a97c54 r7cc3fd 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 std::stringstream f;296 f<<*this;297 return f.str();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.