CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Friends
DTTFBitArray< N > Class Template Reference

#include <DTTFBitArray.h>

Classes

class  refToBit
 

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

unsigned _data [N/32+1]
 

Friends

class refToBit
 

Detailed Description

template<int N>
class DTTFBitArray< N >

Definition at line 30 of file DTTFBitArray.h.

Constructor & Destructor Documentation

template<int N>
DTTFBitArray< N >::DTTFBitArray ( )
inline

Definition at line 83 of file DTTFBitArray.h.

References DTTFBitArray< N >::zero().

83 {this->zero();}
template<int N>
DTTFBitArray< N >::DTTFBitArray ( const DTTFBitArray< N > &  br)
inline

Definition at line 85 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, DTTFBitArray< N >::cleanUnused(), i, and DTTFBitArray< N >::nWords().

85  {
86  for (int i=0;i<this->nWords();i++) {
87  _data[i] = br._data[i];
88  }
89  this->cleanUnused();
90  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
DTTFBitArray< N >::DTTFBitArray ( const char *  str)
inline

Definition at line 91 of file DTTFBitArray.h.

References DTTFBitArray< N >::assign(), DTTFBitArray< N >::cleanUnused(), DTTFBitArray< N >::nBits(), and DTTFBitArray< N >::zero().

91  {
92  this->zero();
93  this->assign(0,this->nBits(),str);
94  this->cleanUnused();
95  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int nBits() const
Definition: DTTFBitArray.h:121
void assign(const int p, const int n, const int val)
Definition: DTTFBitArray.h:239
template<int N>
DTTFBitArray< N >::DTTFBitArray ( const char *  str,
const int  p,
const int  n 
)
inline

Definition at line 96 of file DTTFBitArray.h.

References DTTFBitArray< N >::assign(), and DTTFBitArray< N >::zero().

96  {
97  this->zero();
98  this->assign(p, n, str);
99  }
void assign(const int p, const int n, const int val)
Definition: DTTFBitArray.h:239
template<int N>
DTTFBitArray< N >::DTTFBitArray ( const unsigned  i)
inline

Definition at line 100 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, DTTFBitArray< N >::cleanUnused(), i, and DTTFBitArray< N >::zero().

100  {
101  this->zero();
102  _data[0] = i; // the nBit least sign. bits are considered
103  this->cleanUnused();
104  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int i
Definition: DBlmapReader.cc:9
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519

Member Function Documentation

template<int N>
int DTTFBitArray< N >::any ( )
inline

Definition at line 184 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), DTTFBitArray< N >::nWords(), and DTTFBitArray< N >::unusedBits().

184  {
185  int nw = this->nWords();
186  int ub = unusedBits();
187  if(this->dataWord(nw-1)<<ub!=0)return 1;
188  if(nw>1){
189  for (int iw=0;iw<nw-1;iw++){
190  if(this->dataWord(iw)!=0) return 1;
191  }
192  }
193  return 0;
194  }
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
int unusedBits() const
Definition: DTTFBitArray.h:159
template<int N>
void DTTFBitArray< N >::assign ( const int  p,
const int  n,
const int  val 
)
inline

Definition at line 239 of file DTTFBitArray.h.

References i, n, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

Referenced by DTTFBitArray< N >::DTTFBitArray(), and DTTFBitArray< N >::set().

239  {
240  assert(p>=0 && p+n<=this->nBits());
241  // only the n least significant bits of val are considered
242  for(int i=0; i<n;i++){
243  if(val>>i&1) {
244  this->set(p+i);
245  } else {
246  this->unset(p+i);
247  }
248  }
249  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
void DTTFBitArray< N >::assign ( const int  p,
const int  n,
const DTTFBitArray< N > &  val 
)
inline

Definition at line 250 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, n, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

250  {
251  assert(p>=0 && p+n<=this->nBits());
252  // only the n least significant bits of val are considered
253  for(int i=0; i<n;i++){
254  if(val.element(i)) {
255  this->set(p+i);
256  } else {
257  this->unset(p+i);
258  }
259  }
260  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
void DTTFBitArray< N >::assign ( const int  p,
const int  n,
const char *  str 
)
inline

Definition at line 261 of file DTTFBitArray.h.

References i, n, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

261  {
262  assert(p>=0 && p+n<=this->nBits());
263  // only the n least significant bits of val are considered
264  for(int i=0; i<n;i++){
265  assert(str[i]=='1'||str[i]=='0');
266  if(str[i]=='1') {
267  this->set(p+n-i-1); // reading a string from left to right
268  } else { // --> most significative bit is the one
269  this->unset(p+n-i-1); // with lower string index
270  }
271  }
272  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
DTTFBitArray<8> DTTFBitArray< N >::byte ( const int  i) const
inline

Definition at line 287 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, gen::k, DTTFBitArray< N >::nWords(), and dbtoconf::out.

287  {
289  if(i>=0&&i<4*this->nWords()){
290  unsigned k=(_data[i/4]>>8*(i%4))&0xff;
291  out=k;
292  }
293  return out;
294  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
int k[5][pyjets_maxn]
tuple out
Definition: dbtoconf.py:99
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
void DTTFBitArray< N >::cleanUnused ( )
inline

Definition at line 170 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, DTTFBitArray< N >::lastWordMask(), and DTTFBitArray< N >::nWords().

Referenced by DTTFBitArray< N >::DTTFBitArray(), and DTTFBitArray< N >::operator=().

170  {
171  _data[this->nWords()-1] &= (this->lastWordMask());
172  }
int nWords() const
Definition: DTTFBitArray.h:125
unsigned lastWordMask() const
Definition: DTTFBitArray.h:165
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
int DTTFBitArray< N >::count ( void  ) const
inline

Definition at line 175 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, n, and DTTFBitArray< N >::nBits().

175  {
176  int n=0;
177  for(int i=0;i<this->nBits();i++) {
178  if(this->element(i))n++;
179  }
180  return n;
181  }
int i
Definition: DBlmapReader.cc:9
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
unsigned DTTFBitArray< N >::dataWord ( const int  i) const
inline
template<int N>
unsigned& DTTFBitArray< N >::dataWord ( const int  i)
inline

Definition at line 132 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, i, and DTTFBitArray< N >::nWords().

132  {
133  assert(i>=0 && i<this->nWords());
134  return _data[i];
135  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
int DTTFBitArray< N >::element ( const int  pos) const
inline
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::flip ( )
inline

Definition at line 406 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, i, and DTTFBitArray< N >::nWords().

Referenced by DTTFBitArray< N >::operator~().

406  {
407  for(int i=0;i<this->nWords();i++) {
408  _data[i] = ~_data[i];
409  }
410  return *this;
411  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
static int DTTFBitArray< N >::getPosInWord ( const int  pos)
inlinestatic

Definition at line 148 of file DTTFBitArray.h.

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

148  {
149  // assert(pos>=0&& pos<this->nBits());
150  return pos%32;
151  }
template<int N>
static unsigned DTTFBitArray< N >::getPosMask ( const int  pos)
inlinestatic
template<int N>
unsigned& DTTFBitArray< N >::getWord ( const int  pos)
inline

Definition at line 138 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, and DTTFBitArray< N >::nBits().

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

138  {
139  assert(pos>=0&& pos<this->nBits());
140  return _data[pos/32];
141  }
int nBits() const
Definition: DTTFBitArray.h:121
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
unsigned DTTFBitArray< N >::getWord ( const int  pos) const
inline

Definition at line 142 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, and DTTFBitArray< N >::nBits().

142  {
143  assert(pos>=0&& pos<this->nBits());
144  return _data[pos/32];
145  }
int nBits() const
Definition: DTTFBitArray.h:121
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
unsigned DTTFBitArray< N >::lastWordMask ( ) const
inline

Definition at line 165 of file DTTFBitArray.h.

References DTTFBitArray< N >::unusedBits().

Referenced by DTTFBitArray< N >::cleanUnused().

165  {
166  return static_cast<unsigned>(0xffffffff)>>(this->unusedBits());
167  }
int unusedBits() const
Definition: DTTFBitArray.h:159
template<int N>
int DTTFBitArray< N >::nBits ( ) const
inline
template<int N>
int DTTFBitArray< N >::none ( )
inline

Definition at line 197 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), DTTFBitArray< N >::nWords(), and DTTFBitArray< N >::unusedBits().

197  {
198  int nw = this->nWords();
199  int ub = unusedBits();
200  if(this->dataWord(nw-1)<<ub!=0xffffffff)return 1;
201  if(nw>1){
202  for (int iw=0;iw<nw-1;iw++){
203  if(this->dataWord(iw)!=0xffffffff) return 1;
204  }
205  }
206  return 0;
207  }
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
int unusedBits() const
Definition: DTTFBitArray.h:159
template<int N>
int DTTFBitArray< N >::nWords ( ) const
inline
template<int N>
void DTTFBitArray< N >::one ( )
inline

Definition at line 223 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, i, and DTTFBitArray< N >::nWords().

Referenced by runEdmFileComparison.EdmObject::label().

223  {
224  for (int i=0;i<this->nWords();i++) {
225  _data[i] = 0xffffffff; // set to 1
226  }
227  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
bool DTTFBitArray< N >::operator!= ( const DTTFBitArray< N > &  a) const
inline

Definition at line 394 of file DTTFBitArray.h.

394 { return !(a==*this); }
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator& ( const DTTFBitArray< N > &  a)
inline

Definition at line 425 of file DTTFBitArray.h.

References a.

425 {return DTTFBitArray<N> (*this)&=a; }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator&= ( const DTTFBitArray< N > &  a)
inline

Definition at line 417 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), i, and DTTFBitArray< N >::nWords().

417  {
418  for(int i = 0;i<this->nWords();i++) {
419  this->dataWord(i) &= a.dataWord(i);
420  }
421  return *this;
422  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator+ ( const DTTFBitArray< N > &  a)
inline

Definition at line 489 of file DTTFBitArray.h.

References a.

489 {return DTTFBitArray<N> (*this)+=a; }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator++ ( int  )
inline

Definition at line 492 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

492  {
493  int i = 0;
494  while(i<this->nBits()&&this->element(i)==1) { this->unset(i); i++; }
495  if(i<this->nBits())this->set(i);
496  return *this;
497  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator+= ( const DTTFBitArray< N > &  a)
inline

Definition at line 476 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, DTTFBitArray< N >::nBits(), and DTTFBitArray< N >::set().

476  {
477  int rep=0;
478  int sum=0;
479  for(int i=0;i<this->nBits();i++) {
480  sum=this->element(i)^rep;
481  rep=this->element(i)&rep;
482  this->set(i,sum^a.element(i));
483  rep|=(sum&a.element(i));
484  }
485  return *this;
486  }
int i
Definition: DBlmapReader.cc:9
void set(const int i)
Definition: DTTFBitArray.h:230
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator- ( const DTTFBitArray< N > &  a)
inline

Definition at line 515 of file DTTFBitArray.h.

References a.

515 {return DTTFBitArray<N> (*this)-=a; }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator-= ( const DTTFBitArray< N > &  a)
inline

Definition at line 510 of file DTTFBitArray.h.

References DTTFBitArray< N >::twoComplement().

510  {
511  return *this+=a.twoComplement();
512  }
DTTFBitArray< N > twoComplement() const
Definition: DTTFBitArray.h:500
template<int N>
bool DTTFBitArray< N >::operator< ( const DTTFBitArray< N > &  a) const
inline

Definition at line 371 of file DTTFBitArray.h.

References a, DTTFBitArray< N >::dataWord(), DTTFBitArray< N >::nWords(), and DTTFBitArray< N >::unusedBits().

371  {
372  int nw = this->nWords();
373  int ub = this->unusedBits();
374  unsigned aaa = this->dataWord(nw-1)<<ub; // ignore unused bits
375  unsigned bbb = a.dataWord(nw-1)<<ub; // in both operands
376  if (aaa<bbb) {
377  return 1;
378  } else if (aaa>bbb) {
379  return 0;
380  }
381  if(nw>1){
382  for (int iw=nw-2;iw>=0;iw--){
383  if (this->dataWord(iw)<a.dataWord(iw)) {
384  return 1;
385  } else if (this->dataWord(iw)>a.dataWord(iw)) {
386  return 0;
387  }
388  }
389  }
390  return 0;
391  }
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
int unusedBits() const
Definition: DTTFBitArray.h:159
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator<< ( const int  n)
inline

Definition at line 460 of file DTTFBitArray.h.

References n.

460 { return DTTFBitArray<N> (*this)<<=n; }
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator<<= ( const int  n)
inline

Definition at line 450 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, n, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

450  {
451  assert(n>=0&&n<this->nBits());
452  if(n==0)return *this;
453  int i=0;
454  for(i=this->nBits()-1;i>=n;i--) this->set(i,this->element(i-n));
455  for(i=n-1;i>=0;i--) this->unset(i);
456  return *this;
457  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
bool DTTFBitArray< N >::operator<= ( const DTTFBitArray< N > &  a) const
inline

Definition at line 403 of file DTTFBitArray.h.

References a.

403 { return !(*this>a); }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator= ( const DTTFBitArray< N > &  a)
inline

Definition at line 296 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, DTTFBitArray< N >::cleanUnused(), i, and DTTFBitArray< N >::nWords().

296  {
297  if(this != &a) {
298  for (int i=0;i<this->nWords();i++) {
299  _data[i] = a._data[i];
300  }
301  }
302  this->cleanUnused();
303  return *this;
304  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator= ( const unsigned  i)
inline

Definition at line 307 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, DTTFBitArray< N >::cleanUnused(), i, and DTTFBitArray< N >::zero().

307  {
308  this->zero();
309  _data[0] = i; // the nBit least sign. bits are considered
310  this->cleanUnused();
311  return *this;
312  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int i
Definition: DBlmapReader.cc:9
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator= ( const char *  str)
inline

Definition at line 328 of file DTTFBitArray.h.

References DTTFBitArray< N >::cleanUnused(), i, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), DTTFBitArray< N >::unset(), and DTTFBitArray< N >::zero().

328  {
329  this->zero();
330  for(int i=0; i<this->nBits();i++){
331  assert(str[i]=='1'||str[i]=='0');
332  if(str[i]=='1') {
333  this->set(this->nBits()-i-1); // reading a string from left to right
334  } else if(str[i]=='0') { // --> most significative bit is the one
335  this->unset(this->nBits()-i-1); // with lower string index
336  } else {
337  break; // exit when find a char which is not 0 or 1
338  }
339  }
340  this->cleanUnused();
341  return *this;
342  }
void cleanUnused()
Definition: DTTFBitArray.h:170
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
bool DTTFBitArray< N >::operator== ( const DTTFBitArray< N > &  a) const
inline

Definition at line 357 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), DTTFBitArray< N >::nWords(), and DTTFBitArray< N >::unusedBits().

357  {
358  int nw = this->nWords();
359  int ub = this->unusedBits();
360  if(this->dataWord(nw-1)<<ub!= // check last word
361  a.dataWord(nw-1)<<ub)return 0;
362  if(nw>1){
363  for (int iw=0;iw<nw-1;iw++){
364  if(this->dataWord(iw)!=a.dataWord(iw)) return 0;
365  }
366  }
367  return 1;
368  }
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
int unusedBits() const
Definition: DTTFBitArray.h:159
template<int N>
bool DTTFBitArray< N >::operator> ( const DTTFBitArray< N > &  a) const
inline

Definition at line 400 of file DTTFBitArray.h.

References a.

400 { return !(*this<a||*this==a); }
double a
Definition: hdecay.h:121
template<int N>
bool DTTFBitArray< N >::operator>= ( const DTTFBitArray< N > &  a) const
inline

Definition at line 397 of file DTTFBitArray.h.

References a.

397 { return !(*this<a); }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator>> ( const int  n)
inline

Definition at line 473 of file DTTFBitArray.h.

References n.

473 { return DTTFBitArray<N> (*this)>>=n; }
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator>>= ( const int  n)
inline

Definition at line 463 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, n, DTTFBitArray< N >::nBits(), DTTFBitArray< N >::set(), and DTTFBitArray< N >::unset().

463  {
464  assert(n>=0&&n<this->nBits());
465  if(n==0)return *this;
466  int i=0;
467  for(i=0;i<this->nBits()-n;i++) this->set(i,this->element(i+n));
468  for(i=this->nBits()-n;i<this->nBits();i++) this->unset(i);
469  return *this;
470  }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
void set(const int i)
Definition: DTTFBitArray.h:230
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
refToBit DTTFBitArray< N >::operator[] ( const int  pos)
inline

Definition at line 353 of file DTTFBitArray.h.

References DTTFBitArray< N >::refToBit.

353 { return refToBit(*this,pos); }
friend class refToBit
Definition: DTTFBitArray.h:33
template<int N>
int DTTFBitArray< N >::operator[] ( const int  pos) const
inline

Definition at line 354 of file DTTFBitArray.h.

References DTTFBitArray< N >::element().

354 { return element(pos); }
int element(const int pos) const
Definition: DTTFBitArray.h:210
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator^ ( const DTTFBitArray< N > &  a)
inline

Definition at line 447 of file DTTFBitArray.h.

References a.

447 {return DTTFBitArray<N> (*this)^=a; }
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator^= ( const DTTFBitArray< N > &  a)
inline

Definition at line 439 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), i, and DTTFBitArray< N >::nWords().

439  {
440  for(int i = 0;i<this->nWords();i++) {
441  this->dataWord(i) ^= a.dataWord(i);
442  }
443  return *this;
444  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator| ( const DTTFBitArray< N > &  a)
inline

Definition at line 436 of file DTTFBitArray.h.

References a.

436 {return DTTFBitArray<N> (*this)|=a;}
double a
Definition: hdecay.h:121
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::operator|= ( const DTTFBitArray< N > &  a)
inline

Definition at line 428 of file DTTFBitArray.h.

References DTTFBitArray< N >::dataWord(), i, and DTTFBitArray< N >::nWords().

428  {
429  for(int i = 0;i<this->nWords();i++) {
430  this->dataWord(i) |= a.dataWord(i);
431  }
432  return *this;
433  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:128
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::operator~ ( ) const
inline

Definition at line 414 of file DTTFBitArray.h.

References DTTFBitArray< N >::flip().

414 { return DTTFBitArray<N> (*this).flip(); }
DTTFBitArray< N > & flip()
Definition: DTTFBitArray.h:406
template<int N>
std::ostream& DTTFBitArray< N >::print ( std::ostream &  o = std::cout) const
inline

Definition at line 345 of file DTTFBitArray.h.

References DTTFBitArray< N >::element(), i, DTTFBitArray< N >::nBits(), and connectstrParser::o.

Referenced by L1MuDTPtaLut::print().

345  {
346  for(int i = this->nBits()-1; i>=0; i--){
347  o << this->element(i);
348  }
349  return o;
350  }
int i
Definition: DBlmapReader.cc:9
int element(const int pos) const
Definition: DTTFBitArray.h:210
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
unsigned DTTFBitArray< N >::read ( const int  p,
const int  n 
) const
inline

Definition at line 275 of file DTTFBitArray.h.

References i, n, DTTFBitArray< N >::nBits(), dbtoconf::out, and DTTFBitArray< N >::test().

Referenced by python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::goto(), and python.Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor::setFilterBranches().

275  {
276  assert(p>=0 && p+n<=this->nBits());
277  assert(n<=32); // the output must fit in a 32 bit word
278  // only the n least significant bits of val are considered
279  unsigned out=0x0;
280  for(int i=0; i<n;i++){
281  if(this->test(p+i)) out |= 1<<i;
282  }
283  return out;
284  }
int i
Definition: DBlmapReader.cc:9
int test(const int i) const
Definition: DTTFBitArray.h:213
tuple out
Definition: dbtoconf.py:99
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
void DTTFBitArray< N >::reset ( void  )
inline
template<int N>
void DTTFBitArray< N >::reset ( const int  i)
inline

Definition at line 232 of file DTTFBitArray.h.

References DTTFBitArray< N >::unset().

Referenced by runTheMatrix.MatrixReader::__init__(), and BeautifulSoup.BeautifulStoneSoup::__init__().

232 { this->unset(i); }
int i
Definition: DBlmapReader.cc:9
void unset(const int i)
Definition: DTTFBitArray.h:231
template<int N>
void DTTFBitArray< N >::set ( const int  i)
inline
template<int N>
void DTTFBitArray< N >::set ( const int  i,
const int  val 
)
inline

Definition at line 235 of file DTTFBitArray.h.

References DTTFBitArray< N >::assign().

235 { this->assign(i,1,val); }
int i
Definition: DBlmapReader.cc:9
void assign(const int p, const int n, const int val)
Definition: DTTFBitArray.h:239
template<int N>
void DTTFBitArray< N >::set ( const int  i,
const char *  str 
)
inline

Definition at line 236 of file DTTFBitArray.h.

References DTTFBitArray< N >::assign().

236 { this->assign(i,1,str); }
int i
Definition: DBlmapReader.cc:9
void assign(const int p, const int n, const int val)
Definition: DTTFBitArray.h:239
template<int N>
int DTTFBitArray< N >::size ( void  ) const
inline

Definition at line 122 of file DTTFBitArray.h.

References DTTFBitArray< N >::nBits().

122 { return this->nBits(); }
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
int DTTFBitArray< N >::test ( const int  i) const
inline

Definition at line 213 of file DTTFBitArray.h.

References DTTFBitArray< N >::element().

Referenced by DTTFBitArray< N >::read().

213 { return element(i); }
int i
Definition: DBlmapReader.cc:9
int element(const int pos) const
Definition: DTTFBitArray.h:210
template<int N>
DTTFBitArray<N> DTTFBitArray< N >::twoComplement ( ) const
inline
template<int N>
DTTFBitArray<N>& DTTFBitArray< N >::twoComplement ( )
inline

Definition at line 503 of file DTTFBitArray.h.

503  {
504  (*this).flip();
505  (*this)++;
506  return *this;
507  }
template<int N>
void DTTFBitArray< N >::unset ( const int  i)
inline
template<int N>
int DTTFBitArray< N >::unusedBits ( ) const
inline

Definition at line 159 of file DTTFBitArray.h.

References DTTFBitArray< N >::nBits().

Referenced by DTTFBitArray< N >::any(), DTTFBitArray< N >::lastWordMask(), DTTFBitArray< N >::none(), DTTFBitArray< N >::operator<(), and DTTFBitArray< N >::operator==().

159  {
160  if(this->nBits()==0)return 32;
161  return 31-((this->nBits()-1)%32);
162  }
int nBits() const
Definition: DTTFBitArray.h:121
template<int N>
void DTTFBitArray< N >::zero ( )
inline

Definition at line 216 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, i, and DTTFBitArray< N >::nWords().

Referenced by DTTFBitArray< N >::DTTFBitArray(), DTTFBitArray< N >::operator=(), and DTTFBitArray< N >::reset().

216  {
217  for (int i=0;i<this->nWords();i++) {
218  _data[i] = 0x0; // set to 0
219  }
220  }
int i
Definition: DBlmapReader.cc:9
int nWords() const
Definition: DTTFBitArray.h:125
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:519

Friends And Related Function Documentation

template<int N>
friend class refToBit
friend

Definition at line 33 of file DTTFBitArray.h.

Referenced by DTTFBitArray< N >::operator[]().

Member Data Documentation

template<int N>
unsigned DTTFBitArray< N >::_data[N/32+1]
private