Changeset 7cc3fd in git for gfanlib/gfanlib_vector.h


Ignore:
Timestamp:
Aug 8, 2016, 2:16:42 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
0d1bcb7165ef371658ad444b7547d9fdf53d7136
Parents:
6a97c544535256c37da0f10bcb6821b592546c6815813d0947d4221b8c060256fd6994a48e3c6605
Message:
t push origin spielwieseMerge branch 'YueRen-gfanlib0.6' into spielwiese
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gfanlib/gfanlib_vector.h

    r6a97c54 r7cc3fd  
    7272  // Access
    7373  //--------
    74   typ& operator[](int n)
     74  typ& operator[](int n)__attribute__((always_inline))
    7575    {
    7676      if(!(n>=0 && n<(int)v.size()))outOfRange(n,v.size());
    7777      return (v[n]);
    7878    }
    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]);}
    8182
    8283  //-------------
     
    8586  unsigned int size()const{return v.size();};
    8687  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);}
    8889  void push_back(typ a)
    8990  {
     
    293294  std::string toString()const
    294295  {
    295     std::stringstream f;
    296     f<<*this;
    297     return f.str();
     296          std::stringstream f;
     297          f<<*this;
     298          return f.str();
    298299  }
    299300
    300301  typ gcd()const
    301302  {
     303    typ temp1,temp2;
    302304    typ ret(1);
    303305    for(unsigned i=0;i<size();i++)
    304       ret=typ::gcd(ret,v[i]);
     306      ret=typ::gcd(ret,v[i],temp1,temp2);
    305307    return ret;
    306308  }
     
    309311    assert(!typ::isField());
    310312    return (*this)/gcd();
    311   }
    312 
    313   void debugPrint()const
    314   {
    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;
    325313  }
    326314};
     
    415403
    416404    return ret;
    417 };
    418 
    419 };
     405}
     406
     407}
    420408
    421409#endif /* LIB_ZVECTOR_H_ */
Note: See TracChangeset for help on using the changeset viewer.