32 if (nbits <= 0) nbits = 8;
33 fNbytes = ((nbits-1)/8) + 1;
34 fAllBits =
new UChar_t[fNbytes];
36 memset(fAllBits,0,fNbytes);
43 fNbytes(original.fNbytes)
97 needed > 0 &&
fAllBits[needed]==0; ) { needed--; };
102 fAllBits =
new UChar_t[needed];
104 memcpy(fAllBits,old_location,needed);
105 delete [] old_location;
117 static const Int_t nbits[256] = {
118 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
119 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
120 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
121 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
122 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
123 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
124 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
125 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
126 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
127 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
128 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
129 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
130 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
131 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
132 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
133 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};
142 if (startBit >=
fNbits)
return count;
143 UInt_t startByte = startBit/8;
146 for (i=ibit;i<8;i++) {
147 if (
fAllBits[startByte] & (1<<ibit)) count++;
151 for(i=startByte; i<
fNbytes; i++) {
165 for(
UInt_t i=0; i<min; ++i) {
181 for(
UInt_t i=0; i<min; ++i) {
194 for(
UInt_t i=0; i<min; ++i) {
215 if (shift==0)
return;
216 const UInt_t wordshift = shift / 8;
217 const UInt_t offset = shift % 8;
223 const UInt_t sub_offset = 8 - offset;
226 (
fAllBits[
n - wordshift - 1] >> sub_offset);
238 if (shift==0)
return;
239 const UInt_t wordshift = shift / 8;
240 const UInt_t offset = shift % 8;
248 const UInt_t sub_offset = 8 - offset;
251 (
fAllBits[
n + wordshift + 1] << sub_offset);
263 static const Int_t fbits[256] = {
264 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
265 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
266 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
267 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
268 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
269 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
270 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
271 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,
272 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
273 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
274 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
275 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
276 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
277 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
278 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
279 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8};
289 UInt_t startByte = startBit/8;
292 for (i=ibit;i<8;i++) {
293 if ((
fAllBits[startByte] & (1<<i)) == 0)
return 8*startByte+i;
297 for(i=startByte; i<
fNbytes; i++) {
308 static const Int_t fbits[256] = {
309 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
310 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
311 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
312 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
313 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
314 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
315 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
316 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
317 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
318 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
319 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
320 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
321 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
322 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
323 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
324 3,3,3,3,3,3,3,3,2,2,2,2,1,1,0,8};
328 UInt_t startByte = startBit/8;
331 for (i=ibit+1;i>0;i--) {
332 if ((
fAllBits[startByte] & (1<<(i-1))) == 0)
return 8*startByte+i-1;
336 for(i=startByte+1; i>0; i--) {
347 static const Int_t fbits[256] = {
348 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
349 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
350 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
351 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
352 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
353 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
354 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
355 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
356 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
357 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
358 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
359 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
360 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
361 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
362 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
363 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
373 UInt_t startByte = startBit/8;
376 for (i=ibit;i<8;i++) {
377 if ((
fAllBits[startByte] & (1<<i)) != 0)
return 8*startByte+i;
381 for(i=startByte; i<
fNbytes; i++) {
392 static const Int_t fbits[256] = {
393 8,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
394 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
395 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
396 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
397 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
398 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
399 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
400 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
401 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
402 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
403 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
404 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
405 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
406 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
407 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
408 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
412 UInt_t startByte = startBit/8;
415 for (i=ibit+1;i>0;i--) {
416 if ((
fAllBits[startByte] & (1<<(i-1))) != 0)
return 8*startByte+i-1;
420 for(i=startByte+1; i>0; i--) {
433 for (
UInt_t j=0; j<8; ++j) {
456 for (
UInt_t j=0; j<8; ++j) {
457 if (val & 1) printf(
" bit:%4d = 1\n",count);
491 UInt_t nbytes=(nbits+7)>>3;
566 UInt_t nbytes = ((nbits+15)>>3)&~1;
573 for (
UInt_t i=0; i<nbytes; i+=2) {
582 UInt_t nbytes = ((nbits+31)>>3)&~3;
589 for (
UInt_t i=0; i<nbytes; i+=4) {
600 UInt_t nbytes = ((nbits+63)>>3)&~7;
607 for (
UInt_t i=0; i<nbytes; i+=8) {
624 UInt_t nSafeBytes = nBytes&~1;
627 for (
UInt_t i=0; i<nSafeBytes; i+=2) {
632 if (nBytes>nSafeBytes) {
633 cArray[nSafeBytes+1] =
fAllBits[nSafeBytes];
642 UInt_t nSafeBytes = nBytes&~3;
646 for (i=0; i<nSafeBytes; i+=4) {
653 for (i=0; i<nBytes-nSafeBytes; ++i) {
654 cArray[nSafeBytes + (3 - i)] =
fAllBits[nSafeBytes + i];
663 UInt_t nSafeBytes = nBytes&~7;
667 for (i=0; i<nSafeBytes; i+=8) {
678 for (i=0; i<nBytes-nSafeBytes; ++i) {
679 cArray[nSafeBytes + (7 - i)] =
fAllBits[nSafeBytes + i];
void Output(std::ostream &) const
Print the value to the std::ostream.
void Print(Option_t *option="") const
Print the list of active bits.
void Clear(Option_t *option="")
Clear the value.
void Set(UInt_t nbits, const Char_t *array)
Set all the bytes.
void DoAndEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
void DoRightShift(UInt_t shift)
Execute the left shift operation.
void ResetAllBits(Bool_t value=kFALSE)
Reset all bits to 0 (false).
TBits & operator=(const TBits &)
TBits assignment operator.
Bool_t operator==(const TBits &other) const
virtual ~TBits()
TBits destructor.
void DoOrEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
TObject & operator=(const TObject &rhs)
TObject assignment operator.
void Get(Char_t *array) const
Copy all the byes.
UInt_t LastSetBit(UInt_t startBit=999999999) const
Return position of first non null bit (starting from position 0 and up)
UInt_t LastNullBit(UInt_t startBit=999999999) const
Return position of first null bit (starting from position 0 and up)
UInt_t FirstSetBit(UInt_t startBit=0) const
Return position of first non null bit (starting from position 0 and up)
void Compact()
Reduce the storage used by the object to a minimun.
void DoLeftShift(UInt_t shift)
Execute the left shift operation.
void DoXorEqual(const TBits &rhs)
Execute (*this) ^= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero...
TBits(UInt_t nbits=8)
TBits constructor. All bits set to 0.
Mother of all ROOT objects.
void Paint(Option_t *option="")
Once implemented, it will draw the bit field as an histogram.
void DoFlip()
Execute ~(*this)
UInt_t CountBits(UInt_t startBit=0) const
Return number of bits set to 1 starting at bit startBit.
void ReserveBytes(UInt_t nbytes)
Reverse each bytes.
UInt_t FirstNullBit(UInt_t startBit=0) const
Return position of first null bit (starting from position 0 and up)