CMS 3D CMS Logo

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 ()
 
DTTFBitArray< Noperator & (const DTTFBitArray< N > &a)
 
DTTFBitArray< N > & operator &= (const DTTFBitArray< N > &a)
 
bool operator!= (const DTTFBitArray< N > &a) const
 
DTTFBitArray< Noperator+ (const DTTFBitArray< N > &a)
 
DTTFBitArray< N > & operator++ (int)
 
DTTFBitArray< N > & operator+= (const DTTFBitArray< N > &a)
 
DTTFBitArray< Noperator- (const DTTFBitArray< N > &a)
 
DTTFBitArray< N > & operator-= (const DTTFBitArray< N > &a)
 
bool operator< (const DTTFBitArray< N > &a) const
 
DTTFBitArray< Noperator<< (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< Noperator>> (const int n)
 
DTTFBitArray< N > & operator>>= (const int n)
 
refToBit operator[] (const int pos)
 
int operator[] (const int pos) const
 
DTTFBitArray< Noperator^ (const DTTFBitArray< N > &a)
 
DTTFBitArray< N > & operator^= (const DTTFBitArray< N > &a)
 
DTTFBitArray< Noperator| (const DTTFBitArray< N > &a)
 
DTTFBitArray< N > & operator|= (const DTTFBitArray< N > &a)
 
DTTFBitArray< 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
 
DTTFBitArray< NtwoComplement () 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 28 of file DTTFBitArray.h.

Constructor & Destructor Documentation

◆ DTTFBitArray() [1/5]

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

Definition at line 79 of file DTTFBitArray.h.

References DTTFBitArray< N >::zero().

79 { this->zero(); }

◆ DTTFBitArray() [2/5]

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

Definition at line 81 of file DTTFBitArray.h.

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

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

◆ DTTFBitArray() [3/5]

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

Definition at line 87 of file DTTFBitArray.h.

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

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

◆ DTTFBitArray() [4/5]

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

Definition at line 92 of file DTTFBitArray.h.

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

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

◆ DTTFBitArray() [5/5]

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

Definition at line 96 of file DTTFBitArray.h.

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

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

Member Function Documentation

◆ any()

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

Definition at line 176 of file DTTFBitArray.h.

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

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  }
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:124
int nWords() const
Definition: DTTFBitArray.h:121
int unusedBits() const
Definition: DTTFBitArray.h:153

◆ assign() [1/3]

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

Definition at line 233 of file DTTFBitArray.h.

References cms::cuda::assert(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), AlCaHLTBitMon_ParallelJobs::p, DTTFBitArray< N >::unset(), and heppy_batch::val.

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

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  }
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117

◆ assign() [2/3]

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

Definition at line 244 of file DTTFBitArray.h.

References cms::cuda::assert(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), AlCaHLTBitMon_ParallelJobs::p, DTTFBitArray< N >::unset(), and heppy_batch::val.

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  }
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117

◆ assign() [3/3]

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

Definition at line 255 of file DTTFBitArray.h.

References cms::cuda::assert(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), AlCaHLTBitMon_ParallelJobs::p, str, and DTTFBitArray< N >::unset().

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  }
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117
#define str(s)

◆ byte()

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

Definition at line 282 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, mps_fire::i, dqmdumpme::k, DTTFBitArray< N >::nWords(), and MillePedeFileConverter_cfg::out.

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  }
int nWords() const
Definition: DTTFBitArray.h:121
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:523

◆ cleanUnused()

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

Definition at line 163 of file DTTFBitArray.h.

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

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

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

◆ count()

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

Definition at line 166 of file DTTFBitArray.h.

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

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 element(const int pos) const
Definition: DTTFBitArray.h:206
int nBits() const
Definition: DTTFBitArray.h:117

◆ dataWord() [1/2]

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

◆ dataWord() [2/2]

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

Definition at line 128 of file DTTFBitArray.h.

References DTTFBitArray< N >::_data, cms::cuda::assert(), mps_fire::i, and DTTFBitArray< N >::nWords().

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

◆ element()

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

◆ flip()

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

Definition at line 403 of file DTTFBitArray.h.

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

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

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

◆ getPosInWord()

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

Definition at line 144 of file DTTFBitArray.h.

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

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

◆ getPosMask()

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

◆ getWord() [1/2]

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

Definition at line 134 of file DTTFBitArray.h.

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

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

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

◆ getWord() [2/2]

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

Definition at line 138 of file DTTFBitArray.h.

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

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

◆ lastWordMask()

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

Definition at line 160 of file DTTFBitArray.h.

References DTTFBitArray< N >::unusedBits().

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

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

◆ nBits()

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

◆ none()

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

Definition at line 191 of file DTTFBitArray.h.

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

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  }
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:124
int nWords() const
Definition: DTTFBitArray.h:121
int unusedBits() const
Definition: DTTFBitArray.h:153

◆ nWords()

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

◆ one()

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

Definition at line 217 of file DTTFBitArray.h.

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

Referenced by runEdmFileComparison.EdmObject::label().

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

◆ operator &()

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

Definition at line 422 of file DTTFBitArray.h.

References a.

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

◆ operator &=()

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

Definition at line 414 of file DTTFBitArray.h.

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

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

◆ operator!=()

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

Definition at line 391 of file DTTFBitArray.h.

References a.

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

◆ operator+()

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

Definition at line 492 of file DTTFBitArray.h.

References a.

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

◆ operator++()

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

Definition at line 495 of file DTTFBitArray.h.

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

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 element(const int pos) const
Definition: DTTFBitArray.h:206
void unset(const int i)
Definition: DTTFBitArray.h:225
int nBits() const
Definition: DTTFBitArray.h:117

◆ operator+=()

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

Definition at line 479 of file DTTFBitArray.h.

References a, DTTFBitArray< N >::element(), mps_fire::i, DTTFBitArray< N >::nBits(), and cuy::rep.

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 element(const int pos) const
Definition: DTTFBitArray.h:206
rep
Definition: cuy.py:1189
int nBits() const
Definition: DTTFBitArray.h:117
double a
Definition: hdecay.h:119

◆ operator-()

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

Definition at line 520 of file DTTFBitArray.h.

References a.

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

◆ operator-=()

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

Definition at line 517 of file DTTFBitArray.h.

References a.

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

◆ operator<()

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

Definition at line 368 of file DTTFBitArray.h.

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

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  }
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:124
double a
Definition: hdecay.h:119
int nWords() const
Definition: DTTFBitArray.h:121
int unusedBits() const
Definition: DTTFBitArray.h:153

◆ operator<<()

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

Definition at line 460 of file DTTFBitArray.h.

References dqmiodumpmetadata::n.

◆ operator<<=()

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

Definition at line 447 of file DTTFBitArray.h.

References cms::cuda::assert(), DTTFBitArray< N >::element(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), and DTTFBitArray< N >::unset().

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  }
int element(const int pos) const
Definition: DTTFBitArray.h:206
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117

◆ operator<=()

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); }
double a
Definition: hdecay.h:119

◆ operator=() [1/3]

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

Definition at line 291 of file DTTFBitArray.h.

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

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  }
void cleanUnused()
Definition: DTTFBitArray.h:163
double a
Definition: hdecay.h:119
int nWords() const
Definition: DTTFBitArray.h:121
unsigned _data[N/32+1]
Definition: DTTFBitArray.h:523

◆ operator=() [2/3]

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

Definition at line 302 of file DTTFBitArray.h.

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

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

◆ operator=() [3/3]

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

Definition at line 323 of file DTTFBitArray.h.

References cms::cuda::assert(), DTTFBitArray< N >::cleanUnused(), mps_fire::i, DTTFBitArray< N >::nBits(), str, DTTFBitArray< N >::unset(), and DTTFBitArray< N >::zero().

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 cleanUnused()
Definition: DTTFBitArray.h:163
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117
#define str(s)

◆ operator==()

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

Definition at line 352 of file DTTFBitArray.h.

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

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  }
unsigned dataWord(const int i) const
Definition: DTTFBitArray.h:124
double a
Definition: hdecay.h:119
int nWords() const
Definition: DTTFBitArray.h:121
int unusedBits() const
Definition: DTTFBitArray.h:153

◆ operator>()

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 || *this == a); }
double a
Definition: hdecay.h:119

◆ operator>=()

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

Definition at line 394 of file DTTFBitArray.h.

References a.

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

◆ operator>>()

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

Definition at line 476 of file DTTFBitArray.h.

References dqmiodumpmetadata::n.

◆ operator>>=()

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

Definition at line 463 of file DTTFBitArray.h.

References cms::cuda::assert(), DTTFBitArray< N >::element(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), and DTTFBitArray< N >::unset().

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  }
int element(const int pos) const
Definition: DTTFBitArray.h:206
void unset(const int i)
Definition: DTTFBitArray.h:225
assert(be >=bs)
int nBits() const
Definition: DTTFBitArray.h:117

◆ operator[]() [1/2]

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

Definition at line 348 of file DTTFBitArray.h.

References DTTFBitArray< N >::refToBit.

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

◆ operator[]() [2/2]

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

Definition at line 349 of file DTTFBitArray.h.

References DTTFBitArray< N >::element().

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

◆ operator^()

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

Definition at line 444 of file DTTFBitArray.h.

References a.

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

◆ operator^=()

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

Definition at line 436 of file DTTFBitArray.h.

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

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

◆ operator|()

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

Definition at line 433 of file DTTFBitArray.h.

References a.

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

◆ operator|=()

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

Definition at line 425 of file DTTFBitArray.h.

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

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

◆ operator~()

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

Definition at line 411 of file DTTFBitArray.h.

References DTTFBitArray< N >::flip().

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

◆ print()

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

Definition at line 340 of file DTTFBitArray.h.

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

Referenced by L1MuDTPtaLut::print(), and L1MuBMLUTHandler::print_pta_lut().

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

◆ read()

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

Definition at line 269 of file DTTFBitArray.h.

References cms::cuda::assert(), mps_fire::i, dqmiodumpmetadata::n, DTTFBitArray< N >::nBits(), MillePedeFileConverter_cfg::out, AlCaHLTBitMon_ParallelJobs::p, and DTTFBitArray< N >::test().

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

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: DTTFBitArray.h:117
int test(const int i) const
Definition: DTTFBitArray.h:207

◆ reset() [1/2]

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

◆ reset() [2/2]

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

Definition at line 226 of file DTTFBitArray.h.

References DTTFBitArray< N >::unset().

Referenced by MatrixReader.MatrixReader::__init__(), and MatrixReader.MatrixReader::showRaw().

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

◆ set() [1/3]

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

Definition at line 224 of file DTTFBitArray.h.

References DTTFBitArray< N >::getPosMask(), DTTFBitArray< N >::getWord(), and mps_fire::i.

224 { getWord(i) |= getPosMask(i); }
static unsigned getPosMask(const int pos)
Definition: DTTFBitArray.h:150
unsigned & getWord(const int pos)
Definition: DTTFBitArray.h:134

◆ set() [2/3]

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

Definition at line 229 of file DTTFBitArray.h.

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

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

◆ set() [3/3]

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

Definition at line 230 of file DTTFBitArray.h.

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

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

◆ size()

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

Definition at line 118 of file DTTFBitArray.h.

References DTTFBitArray< N >::nBits().

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

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

◆ test()

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

◆ twoComplement() [1/2]

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

◆ twoComplement() [2/2]

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

Definition at line 510 of file DTTFBitArray.h.

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

◆ unset()

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

◆ unusedBits()

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

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

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

◆ zero()

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

Definition at line 210 of file DTTFBitArray.h.

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

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

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

Friends And Related Function Documentation

◆ refToBit

template<int N>
friend class refToBit
friend

Definition at line 30 of file DTTFBitArray.h.

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

Member Data Documentation

◆ _data

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