35 if (nbits <= 0) nbits = 8;
36 fNbytes = ((nbits-1)/8) + 1;
37 fAllBits =
new UChar_t[fNbytes];
39 memset(fAllBits,0,fNbytes);
46 fNbytes(original.fNbytes)
100 needed > 0 &&
fAllBits[needed]==0; ) { needed--; };
105 fAllBits =
new UChar_t[needed];
107 memcpy(fAllBits,old_location,needed);
108 delete [] old_location;
120 static const Int_t nbits[256] = {
121 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
122 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
123 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
124 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
125 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
126 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
127 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
128 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
129 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
130 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
131 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
132 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
133 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
134 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
135 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
136 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};
145 if (startBit >=
fNbits)
return count;
146 UInt_t startByte = startBit/8;
149 for (i=ibit;i<8;i++) {
150 if (
fAllBits[startByte] & (1<<ibit)) count++;
154 for(i=startByte; i<
fNbytes; i++) {
168 for(
UInt_t i=0; i<min; ++i) {
184 for(
UInt_t i=0; i<min; ++i) {
197 for(
UInt_t i=0; i<min; ++i) {
218 if (shift==0)
return;
219 const UInt_t wordshift = shift / 8;
220 const UInt_t offset = shift % 8;
226 const UInt_t sub_offset = 8 - offset;
229 (
fAllBits[
n - wordshift - 1] >> sub_offset);
241 if (shift==0)
return;
242 const UInt_t wordshift = shift / 8;
243 const UInt_t offset = shift % 8;
251 const UInt_t sub_offset = 8 - offset;
254 (
fAllBits[
n + wordshift + 1] << sub_offset);
266 static const Int_t fbits[256] = {
267 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
268 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
269 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
270 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
271 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
272 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
273 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
274 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,
275 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
276 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
277 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
278 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
279 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
280 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
281 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
282 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8};
292 UInt_t startByte = startBit/8;
295 for (i=ibit;i<8;i++) {
296 if ((
fAllBits[startByte] & (1<<i)) == 0)
return 8*startByte+i;
300 for(i=startByte; i<
fNbytes; i++) {
311 static const Int_t fbits[256] = {
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 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
318 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
319 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
320 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
321 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
322 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
323 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
324 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
325 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
326 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
327 3,3,3,3,3,3,3,3,2,2,2,2,1,1,0,8};
331 UInt_t startByte = startBit/8;
334 for (i=ibit+1;i>0;i--) {
335 if ((
fAllBits[startByte] & (1<<(i-1))) == 0)
return 8*startByte+i-1;
339 for(i=startByte+1; i>0; i--) {
350 static const Int_t fbits[256] = {
351 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
352 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
353 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
354 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
355 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
356 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
357 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
358 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
359 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
360 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
361 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
362 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
363 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
364 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
365 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
366 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
376 UInt_t startByte = startBit/8;
379 for (i=ibit;i<8;i++) {
380 if ((
fAllBits[startByte] & (1<<i)) != 0)
return 8*startByte+i;
384 for(i=startByte; i<
fNbytes; i++) {
395 static const Int_t fbits[256] = {
396 8,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
397 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
398 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
399 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
400 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
401 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
402 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
403 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
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,
409 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
410 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
411 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
415 UInt_t startByte = startBit/8;
418 for (i=ibit+1;i>0;i--) {
419 if ((
fAllBits[startByte] & (1<<(i-1))) != 0)
return 8*startByte+i-1;
423 for(i=startByte+1; i>0; i--) {
436 for (
UInt_t j=0; j<8; ++j) {
459 for (
UInt_t j=0; j<8; ++j) {
460 if (val & 1) printf(
" bit:%4d = 1\n",count);
494 UInt_t nbytes=(nbits+7)>>3;
569 UInt_t nbytes = ((nbits+15)>>3)&~1;
576 for (
UInt_t i=0; i<nbytes; i+=2) {
585 UInt_t nbytes = ((nbits+31)>>3)&~3;
592 for (
UInt_t i=0; i<nbytes; i+=4) {
603 UInt_t nbytes = ((nbits+63)>>3)&~7;
610 for (
UInt_t i=0; i<nbytes; i+=8) {
627 UInt_t nSafeBytes = nBytes&~1;
630 for (
UInt_t i=0; i<nSafeBytes; i+=2) {
635 if (nBytes>nSafeBytes) {
636 cArray[nSafeBytes+1] =
fAllBits[nSafeBytes];
645 UInt_t nSafeBytes = nBytes&~3;
649 for (i=0; i<nSafeBytes; i+=4) {
656 for (i=0; i<nBytes-nSafeBytes; ++i) {
657 cArray[nSafeBytes + (3 - i)] =
fAllBits[nSafeBytes + i];
666 UInt_t nSafeBytes = nBytes&~7;
670 for (i=0; i<nSafeBytes; i+=8) {
681 for (i=0; i<nBytes-nSafeBytes; ++i) {
682 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)