CMS 3D CMS Logo

BitArray< N > Class Template Reference

#include <CondFormats/Calibration/interface/BitArray.h>

List of all members.

Public Member Functions

int any ()
int any ()
void assign (const int p, const int n, const char *str)
void assign (const int p, const int n, const BitArray< N > &val)
void assign (const int p, const int n, const int val)
void assign (const int p, const int n, const char *str)
void assign (const int p, const int n, const BitArray< N > &val)
void assign (const int p, const int n, const int val)
 BitArray (const unsigned i)
 BitArray (const char *str, const int p, const int n)
 BitArray (const char *str)
 BitArray (const BitArray< N > &br)
 BitArray ()
 BitArray (const unsigned i)
 BitArray (const char *str, const int p, const int n)
 BitArray (const char *str)
 BitArray (const BitArray< N > &br)
 BitArray ()
BitArray< 8 > byte (const int i) const
BitArray< 8 > byte (const int i) const
void cleanUnused ()
void cleanUnused ()
int count () const
int count () const
unsigned & dataWord (const int i)
unsigned dataWord (const int i) const
unsigned & dataWord (const int i)
unsigned dataWord (const int i) const
int element (const int pos) const
int element (const int pos) const
BitArray< N > & flip ()
BitArray< N > & flip ()
unsigned getWord (const int pos) const
unsigned & getWord (const int pos)
unsigned getWord (const int pos) const
unsigned & getWord (const int pos)
unsigned lastWordMask () const
unsigned lastWordMask () const
int nBits () const
int nBits () const
int none ()
int none ()
int nWords () const
int nWords () const
void one ()
void one ()
BitArray< N > operator & (const BitArray< N > &a)
BitArray< N > operator & (const BitArray< N > &a)
BitArray< N > & operator &= (const BitArray< N > &a)
BitArray< N > & operator &= (const BitArray< N > &a)
bool operator!= (const BitArray< N > &a) const
bool operator!= (const BitArray< N > &a) const
BitArray< N > operator+ (const BitArray< N > &a)
BitArray< N > operator+ (const BitArray< N > &a)
BitArray< N > & operator++ (int)
BitArray< N > & operator++ (int)
BitArray< N > & operator+= (const BitArray< N > &a)
BitArray< N > & operator+= (const BitArray< N > &a)
BitArray< N > operator- (const BitArray< N > &a)
BitArray< N > operator- (const BitArray< N > &a)
BitArray< N > & operator-= (const BitArray< N > &a)
BitArray< N > & operator-= (const BitArray< N > &a)
bool operator< (const BitArray< N > &a) const
bool operator< (const BitArray< N > &a) const
BitArray< N > operator<< (const int n)
BitArray< N > operator<< (const int n)
BitArray< N > & operator<<= (const int n)
BitArray< N > & operator<<= (const int n)
bool operator<= (const BitArray< N > &a) const
bool operator<= (const BitArray< N > &a) const
BitArray< N > & operator= (const char *str)
BitArray< N > & operator= (const unsigned i)
BitArray< N > & operator= (const BitArray< N > &a)
BitArray< N > & operator= (const char *str)
BitArray< N > & operator= (const unsigned i)
BitArray< N > & operator= (const BitArray< N > &a)
bool operator== (const BitArray< N > &a) const
bool operator== (const BitArray< N > &a) const
bool operator> (const BitArray< N > &a) const
bool operator> (const BitArray< N > &a) const
bool operator>= (const BitArray< N > &a) const
bool operator>= (const BitArray< N > &a) const
BitArray< N > operator>> (const int n)
BitArray< N > operator>> (const int n)
BitArray< N > & operator>>= (const int n)
BitArray< N > & operator>>= (const int n)
int operator[] (const int pos) const
refToBit operator[] (const int pos)
int operator[] (const int pos) const
refToBit operator[] (const int pos)
BitArray< N > operator^ (const BitArray< N > &a)
BitArray< N > operator^ (const BitArray< N > &a)
BitArray< N > & operator^= (const BitArray< N > &a)
BitArray< N > & operator^= (const BitArray< N > &a)
BitArray< N > operator| (const BitArray< N > &a)
BitArray< N > operator| (const BitArray< N > &a)
BitArray< N > & operator|= (const BitArray< N > &a)
BitArray< N > & operator|= (const BitArray< N > &a)
BitArray< N > operator~ () const
BitArray< N > operator~ () const
std::ostream & print (std::ostream &o=std::cout) const
std::ostream & print (std::ostream &o=std::cout) const
unsigned read (const int p, const int n) const
unsigned read (const int p, const int n) const
void reset (const int i)
void reset ()
void reset (const int i)
void reset ()
void set (const int i, const char *str)
void set (const int i, const int val)
void set (const int i)
void set (const int i, const char *str)
void set (const int i, const int val)
void set (const int i)
int size () const
int size () const
int test (const int i) const
int test (const int i) const
BitArray< N > & twoComplement ()
BitArray< N > twoComplement () const
BitArray< N > & twoComplement ()
BitArray< N > twoComplement () const
void unset (const int i)
void unset (const int i)
int unusedBits () const
int unusedBits () const
void zero ()
void zero ()

Static Public Member Functions

static int getPosInWord (const int pos)
static int getPosInWord (const int pos)
static unsigned getPosMask (const int pos)
static unsigned getPosMask (const int pos)

Private Attributes

unsigned _data [N/32+1]

Friends

class refToBit

Classes

class  refToBit


Detailed Description

template<int N>
class BitArray< N >

Definition at line 30 of file BitArray.h.


Constructor & Destructor Documentation

template<int N>
BitArray< N >::BitArray (  )  [inline]

Definition at line 82 of file BitArray.h.

00082 {this->zero();}

template<int N>
BitArray< N >::BitArray ( const BitArray< N > &  br  )  [inline]

Definition at line 84 of file BitArray.h.

00084                                   {
00085     for (int i=0;i<this->nWords();i++) {
00086       _data[i] = br._data[i];         
00087     }
00088     this->cleanUnused();
00089   }

template<int N>
BitArray< N >::BitArray ( const char *  str  )  [inline]

Definition at line 90 of file BitArray.h.

00090                             { 
00091     this->zero(); 
00092     this->assign(0,this->nBits(),str); 
00093     this->cleanUnused();
00094   }

template<int N>
BitArray< N >::BitArray ( const char *  str,
const int  p,
const int  n 
) [inline]

Definition at line 95 of file BitArray.h.

00095                                                       {
00096     this->zero(); 
00097     this->assign(p, n, str);
00098   }

template<int N>
BitArray< N >::BitArray ( const unsigned  i  )  [inline]

Definition at line 99 of file BitArray.h.

00099                              { 
00100     this->zero();
00101     _data[0] = i;                 // the nBit least sign. bits are considered
00102     this->cleanUnused();
00103   }

template<int N>
BitArray< N >::BitArray (  )  [inline]

Definition at line 83 of file BitArray.h.

00083 {this->zero();}

template<int N>
BitArray< N >::BitArray ( const BitArray< N > &  br  )  [inline]

Definition at line 85 of file BitArray.h.

00085                                   {
00086     for (int i=0;i<this->nWords();i++) {
00087       _data[i] = br._data[i];         
00088     }
00089     this->cleanUnused();
00090   }

template<int N>
BitArray< N >::BitArray ( const char *  str  )  [inline]

Definition at line 91 of file BitArray.h.

00091                             { 
00092     this->zero(); 
00093     this->assign(0,this->nBits(),str); 
00094     this->cleanUnused();
00095   }

template<int N>
BitArray< N >::BitArray ( const char *  str,
const int  p,
const int  n 
) [inline]

Definition at line 96 of file BitArray.h.

00096                                                       {
00097     this->zero(); 
00098     this->assign(p, n, str);
00099   }

template<int N>
BitArray< N >::BitArray ( const unsigned  i  )  [inline]

Definition at line 100 of file BitArray.h.

00100                              { 
00101     this->zero();
00102     _data[0] = i;                 // the nBit least sign. bits are considered
00103     this->cleanUnused();
00104   }


Member Function Documentation

template<int N>
int BitArray< N >::any (  )  [inline]

Definition at line 184 of file BitArray.h.

00184             {
00185     int nw = this->nWords();
00186     int ub = unusedBits();
00187     if(this->dataWord(nw-1)<<ub!=0)return 1;
00188     if(nw>1){
00189       for (int iw=0;iw<nw-1;iw++){
00190         if(this->dataWord(iw)!=0) return 1;
00191       }
00192     }
00193     return 0;
00194   }    

template<int N>
int BitArray< N >::any (  )  [inline]

Definition at line 183 of file BitArray.h.

Referenced by DTTSTheta::runDTTSTheta().

00183             {
00184     int nw = this->nWords();
00185     int ub = unusedBits();
00186     if(this->dataWord(nw-1)<<ub!=0)return 1;
00187     if(nw>1){
00188       for (int iw=0;iw<nw-1;iw++){
00189         if(this->dataWord(iw)!=0) return 1;
00190       }
00191     }
00192     return 0;
00193   }    

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const char *  str 
) [inline]

Definition at line 261 of file BitArray.h.

00261                                                          {
00262     assert(p>=0 && p+n<=this->nBits());  
00263     // only the n least significant bits of val are considered
00264     for(int i=0; i<n;i++){
00265       assert(str[i]=='1'||str[i]=='0');  
00266       if(str[i]=='1') {
00267         this->set(p+n-i-1);   // reading a string from left to right 
00268       } else {                // --> most significative bit is the one 
00269         this->unset(p+n-i-1); // with lower string index
00270       }
00271     }
00272   }

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const BitArray< N > &  val 
) [inline]

Definition at line 250 of file BitArray.h.

00250                                                                 {
00251     assert(p>=0 && p+n<=this->nBits());  
00252     // only the n least significant bits of val are considered
00253     for(int i=0; i<n;i++){
00254       if(val.element(i)) {
00255         this->set(p+i);
00256       } else {
00257         this->unset(p+i);
00258       }
00259     }
00260   }

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const int  val 
) [inline]

Definition at line 239 of file BitArray.h.

00239                                                        {
00240     assert(p>=0 && p+n<=this->nBits());  
00241     // only the n least significant bits of val are considered
00242     for(int i=0; i<n;i++){
00243       if(val>>i&1) {
00244         this->set(p+i);
00245       } else {
00246         this->unset(p+i);
00247       }
00248     }
00249   }

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const char *  str 
) [inline]

Definition at line 260 of file BitArray.h.

00260                                                          {
00261     assert(p>=0 && p+n<=this->nBits());  
00262     // only the n least significant bits of val are considered
00263     for(int i=0; i<n;i++){
00264       assert(str[i]=='1'||str[i]=='0');  
00265       if(str[i]=='1') {
00266         this->set(p+n-i-1);   // reading a string from left to right 
00267       } else {                // --> most significative bit is the one 
00268         this->unset(p+n-i-1); // with lower string index
00269       }
00270     }
00271   }

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const BitArray< N > &  val 
) [inline]

Definition at line 249 of file BitArray.h.

00249                                                                 {
00250     assert(p>=0 && p+n<=this->nBits());  
00251     // only the n least significant bits of val are considered
00252     for(int i=0; i<n;i++){
00253       if(val.element(i)) {
00254         this->set(p+i);
00255       } else {
00256         this->unset(p+i);
00257       }
00258     }
00259   }

template<int N>
void BitArray< N >::assign ( const int  p,
const int  n,
const int  val 
) [inline]

Definition at line 238 of file BitArray.h.

Referenced by BitArray< 9 >::BitArray(), DTSectCollPhCand::clearBits(), DTTSCand::clearBits(), DTTSCand::clearBitsBkmod(), DTSectCollPhCand::clearBitsSectColl(), DTTracoChip::insideAngWindow(), BitArray< 9 >::set(), DTSectCollPhCand::setBitsSectColl(), DTTSCand::setBitsTsm(), and DTTSCand::setBitsTss().

00238                                                        {
00239     assert(p>=0 && p+n<=this->nBits());  
00240     // only the n least significant bits of val are considered
00241     for(int i=0; i<n;i++){
00242       if(val>>i&1) {
00243         this->set(p+i);
00244       } else {
00245         this->unset(p+i);
00246       }
00247     }
00248   }

template<int N>
BitArray<8> BitArray< N >::byte ( const int  i  )  const [inline]

Definition at line 287 of file BitArray.h.

00287                                       {
00288     BitArray<8> out;
00289     if(i>=0&&i<4*this->nWords()){
00290       unsigned k=(_data[i/4]>>8*(i%4))&0xff;
00291       out=k;
00292     }
00293     return out;
00294   }

template<int N>
BitArray<8> BitArray< N >::byte ( const int  i  )  const [inline]

Definition at line 286 of file BitArray.h.

Referenced by DTTSTheta::runDTTSTheta().

00286                                       {
00287     BitArray<8> out;
00288     if(i>=0&&i<4*this->nWords()){
00289       unsigned k=(_data[i/4]>>8*(i%4))&0xff;
00290       out=k;
00291     }
00292     return out;
00293   }

template<int N>
void BitArray< N >::cleanUnused (  )  [inline]

Definition at line 170 of file BitArray.h.

00170                      {
00171     _data[this->nWords()-1] &= (this->lastWordMask());
00172   }

template<int N>
void BitArray< N >::cleanUnused (  )  [inline]

Definition at line 169 of file BitArray.h.

Referenced by BitArray< 9 >::BitArray(), and BitArray< 9 >::operator=().

00169                      {
00170     _data[this->nWords()-1] &= (this->lastWordMask());
00171   }

template<int N>
int BitArray< N >::count ( void   )  const [inline]

Definition at line 175 of file BitArray.h.

00175                     {
00176     int n=0;
00177     for(int i=0;i<this->nBits();i++) {
00178       if(this->element(i))n++;
00179     }
00180     return n;
00181   }

template<int N>
int BitArray< N >::count ( void   )  const [inline]

Definition at line 174 of file BitArray.h.

00174                     {
00175     int n=0;
00176     for(int i=0;i<this->nBits();i++) {
00177       if(this->element(i))n++;
00178     }
00179     return n;
00180   }

template<int N>
unsigned& BitArray< N >::dataWord ( const int  i  )  [inline]

Definition at line 132 of file BitArray.h.

00132                                    {
00133     assert(i>=0 && i<this->nWords());
00134     return _data[i];
00135   }

template<int N>
unsigned BitArray< N >::dataWord ( const int  i  )  const [inline]

Definition at line 128 of file BitArray.h.

00128                                        {
00129     assert(i>=0 && i<this->nWords());
00130     return _data[i];
00131   }

template<int N>
unsigned& BitArray< N >::dataWord ( const int  i  )  [inline]

Definition at line 131 of file BitArray.h.

00131                                    {
00132     assert(i>=0 && i<this->nWords());
00133     return _data[i];
00134   }

template<int N>
unsigned BitArray< N >::dataWord ( const int  i  )  const [inline]

Definition at line 127 of file BitArray.h.

Referenced by DTTSCand::dataword(), DTSectCollPhCand::dataword(), BitArray< 9 >::operator &=(), BitArray< 9 >::operator<(), BitArray< 9 >::operator==(), BitArray< 9 >::operator^=(), and BitArray< 9 >::operator|=().

00127                                        {
00128     assert(i>=0 && i<this->nWords());
00129     return _data[i];
00130   }

template<int N>
int BitArray< N >::element ( const int  pos  )  const [inline]

Definition at line 210 of file BitArray.h.

00210                                    {
00211     return (getWord(pos)&getPosMask(pos))!=static_cast<unsigned>(0);
00212   }

template<int N>
int BitArray< N >::element ( const int  pos  )  const [inline]

Definition at line 209 of file BitArray.h.

Referenced by DTTracoChip::add_btiT(), DTTracoChip::AdjBtiLTSuppressed(), BitArray< 9 >::assign(), DTTSPhi::ignoreSecondTrack(), DTTracoChip::insideAngWindow(), DTSectCollPhCand::isFirst(), DTTSCand::isFirst(), DTBtiChip::keepTrig(), DTBtiChip::keepTrigPatt(), BitArray< 9 >::operator+=(), BitArray< 9 >::operator[](), DTTracoChip::ovlFlag(), BitArray< 9 >::print(), DTSectCollPhCand::print(), DTConfigBti::PTMSflag(), DTTracoChip::run(), DTTSPhi::runTSPhi(), DTTSCand::setBitsTsm(), DTTSCand::setBitsTss(), DTTracoChip::setFlag(), DTTracoChip::storeCorr(), DTTracoChip::storeUncorr(), BitArray< 9 >::test(), DTConfigTraco::usedBti(), DTConfigTSPhi::usedTraco(), DTTracoChip::useSecondTrack(), and DTConfigBti::WENflag().

00209                                    {
00210     return (getWord(pos)&getPosMask(pos))!=static_cast<unsigned>(0);
00211   }

template<int N>
BitArray<N>& BitArray< N >::flip (  )  [inline]

Definition at line 406 of file BitArray.h.

00406                        {
00407     for(int i=0;i<this->nWords();i++) {
00408       _data[i] = ~_data[i];
00409     }
00410     return *this;
00411   }

template<int N>
BitArray<N>& BitArray< N >::flip (  )  [inline]

Definition at line 405 of file BitArray.h.

00405                        {
00406     for(int i=0;i<this->nWords();i++) {
00407       _data[i] = ~_data[i];
00408     }
00409     return *this;
00410   }

template<int N>
static int BitArray< N >::getPosInWord ( const int  pos  )  [inline, static]

Definition at line 148 of file BitArray.h.

00148                                          {
00149     // assert(pos>=0&& pos<this->nBits());
00150     return pos%32;
00151   }

template<int N>
static int BitArray< N >::getPosInWord ( const int  pos  )  [inline, static]

Definition at line 147 of file BitArray.h.

Referenced by BitArray< 9 >::getPosMask(), and BitArray< N >::refToBit::refToBit().

00147                                          {
00148     // assert(pos>=0&& pos<this->nBits());
00149     return pos%32;
00150   }

template<int N>
static unsigned BitArray< N >::getPosMask ( const int  pos  )  [inline, static]

Definition at line 154 of file BitArray.h.

00154                                             {
00155     return static_cast<unsigned>(1)<<getPosInWord(pos);
00156   }

template<int N>
static unsigned BitArray< N >::getPosMask ( const int  pos  )  [inline, static]

Definition at line 153 of file BitArray.h.

Referenced by BitArray< 9 >::element(), BitArray< N >::refToBit::flip(), BitArray< N >::refToBit::operator int(), BitArray< N >::refToBit::operator=(), BitArray< N >::refToBit::operator~(), BitArray< 9 >::set(), and BitArray< 9 >::unset().

00153                                             {
00154     return static_cast<unsigned>(1)<<getPosInWord(pos);
00155   }

template<int N>
unsigned BitArray< N >::getWord ( const int  pos  )  const [inline]

Definition at line 142 of file BitArray.h.

00142                                         {
00143     assert(pos>=0&& pos<this->nBits());
00144     return _data[pos/32];
00145   }

template<int N>
unsigned& BitArray< N >::getWord ( const int  pos  )  [inline]

Definition at line 138 of file BitArray.h.

00138                                     {
00139     assert(pos>=0&& pos<this->nBits());
00140     return _data[pos/32];
00141   }

template<int N>
unsigned BitArray< N >::getWord ( const int  pos  )  const [inline]

Definition at line 141 of file BitArray.h.

00141                                         {
00142     assert(pos>=0&& pos<this->nBits());
00143     return _data[pos/32];
00144   }

template<int N>
unsigned& BitArray< N >::getWord ( const int  pos  )  [inline]

Definition at line 137 of file BitArray.h.

Referenced by BitArray< 9 >::element(), BitArray< N >::refToBit::refToBit(), BitArray< 9 >::set(), and BitArray< 9 >::unset().

00137                                     {
00138     assert(pos>=0&& pos<this->nBits());
00139     return _data[pos/32];
00140   }

template<int N>
unsigned BitArray< N >::lastWordMask (  )  const [inline]

Definition at line 165 of file BitArray.h.

00165                                 {
00166     return static_cast<unsigned>(0xffffffff)>>(this->unusedBits());
00167   }

template<int N>
unsigned BitArray< N >::lastWordMask (  )  const [inline]

Definition at line 164 of file BitArray.h.

Referenced by BitArray< 9 >::cleanUnused().

00164                                 {
00165     return static_cast<unsigned>(0xffffffff)>>(this->unusedBits());
00166   }

template<int N>
int BitArray< N >::nBits (  )  const [inline]

Definition at line 121 of file BitArray.h.

00121 { return N; }

template<int N>
int BitArray< N >::nBits (  )  const [inline]

Definition at line 120 of file BitArray.h.

Referenced by BitArray< 9 >::assign(), BitArray< 9 >::count(), BitArray< 9 >::getWord(), BitArray< 9 >::operator++(), BitArray< 9 >::operator+=(), BitArray< 9 >::operator<<=(), BitArray< 9 >::operator=(), BitArray< 9 >::operator>>=(), BitArray< 9 >::read(), BitArray< 9 >::size(), and BitArray< 9 >::unusedBits().

00120 { return N; }

template<int N>
int BitArray< N >::none (  )  [inline]

Definition at line 197 of file BitArray.h.

00197              {
00198     int nw = this->nWords();
00199     int ub = unusedBits();
00200     if(this->dataWord(nw-1)<<ub!=0xffffffff)return 1;
00201     if(nw>1){
00202       for (int iw=0;iw<nw-1;iw++){
00203         if(this->dataWord(iw)!=0xffffffff) return 1;
00204       }
00205     }
00206     return 0;
00207   }    

template<int N>
int BitArray< N >::none (  )  [inline]

Definition at line 196 of file BitArray.h.

00196              {
00197     int nw = this->nWords();
00198     int ub = unusedBits();
00199     if(this->dataWord(nw-1)<<ub!=0xffffffff)return 1;
00200     if(nw>1){
00201       for (int iw=0;iw<nw-1;iw++){
00202         if(this->dataWord(iw)!=0xffffffff) return 1;
00203       }
00204     }
00205     return 0;
00206   }    

template<int N>
int BitArray< N >::nWords (  )  const [inline]

Definition at line 125 of file BitArray.h.

00125 { return N/32+1; }

template<int N>
int BitArray< N >::nWords (  )  const [inline]

Definition at line 124 of file BitArray.h.

Referenced by BitArray< 9 >::any(), BitArray< 9 >::BitArray(), BitArray< 9 >::byte(), BitArray< 9 >::cleanUnused(), BitArray< 9 >::dataWord(), BitArray< 9 >::flip(), BitArray< 9 >::none(), BitArray< 9 >::one(), BitArray< 9 >::operator &=(), BitArray< 9 >::operator<(), BitArray< 9 >::operator=(), BitArray< 9 >::operator==(), BitArray< 9 >::operator^=(), BitArray< 9 >::operator|=(), and BitArray< 9 >::zero().

00124 { return N/32+1; }

template<int N>
void BitArray< N >::one (  )  [inline]

Definition at line 223 of file BitArray.h.

00223              {
00224     for (int i=0;i<this->nWords();i++) {
00225       _data[i] = 0xffffffff;       // set to 1
00226     }
00227   }

template<int N>
void BitArray< N >::one (  )  [inline]

Definition at line 222 of file BitArray.h.

Referenced by DTSectCollPhCand::clear(), DTTSCand::clear(), DTSectCollPhCand::DTSectCollPhCand(), DTTSCand::DTTSCand(), and DTConfigTSPhi::setDefaults().

00222              {
00223     for (int i=0;i<this->nWords();i++) {
00224       _data[i] = 0xffffffff;       // set to 1
00225     }
00226   }

template<int N>
BitArray<N> BitArray< N >::operator & ( const BitArray< N > &  a  )  [inline]

Definition at line 425 of file BitArray.h.

00425 {return BitArray<N> (*this)&=a; }

template<int N>
BitArray<N> BitArray< N >::operator & ( const BitArray< N > &  a  )  [inline]

Definition at line 424 of file BitArray.h.

00424 {return BitArray<N> (*this)&=a; }

template<int N>
BitArray<N>& BitArray< N >::operator &= ( const BitArray< N > &  a  )  [inline]

Definition at line 417 of file BitArray.h.

00417                                                  {
00418     for(int i = 0;i<this->nWords();i++) {
00419       this->dataWord(i) &= a.dataWord(i);
00420     }
00421     return *this;
00422   }    

template<int N>
BitArray<N>& BitArray< N >::operator &= ( const BitArray< N > &  a  )  [inline]

Definition at line 416 of file BitArray.h.

00416                                                  {
00417     for(int i = 0;i<this->nWords();i++) {
00418       this->dataWord(i) &= a.dataWord(i);
00419     }
00420     return *this;
00421   }    

template<int N>
bool BitArray< N >::operator!= ( const BitArray< N > &  a  )  const [inline]

Definition at line 394 of file BitArray.h.

00394 { return !(a==*this); }

template<int N>
bool BitArray< N >::operator!= ( const BitArray< N > &  a  )  const [inline]

Definition at line 393 of file BitArray.h.

00393 { return !(a==*this); }

template<int N>
BitArray<N> BitArray< N >::operator+ ( const BitArray< N > &  a  )  [inline]

Definition at line 489 of file BitArray.h.

00489 {return BitArray<N> (*this)+=a; }

template<int N>
BitArray<N> BitArray< N >::operator+ ( const BitArray< N > &  a  )  [inline]

Definition at line 488 of file BitArray.h.

00488 {return BitArray<N> (*this)+=a; }

template<int N>
BitArray<N>& BitArray< N >::operator++ ( int   )  [inline]

Definition at line 492 of file BitArray.h.

00492                                {
00493     int i = 0;
00494     while(i<this->nBits()&&this->element(i)==1) { this->unset(i); i++; }
00495     if(i<this->nBits())this->set(i);
00496     return *this;
00497   }

template<int N>
BitArray<N>& BitArray< N >::operator++ ( int   )  [inline]

Definition at line 491 of file BitArray.h.

00491                                {
00492     int i = 0;
00493     while(i<this->nBits()&&this->element(i)==1) { this->unset(i); i++; }
00494     if(i<this->nBits())this->set(i);
00495     return *this;
00496   }

template<int N>
BitArray<N>& BitArray< N >::operator+= ( const BitArray< N > &  a  )  [inline]

Definition at line 476 of file BitArray.h.

00476                                                 {
00477     int rep=0;
00478     int sum=0;
00479     for(int i=0;i<this->nBits();i++) {
00480       sum=this->element(i)^rep;
00481       rep=this->element(i)&rep;
00482       this->set(i,sum^a.element(i));
00483       rep|=(sum&a.element(i));
00484     }
00485     return *this;
00486   }

template<int N>
BitArray<N>& BitArray< N >::operator+= ( const BitArray< N > &  a  )  [inline]

Definition at line 475 of file BitArray.h.

00475                                                 {
00476     int rep=0;
00477     int sum=0;
00478     for(int i=0;i<this->nBits();i++) {
00479       sum=this->element(i)^rep;
00480       rep=this->element(i)&rep;
00481       this->set(i,sum^a.element(i));
00482       rep|=(sum&a.element(i));
00483     }
00484     return *this;
00485   }

template<int N>
BitArray<N> BitArray< N >::operator- ( const BitArray< N > &  a  )  [inline]

Definition at line 515 of file BitArray.h.

00515 {return BitArray<N> (*this)-=a; }

template<int N>
BitArray<N> BitArray< N >::operator- ( const BitArray< N > &  a  )  [inline]

Definition at line 514 of file BitArray.h.

00514 {return BitArray<N> (*this)-=a; }

template<int N>
BitArray<N>& BitArray< N >::operator-= ( const BitArray< N > &  a  )  [inline]

Definition at line 510 of file BitArray.h.

00510                                                 {
00511     return *this+=a.twoComplement();
00512   }

template<int N>
BitArray<N>& BitArray< N >::operator-= ( const BitArray< N > &  a  )  [inline]

Definition at line 509 of file BitArray.h.

00509                                                 {
00510     return *this+=a.twoComplement();
00511   }

template<int N>
bool BitArray< N >::operator< ( const BitArray< N > &  a  )  const [inline]

Definition at line 371 of file BitArray.h.

00371                                              {
00372     int nw = this->nWords();
00373     int ub = this->unusedBits();
00374     unsigned aaa = this->dataWord(nw-1)<<ub; // ignore unused bits
00375     unsigned bbb =     a.dataWord(nw-1)<<ub; // in both operands
00376     if        (aaa<bbb) {
00377       return 1;
00378     } else if (aaa>bbb) {
00379       return 0;
00380     }
00381     if(nw>1){
00382       for (int iw=nw-2;iw>=0;iw--){
00383         if        (this->dataWord(iw)<a.dataWord(iw)) {
00384           return 1;
00385         } else if (this->dataWord(iw)>a.dataWord(iw)) {
00386           return 0;
00387         }
00388       }
00389     }
00390     return 0;
00391   }

template<int N>
bool BitArray< N >::operator< ( const BitArray< N > &  a  )  const [inline]

Definition at line 370 of file BitArray.h.

00370                                              {
00371     int nw = this->nWords();
00372     int ub = this->unusedBits();
00373     unsigned aaa = this->dataWord(nw-1)<<ub; // ignore unused bits
00374     unsigned bbb =     a.dataWord(nw-1)<<ub; // in both operands
00375     if        (aaa<bbb) {
00376       return 1;
00377     } else if (aaa>bbb) {
00378       return 0;
00379     }
00380     if(nw>1){
00381       for (int iw=nw-2;iw>=0;iw--){
00382         if        (this->dataWord(iw)<a.dataWord(iw)) {
00383           return 1;
00384         } else if (this->dataWord(iw)>a.dataWord(iw)) {
00385           return 0;
00386         }
00387       }
00388     }
00389     return 0;
00390   }

template<int N>
BitArray<N> BitArray< N >::operator<< ( const int  n  )  [inline]

Definition at line 460 of file BitArray.h.

00460 { return BitArray<N> (*this)<<=n; }

template<int N>
BitArray<N> BitArray< N >::operator<< ( const int  n  )  [inline]

Definition at line 459 of file BitArray.h.

00459 { return BitArray<N> (*this)<<=n; }

template<int N>
BitArray<N>& BitArray< N >::operator<<= ( const int  n  )  [inline]

Definition at line 450 of file BitArray.h.

00450                                         {
00451     assert(n>=0&&n<this->nBits());
00452     if(n==0)return *this;
00453     int i=0;
00454     for(i=this->nBits()-1;i>=n;i--) this->set(i,this->element(i-n));
00455     for(i=n-1;i>=0;i--) this->unset(i);
00456     return *this;
00457   }

template<int N>
BitArray<N>& BitArray< N >::operator<<= ( const int  n  )  [inline]

Definition at line 449 of file BitArray.h.

00449                                         {
00450     assert(n>=0&&n<this->nBits());
00451     if(n==0)return *this;
00452     int i=0;
00453     for(i=this->nBits()-1;i>=n;i--) this->set(i,this->element(i-n));
00454     for(i=n-1;i>=0;i--) this->unset(i);
00455     return *this;
00456   }

template<int N>
bool BitArray< N >::operator<= ( const BitArray< N > &  a  )  const [inline]

Definition at line 403 of file BitArray.h.

00403 { return !(*this>a); }

template<int N>
bool BitArray< N >::operator<= ( const BitArray< N > &  a  )  const [inline]

Definition at line 402 of file BitArray.h.

00402 { return !(*this>a); }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const char *  str  )  [inline]

Definition at line 328 of file BitArray.h.

00328                                           {
00329     this->zero();
00330     for(int i=0; i<this->nBits();i++){
00331       assert(str[i]=='1'||str[i]=='0');  
00332       if(str[i]=='1') {
00333         this->set(this->nBits()-i-1);   // reading a string from left to right 
00334       } else if(str[i]=='0') {    // --> most significative bit is the one 
00335         this->unset(this->nBits()-i-1); // with lower string index
00336       } else {
00337         break;                    // exit when find a char which is not 0 or 1
00338       }
00339     }
00340     this->cleanUnused();
00341     return *this;
00342   }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const unsigned  i  )  [inline]

Definition at line 307 of file BitArray.h.

00307                                            {
00308     this->zero();
00309     _data[0] = i;                 // the nBit least sign. bits are considered
00310     this->cleanUnused();
00311     return *this;
00312   }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const BitArray< N > &  a  )  [inline]

Definition at line 296 of file BitArray.h.

00296                                                {
00297     if(this != &a) {
00298       for (int i=0;i<this->nWords();i++) {
00299         _data[i] = a._data[i];
00300       }
00301     }
00302     this->cleanUnused();
00303     return *this;
00304   }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const char *  str  )  [inline]

Definition at line 327 of file BitArray.h.

00327                                           {
00328     this->zero();
00329     for(int i=0; i<this->nBits();i++){
00330       assert(str[i]=='1'||str[i]=='0');  
00331       if(str[i]=='1') {
00332         this->set(this->nBits()-i-1);   // reading a string from left to right 
00333       } else if(str[i]=='0') {    // --> most significative bit is the one 
00334         this->unset(this->nBits()-i-1); // with lower string index
00335       } else {
00336         break;                    // exit when find a char which is not 0 or 1
00337       }
00338     }
00339     this->cleanUnused();
00340     return *this;
00341   }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const unsigned  i  )  [inline]

Definition at line 306 of file BitArray.h.

00306                                            {
00307     this->zero();
00308     _data[0] = i;                 // the nBit least sign. bits are considered
00309     this->cleanUnused();
00310     return *this;
00311   }

template<int N>
BitArray<N>& BitArray< N >::operator= ( const BitArray< N > &  a  )  [inline]

Definition at line 295 of file BitArray.h.

00295                                                {
00296     if(this != &a) {
00297       for (int i=0;i<this->nWords();i++) {
00298         _data[i] = a._data[i];
00299       }
00300     }
00301     this->cleanUnused();
00302     return *this;
00303   }

template<int N>
bool BitArray< N >::operator== ( const BitArray< N > &  a  )  const [inline]

Definition at line 357 of file BitArray.h.

00357                                               {
00358    int nw = this->nWords();
00359     int ub = this->unusedBits();
00360     if(this->dataWord(nw-1)<<ub!=         // check last word
00361            a.dataWord(nw-1)<<ub)return 0;
00362     if(nw>1){
00363       for (int iw=0;iw<nw-1;iw++){
00364         if(this->dataWord(iw)!=a.dataWord(iw)) return 0;
00365       }
00366     }
00367     return 1;
00368   }

template<int N>
bool BitArray< N >::operator== ( const BitArray< N > &  a  )  const [inline]

Definition at line 356 of file BitArray.h.

00356                                               {
00357    int nw = this->nWords();
00358     int ub = this->unusedBits();
00359     if(this->dataWord(nw-1)<<ub!=         // check last word
00360            a.dataWord(nw-1)<<ub)return 0;
00361     if(nw>1){
00362       for (int iw=0;iw<nw-1;iw++){
00363         if(this->dataWord(iw)!=a.dataWord(iw)) return 0;
00364       }
00365     }
00366     return 1;
00367   }

template<int N>
bool BitArray< N >::operator> ( const BitArray< N > &  a  )  const [inline]

Definition at line 400 of file BitArray.h.

00400 { return !(*this<a||*this==a); }

template<int N>
bool BitArray< N >::operator> ( const BitArray< N > &  a  )  const [inline]

Definition at line 399 of file BitArray.h.

00399 { return !(*this<a||*this==a); }

template<int N>
bool BitArray< N >::operator>= ( const BitArray< N > &  a  )  const [inline]

Definition at line 397 of file BitArray.h.

00397 { return !(*this<a); }

template<int N>
bool BitArray< N >::operator>= ( const BitArray< N > &  a  )  const [inline]

Definition at line 396 of file BitArray.h.

00396 { return !(*this<a); }

template<int N>
BitArray<N> BitArray< N >::operator>> ( const int  n  )  [inline]

Definition at line 473 of file BitArray.h.

00473 { return BitArray<N> (*this)>>=n; }

template<int N>
BitArray<N> BitArray< N >::operator>> ( const int  n  )  [inline]

Definition at line 472 of file BitArray.h.

00472 { return BitArray<N> (*this)>>=n; }

template<int N>
BitArray<N>& BitArray< N >::operator>>= ( const int  n  )  [inline]

Definition at line 463 of file BitArray.h.

00463                                         {
00464     assert(n>=0&&n<this->nBits());
00465     if(n==0)return *this;
00466     int i=0;
00467     for(i=0;i<this->nBits()-n;i++) this->set(i,this->element(i+n));
00468     for(i=this->nBits()-n;i<this->nBits();i++) this->unset(i);
00469     return *this;
00470   }

template<int N>
BitArray<N>& BitArray< N >::operator>>= ( const int  n  )  [inline]

Definition at line 462 of file BitArray.h.

00462                                         {
00463     assert(n>=0&&n<this->nBits());
00464     if(n==0)return *this;
00465     int i=0;
00466     for(i=0;i<this->nBits()-n;i++) this->set(i,this->element(i+n));
00467     for(i=this->nBits()-n;i<this->nBits();i++) this->unset(i);
00468     return *this;
00469   }

template<int N>
int BitArray< N >::operator[] ( const int  pos  )  const [inline]

Definition at line 354 of file BitArray.h.

00354 { return element(pos); }

template<int N>
refToBit BitArray< N >::operator[] ( const int  pos  )  [inline]

Definition at line 353 of file BitArray.h.

00353 { return refToBit(*this,pos); }

template<int N>
int BitArray< N >::operator[] ( const int  pos  )  const [inline]

Definition at line 353 of file BitArray.h.

00353 { return element(pos); }

template<int N>
refToBit BitArray< N >::operator[] ( const int  pos  )  [inline]

Definition at line 352 of file BitArray.h.

00352 { return refToBit(*this,pos); }

template<int N>
BitArray<N> BitArray< N >::operator^ ( const BitArray< N > &  a  )  [inline]

Definition at line 447 of file BitArray.h.

00447 {return BitArray<N> (*this)^=a; }

template<int N>
BitArray<N> BitArray< N >::operator^ ( const BitArray< N > &  a  )  [inline]

Definition at line 446 of file BitArray.h.

00446 {return BitArray<N> (*this)^=a; }

template<int N>
BitArray<N>& BitArray< N >::operator^= ( const BitArray< N > &  a  )  [inline]

Definition at line 439 of file BitArray.h.

00439                                                 {
00440     for(int i = 0;i<this->nWords();i++) {
00441       this->dataWord(i) ^= a.dataWord(i);
00442     }
00443     return *this;
00444   }    

template<int N>
BitArray<N>& BitArray< N >::operator^= ( const BitArray< N > &  a  )  [inline]

Definition at line 438 of file BitArray.h.

00438                                                 {
00439     for(int i = 0;i<this->nWords();i++) {
00440       this->dataWord(i) ^= a.dataWord(i);
00441     }
00442     return *this;
00443   }    

template<int N>
BitArray<N> BitArray< N >::operator| ( const BitArray< N > &  a  )  [inline]

Definition at line 436 of file BitArray.h.

00436 {return BitArray<N> (*this)|=a;}

template<int N>
BitArray<N> BitArray< N >::operator| ( const BitArray< N > &  a  )  [inline]

Definition at line 435 of file BitArray.h.

00435 {return BitArray<N> (*this)|=a;}

template<int N>
BitArray<N>& BitArray< N >::operator|= ( const BitArray< N > &  a  )  [inline]

Definition at line 428 of file BitArray.h.

00428                                                 {
00429     for(int i = 0;i<this->nWords();i++) {
00430       this->dataWord(i) |= a.dataWord(i);
00431     }
00432     return *this;
00433   }    

template<int N>
BitArray<N>& BitArray< N >::operator|= ( const BitArray< N > &  a  )  [inline]

Definition at line 427 of file BitArray.h.

00427                                                 {
00428     for(int i = 0;i<this->nWords();i++) {
00429       this->dataWord(i) |= a.dataWord(i);
00430     }
00431     return *this;
00432   }    

template<int N>
BitArray<N> BitArray< N >::operator~ (  )  const [inline]

Definition at line 414 of file BitArray.h.

00414 { return BitArray<N> (*this).flip(); }

template<int N>
BitArray<N> BitArray< N >::operator~ (  )  const [inline]

Definition at line 413 of file BitArray.h.

00413 { return BitArray<N> (*this).flip(); }

template<int N>
std::ostream& BitArray< N >::print ( std::ostream &  o = std::cout  )  const [inline]

Definition at line 345 of file BitArray.h.

00345                                                   {
00346     for(int i = this->nBits()-1; i>=0; i--){
00347       o << this->element(i);
00348     }
00349     return o;
00350   }

template<int N>
std::ostream& BitArray< N >::print ( std::ostream &  o = std::cout  )  const [inline]

Definition at line 344 of file BitArray.h.

Referenced by DTBtiChip::keepTrig(), DTBtiChip::keepTrigPatt(), DTTSCand::print(), DTConfigTSPhi::print(), and DTSectCollPhCand::print().

00344                                                   {
00345     for(int i = this->nBits()-1; i>=0; i--){
00346       o << this->element(i);
00347     }
00348     return o;
00349   }

template<int N>
unsigned BitArray< N >::read ( const int  p,
const int  n 
) const [inline]

Definition at line 275 of file BitArray.h.

00275                                                 {
00276     assert(p>=0 && p+n<=this->nBits());  
00277     assert(n<=32); // the output must fit in a 32 bit word
00278     // only the n least significant bits of val are considered
00279     unsigned out=0x0;
00280     for(int i=0; i<n;i++){
00281       if(this->test(p+i)) out |= 1<<i;
00282     }
00283     return out;
00284   }

template<int N>
unsigned BitArray< N >::read ( const int  p,
const int  n 
) const [inline]

Definition at line 274 of file BitArray.h.

Referenced by DTTracoChip::insideAngWindow().

00274                                                 {
00275     assert(p>=0 && p+n<=this->nBits());  
00276     assert(n<=32); // the output must fit in a 32 bit word
00277     // only the n least significant bits of val are considered
00278     unsigned out=0x0;
00279     for(int i=0; i<n;i++){
00280       if(this->test(p+i)) out |= 1<<i;
00281     }
00282     return out;
00283   }

template<int N>
void BitArray< N >::reset ( const int  i  )  [inline]

Definition at line 232 of file BitArray.h.

00232 { this->unset(i); }

template<int N>
void BitArray< N >::reset ( void   )  [inline]

Definition at line 221 of file BitArray.h.

00221 { zero(); }

template<int N>
void BitArray< N >::reset ( const int  i  )  [inline]

Definition at line 231 of file BitArray.h.

00231 { this->unset(i); }

template<int N>
void BitArray< N >::reset ( void   )  [inline]

Definition at line 220 of file BitArray.h.

Referenced by DTBtiChip::keepTrigPatt().

00220 { zero(); }

template<int N>
void BitArray< N >::set ( const int  i,
const char *  str 
) [inline]

Definition at line 236 of file BitArray.h.

00236 { this->assign(i,1,str); }

template<int N>
void BitArray< N >::set ( const int  i,
const int  val 
) [inline]

Definition at line 235 of file BitArray.h.

00235 { this->assign(i,1,val); }

template<int N>
void BitArray< N >::set ( const int  i  )  [inline]

Definition at line 230 of file BitArray.h.

00230 { getWord(i) |= getPosMask(i); }

template<int N>
void BitArray< N >::set ( const int  i,
const char *  str 
) [inline]

Definition at line 235 of file BitArray.h.

00235 { this->assign(i,1,str); }

template<int N>
void BitArray< N >::set ( const int  i,
const int  val 
) [inline]

Definition at line 234 of file BitArray.h.

00234 { this->assign(i,1,val); }

template<int N>
void BitArray< N >::set ( const int  i  )  [inline]

Definition at line 229 of file BitArray.h.

Referenced by DTBtiChip::acceptMask(), DTTSTheta::add_btiT(), DTTracoChip::add_btiT(), DTBtiChip::keepTrig(), DTBtiChip::keepTrigPatt(), DTTracoChip::raiseOverlap(), DTTracoChip::run(), DTConfigTraco::setDefaults(), DTConfigBti::setDefaults(), DTTracoChip::setFlag(), DTTSCand::setSecondTrack(), and DTSectCollPhCand::setSecondTrack().

00229 { getWord(i) |= getPosMask(i); }

template<int N>
int BitArray< N >::size ( void   )  const [inline]

Definition at line 122 of file BitArray.h.

00122 { return this->nBits(); }

template<int N>
int BitArray< N >::size ( void   )  const [inline]

Definition at line 121 of file BitArray.h.

00121 { return this->nBits(); }

template<int N>
int BitArray< N >::test ( const int  i  )  const [inline]

Definition at line 213 of file BitArray.h.

00213 { return element(i); }

template<int N>
int BitArray< N >::test ( const int  i  )  const [inline]

Definition at line 212 of file BitArray.h.

00212 { return element(i); }

template<int N>
BitArray<N>& BitArray< N >::twoComplement (  )  [inline]

Definition at line 503 of file BitArray.h.

00503                                { 
00504     (*this).flip();
00505     (*this)++;
00506     return *this;
00507   }

template<int N>
BitArray<N> BitArray< N >::twoComplement (  )  const [inline]

Definition at line 500 of file BitArray.h.

00500 { return BitArray<N> (~*this)++; }

template<int N>
BitArray<N>& BitArray< N >::twoComplement (  )  [inline]

Definition at line 502 of file BitArray.h.

00502                                { 
00503     (*this).flip();
00504     (*this)++;
00505     return *this;
00506   }

template<int N>
BitArray<N> BitArray< N >::twoComplement (  )  const [inline]

Definition at line 499 of file BitArray.h.

Referenced by DTTracoChip::insideAngWindow(), and BitArray< 9 >::operator-=().

00499 { return BitArray<N> (~*this)++; }

template<int N>
void BitArray< N >::unset ( const int  i  )  [inline]

Definition at line 231 of file BitArray.h.

00231 { getWord(i) &= ~getPosMask(i); }

template<int N>
void BitArray< N >::unset ( const int  i  )  [inline]

Definition at line 230 of file BitArray.h.

Referenced by BitArray< 9 >::assign(), DTSectCollPhCand::DTSectCollPhCand(), DTTSCand::DTTSCand(), BitArray< 9 >::operator++(), BitArray< 9 >::operator=(), BitArray< 9 >::reset(), DTTSCand::setBitsBkmod(), DTSectCollPhCand::setBitsSectColl(), DTTSCand::setBitsTsm(), DTTSCand::setBitsTss(), and DTConfigTSPhi::setDefaults().

00230 { getWord(i) &= ~getPosMask(i); }

template<int N>
int BitArray< N >::unusedBits (  )  const [inline]

Definition at line 159 of file BitArray.h.

00159                          {
00160     if(this->nBits()==0)return 32;
00161     return 31-((this->nBits()-1)%32);
00162   }

template<int N>
int BitArray< N >::unusedBits (  )  const [inline]

Definition at line 158 of file BitArray.h.

Referenced by BitArray< 9 >::any(), BitArray< 9 >::none(), BitArray< 9 >::operator<(), and BitArray< 9 >::operator==().

00158                          {
00159     if(this->nBits()==0)return 32;
00160     return 31-((this->nBits()-1)%32);
00161   }

template<int N>
void BitArray< N >::zero (  )  [inline]

Definition at line 216 of file BitArray.h.

00216               {
00217     for (int i=0;i<this->nWords();i++) {
00218       _data[i] = 0x0;                // set to 0
00219     }
00220   }

template<int N>
void BitArray< N >::zero (  )  [inline]

Definition at line 215 of file BitArray.h.

Referenced by BitArray< 9 >::BitArray(), DTTracoChip::clear(), DTTracoChip::DTTracoChip(), DTTSTheta::DTTSTheta(), DTTSTheta::localClear(), BitArray< 9 >::operator=(), and BitArray< 9 >::reset().

00215               {
00216     for (int i=0;i<this->nWords();i++) {
00217       _data[i] = 0x0;                // set to 0
00218     }
00219   }


Friends And Related Function Documentation

template<int N>
refToBit [friend]

Definition at line 33 of file BitArray.h.

Referenced by BitArray< 9 >::operator[]().


Member Data Documentation

template<int N>
unsigned BitArray< N >::_data [private]

Definition at line 518 of file BitArray.h.

Referenced by BitArray< 9 >::BitArray(), BitArray< 9 >::byte(), BitArray< 9 >::cleanUnused(), BitArray< 9 >::dataWord(), BitArray< 9 >::flip(), BitArray< 9 >::getWord(), BitArray< 9 >::one(), BitArray< 9 >::operator=(), and BitArray< 9 >::zero().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:15:02 2009 for CMSSW by  doxygen 1.5.4