CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Friends
BitArray< N > Class Template Reference

#include <BitArray.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 BitArray< N > &val)
 
void assign (const int p, const int n, const char *str)
 
 BitArray ()
 
 BitArray (const BitArray< N > &br)
 
 BitArray (const char *str)
 
 BitArray (const char *str, const int p, const int n)
 
 BitArray (const unsigned i)
 
BitArray< 8 > byte (const int i) const
 
void cleanUnused ()
 
int count () const
 
unsigned dataWord (const int i) const
 
unsigned & dataWord (const int i)
 
int element (const int pos) const
 
BitArray< 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 ()
 
BitArray< Noperator & (const BitArray< N > &a)
 
BitArray< N > & operator &= (const BitArray< N > &a)
 
bool operator!= (const BitArray< N > &a) const
 
BitArray< Noperator+ (const BitArray< N > &a)
 
BitArray< N > & operator++ (int)
 
BitArray< N > & operator+= (const BitArray< N > &a)
 
BitArray< Noperator- (const BitArray< N > &a)
 
BitArray< N > & operator-= (const BitArray< N > &a)
 
bool operator< (const BitArray< N > &a) const
 
BitArray< Noperator<< (const int n)
 
BitArray< N > & operator<<= (const int n)
 
bool operator<= (const BitArray< N > &a) const
 
BitArray< N > & operator= (const BitArray< N > &a)
 
BitArray< N > & operator= (const unsigned i)
 
BitArray< N > & operator= (const char *str)
 
bool operator== (const BitArray< N > &a) const
 
bool operator> (const BitArray< N > &a) const
 
bool operator>= (const BitArray< N > &a) const
 
BitArray< Noperator>> (const int n)
 
BitArray< N > & operator>>= (const int n)
 
refToBit operator[] (const int pos)
 
int operator[] (const int pos) const
 
BitArray< Noperator^ (const BitArray< N > &a)
 
BitArray< N > & operator^= (const BitArray< N > &a)
 
BitArray< Noperator| (const BitArray< N > &a)
 
BitArray< N > & operator|= (const BitArray< N > &a)
 
BitArray< Noperator~ () 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
 
BitArray< NtwoComplement () const
 
BitArray< 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 BitArray< N >

Definition at line 28 of file BitArray.h.

Constructor & Destructor Documentation

◆ BitArray() [1/5]

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

Definition at line 79 of file BitArray.h.

79 { this->zero(); }
void zero()
Definition: BitArray.h:210

◆ BitArray() [2/5]

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

Definition at line 81 of file BitArray.h.

81  {
82  for (int i = 0; i < this->nWords(); i++) {
83  _data[i] = br._data[i];
84  }
85  this->cleanUnused();
86  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
void cleanUnused()
Definition: BitArray.h:163
int nWords() const
Definition: BitArray.h:121

◆ BitArray() [3/5]

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

Definition at line 87 of file BitArray.h.

87  {
88  this->zero();
89  this->assign(0, this->nBits(), str);
90  this->cleanUnused();
91  }
void zero()
Definition: BitArray.h:210
int nBits() const
Definition: BitArray.h:117
void cleanUnused()
Definition: BitArray.h:163
void assign(const int p, const int n, const int val)
Definition: BitArray.h:233
#define str(s)

◆ BitArray() [4/5]

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

Definition at line 92 of file BitArray.h.

92  {
93  this->zero();
94  this->assign(p, n, str);
95  }
void zero()
Definition: BitArray.h:210
void assign(const int p, const int n, const int val)
Definition: BitArray.h:233
#define str(s)

◆ BitArray() [5/5]

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

Definition at line 96 of file BitArray.h.

96  {
97  this->zero();
98  _data[0] = i; // the nBit least sign. bits are considered
99  this->cleanUnused();
100  }
void zero()
Definition: BitArray.h:210
unsigned _data[N/32+1]
Definition: BitArray.h:523
void cleanUnused()
Definition: BitArray.h:163

Member Function Documentation

◆ any()

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

Definition at line 176 of file BitArray.h.

Referenced by DTTSTheta::runDTTSTheta().

176  {
177  int nw = this->nWords();
178  int ub = unusedBits();
179  if (this->dataWord(nw - 1) << ub != 0)
180  return 1;
181  if (nw > 1) {
182  for (int iw = 0; iw < nw - 1; iw++) {
183  if (this->dataWord(iw) != 0)
184  return 1;
185  }
186  }
187  return 0;
188  }
int unusedBits() const
Definition: BitArray.h:153
int nWords() const
Definition: BitArray.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ assign() [1/3]

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

Definition at line 233 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().

233  {
234  assert(p >= 0 && p + n <= this->nBits());
235  // only the n least significant bits of val are considered
236  for (int i = 0; i < n; i++) {
237  if (val >> i & 1) {
238  this->set(p + i);
239  } else {
240  this->unset(p + i);
241  }
242  }
243  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225

◆ assign() [2/3]

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

Definition at line 244 of file BitArray.h.

244  {
245  assert(p >= 0 && p + n <= this->nBits());
246  // only the n least significant bits of val are considered
247  for (int i = 0; i < n; i++) {
248  if (val.element(i)) {
249  this->set(p + i);
250  } else {
251  this->unset(p + i);
252  }
253  }
254  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225

◆ assign() [3/3]

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

Definition at line 255 of file BitArray.h.

255  {
256  assert(p >= 0 && p + n <= this->nBits());
257  // only the n least significant bits of val are considered
258  for (int i = 0; i < n; i++) {
259  assert(str[i] == '1' || str[i] == '0');
260  if (str[i] == '1') {
261  this->set(p + n - i - 1); // reading a string from left to right
262  } else { // --> most significative bit is the one
263  this->unset(p + n - i - 1); // with lower string index
264  }
265  }
266  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225
#define str(s)

◆ byte()

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

Definition at line 282 of file BitArray.h.

Referenced by DTTSTheta::runDTTSTheta().

282  {
284  if (i >= 0 && i < 4 * this->nWords()) {
285  unsigned k = (_data[i / 4] >> 8 * (i % 4)) & 0xff;
286  out = k;
287  }
288  return out;
289  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

◆ cleanUnused()

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

Definition at line 163 of file BitArray.h.

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

163 { _data[this->nWords() - 1] &= (this->lastWordMask()); }
unsigned lastWordMask() const
Definition: BitArray.h:160
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

◆ count()

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

Definition at line 166 of file BitArray.h.

166  {
167  int n = 0;
168  for (int i = 0; i < this->nBits(); i++) {
169  if (this->element(i))
170  n++;
171  }
172  return n;
173  }
int nBits() const
Definition: BitArray.h:117
int element(const int pos) const
Definition: BitArray.h:206

◆ dataWord() [1/2]

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

◆ dataWord() [2/2]

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

Definition at line 128 of file BitArray.h.

128  {
129  assert(i >= 0 && i < this->nWords());
130  return _data[i];
131  }
assert(be >=bs)
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

◆ element()

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

◆ flip()

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

Definition at line 403 of file BitArray.h.

Referenced by BitArray< 9 >::operator~().

403  {
404  for (int i = 0; i < this->nWords(); i++) {
405  _data[i] = ~_data[i];
406  }
407  return *this;
408  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

◆ getPosInWord()

template<int N>
static int BitArray< N >::getPosInWord ( const int  pos)
inlinestatic

Definition at line 144 of file BitArray.h.

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

144  {
145  // assert(pos>=0&& pos<this->nBits());
146  return pos % 32;
147  }

◆ getPosMask()

template<int N>
static unsigned BitArray< N >::getPosMask ( const int  pos)
inlinestatic

◆ getWord() [1/2]

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

Definition at line 134 of file BitArray.h.

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

134  {
135  assert(pos >= 0 && pos < this->nBits());
136  return _data[pos / 32];
137  }
assert(be >=bs)
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nBits() const
Definition: BitArray.h:117

◆ getWord() [2/2]

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

Definition at line 138 of file BitArray.h.

138  {
139  assert(pos >= 0 && pos < this->nBits());
140  return _data[pos / 32];
141  }
assert(be >=bs)
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nBits() const
Definition: BitArray.h:117

◆ lastWordMask()

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

Definition at line 160 of file BitArray.h.

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

160 { return static_cast<unsigned>(0xffffffff) >> (this->unusedBits()); }
int unusedBits() const
Definition: BitArray.h:153

◆ nBits()

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

◆ none()

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

Definition at line 191 of file BitArray.h.

191  {
192  int nw = this->nWords();
193  int ub = unusedBits();
194  if (this->dataWord(nw - 1) << ub != 0xffffffff)
195  return 1;
196  if (nw > 1) {
197  for (int iw = 0; iw < nw - 1; iw++) {
198  if (this->dataWord(iw) != 0xffffffff)
199  return 1;
200  }
201  }
202  return 0;
203  }
int unusedBits() const
Definition: BitArray.h:153
int nWords() const
Definition: BitArray.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ nWords()

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

◆ one()

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

Definition at line 217 of file BitArray.h.

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

217  {
218  for (int i = 0; i < this->nWords(); i++) {
219  _data[i] = 0xffffffff; // set to 1
220  }
221  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

◆ operator &()

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

Definition at line 422 of file BitArray.h.

422 { return BitArray<N>(*this) &= a; }
double a
Definition: hdecay.h:121

◆ operator &=()

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

Definition at line 414 of file BitArray.h.

414  {
415  for (int i = 0; i < this->nWords(); i++) {
416  this->dataWord(i) &= a.dataWord(i);
417  }
418  return *this;
419  }
int nWords() const
Definition: BitArray.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ operator!=()

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

Definition at line 391 of file BitArray.h.

391 { return !(a == *this); }
double a
Definition: hdecay.h:121

◆ operator+()

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

Definition at line 492 of file BitArray.h.

492 { return BitArray<N>(*this) += a; }
double a
Definition: hdecay.h:121

◆ operator++()

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

Definition at line 495 of file BitArray.h.

495  {
496  int i = 0;
497  while (i < this->nBits() && this->element(i) == 1) {
498  this->unset(i);
499  i++;
500  }
501  if (i < this->nBits())
502  this->set(i);
503  return *this;
504  }
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225
int element(const int pos) const
Definition: BitArray.h:206

◆ operator+=()

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

Definition at line 479 of file BitArray.h.

479  {
480  int rep = 0;
481  int sum = 0;
482  for (int i = 0; i < this->nBits(); i++) {
483  sum = this->element(i) ^ rep;
484  rep = this->element(i) & rep;
485  this->set(i, sum ^ a.element(i));
486  rep |= (sum & a.element(i));
487  }
488  return *this;
489  }
int nBits() const
Definition: BitArray.h:117
rep
Definition: cuy.py:1189
double a
Definition: hdecay.h:121
int element(const int pos) const
Definition: BitArray.h:206

◆ operator-()

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

Definition at line 520 of file BitArray.h.

520 { return BitArray<N>(*this) -= a; }
double a
Definition: hdecay.h:121

◆ operator-=()

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

Definition at line 517 of file BitArray.h.

517 { return *this += a.twoComplement(); }
double a
Definition: hdecay.h:121

◆ operator<()

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

Definition at line 368 of file BitArray.h.

368  {
369  int nw = this->nWords();
370  int ub = this->unusedBits();
371  unsigned aaa = this->dataWord(nw - 1) << ub; // ignore unused bits
372  unsigned bbb = a.dataWord(nw - 1) << ub; // in both operands
373  if (aaa < bbb) {
374  return true;
375  } else if (aaa > bbb) {
376  return false;
377  }
378  if (nw > 1) {
379  for (int iw = nw - 2; iw >= 0; iw--) {
380  if (this->dataWord(iw) < a.dataWord(iw)) {
381  return true;
382  } else if (this->dataWord(iw) > a.dataWord(iw)) {
383  return false;
384  }
385  }
386  }
387  return false;
388  }
int unusedBits() const
Definition: BitArray.h:153
int nWords() const
Definition: BitArray.h:121
double a
Definition: hdecay.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ operator<<()

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

Definition at line 460 of file BitArray.h.

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

◆ operator<<=()

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

Definition at line 447 of file BitArray.h.

447  {
448  assert(n >= 0 && n < this->nBits());
449  if (n == 0)
450  return *this;
451  int i = 0;
452  for (i = this->nBits() - 1; i >= n; i--)
453  this->set(i, this->element(i - n));
454  for (i = n - 1; i >= 0; i--)
455  this->unset(i);
456  return *this;
457  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225
int element(const int pos) const
Definition: BitArray.h:206

◆ operator<=()

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

Definition at line 400 of file BitArray.h.

400 { return !(*this > a); }
double a
Definition: hdecay.h:121

◆ operator=() [1/3]

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

Definition at line 291 of file BitArray.h.

291  {
292  if (this != &a) {
293  for (int i = 0; i < this->nWords(); i++) {
294  _data[i] = a._data[i];
295  }
296  }
297  this->cleanUnused();
298  return *this;
299  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
void cleanUnused()
Definition: BitArray.h:163
int nWords() const
Definition: BitArray.h:121
double a
Definition: hdecay.h:121

◆ operator=() [2/3]

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

Definition at line 302 of file BitArray.h.

302  {
303  this->zero();
304  _data[0] = i; // the nBit least sign. bits are considered
305  this->cleanUnused();
306  return *this;
307  }
void zero()
Definition: BitArray.h:210
unsigned _data[N/32+1]
Definition: BitArray.h:523
void cleanUnused()
Definition: BitArray.h:163

◆ operator=() [3/3]

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

Definition at line 323 of file BitArray.h.

323  {
324  this->zero();
325  for (int i = 0; i < this->nBits(); i++) {
326  assert(str[i] == '1' || str[i] == '0');
327  if (str[i] == '1') {
328  this->set(this->nBits() - i - 1); // reading a string from left to right
329  } else if (str[i] == '0') { // --> most significative bit is the one
330  this->unset(this->nBits() - i - 1); // with lower string index
331  } else {
332  break; // exit when find a char which is not 0 or 1
333  }
334  }
335  this->cleanUnused();
336  return *this;
337  }
void zero()
Definition: BitArray.h:210
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void cleanUnused()
Definition: BitArray.h:163
void unset(const int i)
Definition: BitArray.h:225
#define str(s)

◆ operator==()

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

Definition at line 352 of file BitArray.h.

352  {
353  int nw = this->nWords();
354  int ub = this->unusedBits();
355  if (this->dataWord(nw - 1) << ub != // check last word
356  a.dataWord(nw - 1) << ub)
357  return false;
358  if (nw > 1) {
359  for (int iw = 0; iw < nw - 1; iw++) {
360  if (this->dataWord(iw) != a.dataWord(iw))
361  return false;
362  }
363  }
364  return true;
365  }
int unusedBits() const
Definition: BitArray.h:153
int nWords() const
Definition: BitArray.h:121
double a
Definition: hdecay.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ operator>()

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

Definition at line 397 of file BitArray.h.

397 { return !(*this < a || *this == a); }
double a
Definition: hdecay.h:121

◆ operator>=()

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

Definition at line 394 of file BitArray.h.

394 { return !(*this < a); }
double a
Definition: hdecay.h:121

◆ operator>>()

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

Definition at line 476 of file BitArray.h.

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

◆ operator>>=()

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

Definition at line 463 of file BitArray.h.

463  {
464  assert(n >= 0 && n < this->nBits());
465  if (n == 0)
466  return *this;
467  int i = 0;
468  for (i = 0; i < this->nBits() - n; i++)
469  this->set(i, this->element(i + n));
470  for (i = this->nBits() - n; i < this->nBits(); i++)
471  this->unset(i);
472  return *this;
473  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
void unset(const int i)
Definition: BitArray.h:225
int element(const int pos) const
Definition: BitArray.h:206

◆ operator[]() [1/2]

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

Definition at line 348 of file BitArray.h.

348 { return refToBit(*this, pos); }
friend class refToBit
Definition: BitArray.h:30

◆ operator[]() [2/2]

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

Definition at line 349 of file BitArray.h.

349 { return element(pos); }
int element(const int pos) const
Definition: BitArray.h:206

◆ operator^()

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

Definition at line 444 of file BitArray.h.

444 { return BitArray<N>(*this) ^= a; }
double a
Definition: hdecay.h:121

◆ operator^=()

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

Definition at line 436 of file BitArray.h.

436  {
437  for (int i = 0; i < this->nWords(); i++) {
438  this->dataWord(i) ^= a.dataWord(i);
439  }
440  return *this;
441  }
int nWords() const
Definition: BitArray.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ operator|()

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

Definition at line 433 of file BitArray.h.

433 { return BitArray<N>(*this) |= a; }
double a
Definition: hdecay.h:121

◆ operator|=()

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

Definition at line 425 of file BitArray.h.

425  {
426  for (int i = 0; i < this->nWords(); i++) {
427  this->dataWord(i) |= a.dataWord(i);
428  }
429  return *this;
430  }
int nWords() const
Definition: BitArray.h:121
unsigned dataWord(const int i) const
Definition: BitArray.h:124

◆ operator~()

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

Definition at line 411 of file BitArray.h.

411 { return BitArray<N>(*this).flip(); }
BitArray< N > & flip()
Definition: BitArray.h:403

◆ print()

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

Definition at line 340 of file BitArray.h.

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

340  {
341  for (int i = this->nBits() - 1; i >= 0; i--) {
342  o << this->element(i);
343  }
344  return o;
345  }
int nBits() const
Definition: BitArray.h:117
int element(const int pos) const
Definition: BitArray.h:206

◆ read()

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

Definition at line 269 of file BitArray.h.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), and DTTracoChip::insideAngWindow().

269  {
270  assert(p >= 0 && p + n <= this->nBits());
271  assert(n <= 32); // the output must fit in a 32 bit word
272  // only the n least significant bits of val are considered
273  unsigned out = 0x0;
274  for (int i = 0; i < n; i++) {
275  if (this->test(p + i))
276  out |= 1 << i;
277  }
278  return out;
279  }
assert(be >=bs)
int nBits() const
Definition: BitArray.h:117
int test(const int i) const
Definition: BitArray.h:207

◆ reset() [1/2]

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

Definition at line 215 of file BitArray.h.

Referenced by DTBtiChip::keepTrigPatt().

215 { zero(); }
void zero()
Definition: BitArray.h:210

◆ reset() [2/2]

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

Definition at line 226 of file BitArray.h.

226 { this->unset(i); }
void unset(const int i)
Definition: BitArray.h:225

◆ set() [1/3]

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

◆ set() [2/3]

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

Definition at line 229 of file BitArray.h.

229 { this->assign(i, 1, val); }
void assign(const int p, const int n, const int val)
Definition: BitArray.h:233

◆ set() [3/3]

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

Definition at line 230 of file BitArray.h.

230 { this->assign(i, 1, str); }
void assign(const int p, const int n, const int val)
Definition: BitArray.h:233
#define str(s)

◆ size()

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

Definition at line 118 of file BitArray.h.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

118 { return this->nBits(); }
int nBits() const
Definition: BitArray.h:117

◆ test()

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

Definition at line 207 of file BitArray.h.

Referenced by BitArray< 9 >::read(), edmIntegrityCheck.IntegrityCheck::report(), and edmIntegrityCheck.IntegrityCheck::structured().

207 { return element(i); }
int element(const int pos) const
Definition: BitArray.h:206

◆ twoComplement() [1/2]

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

Definition at line 507 of file BitArray.h.

Referenced by DTTracoChip::insideAngWindow().

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

◆ twoComplement() [2/2]

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

Definition at line 510 of file BitArray.h.

510  {
511  (*this).flip();
512  (*this)++;
513  return *this;
514  }

◆ unset()

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

◆ unusedBits()

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

Definition at line 153 of file BitArray.h.

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

153  {
154  if (this->nBits() == 0)
155  return 32;
156  return 31 - ((this->nBits() - 1) % 32);
157  }
int nBits() const
Definition: BitArray.h:117

◆ zero()

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

Definition at line 210 of file BitArray.h.

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

210  {
211  for (int i = 0; i < this->nWords(); i++) {
212  _data[i] = 0x0; // set to 0
213  }
214  }
unsigned _data[N/32+1]
Definition: BitArray.h:523
int nWords() const
Definition: BitArray.h:121

Friends And Related Function Documentation

◆ refToBit

template<int N>
friend class refToBit
friend

Definition at line 30 of file BitArray.h.

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

Member Data Documentation

◆ _data

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