35 if (nbits <= 0) nbits = 8;
46 fNbytes(original.fNbytes)
100 needed > 0 &&
fAllBits[needed]==0; ) { 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) {
219 if (shift==0)
return;
220 const UInt_t wordshift = shift / 8;
221 const UInt_t offset = shift % 8;
228 const UInt_t sub_offset = 8 - offset;
231 (
fAllBits[
n - wordshift - 1] >> sub_offset);
244 if (shift==0)
return;
245 const UInt_t wordshift = shift / 8;
246 const UInt_t offset = shift % 8;
247 if (
fNbytes < (wordshift + 1)) {
257 const UInt_t sub_offset = 8 - offset;
260 (
fAllBits[
n + wordshift + 1] << sub_offset);
277 static const Int_t fbits[256] = {
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,5,
280 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
281 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
282 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
283 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
284 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
285 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,
286 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
287 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
288 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
289 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
290 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
291 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
292 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
293 0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8};
303 UInt_t startByte = startBit/8;
306 for (i=ibit;i<8;i++) {
307 if ((
fAllBits[startByte] & (1<<i)) == 0)
return 8*startByte+i;
311 for(i=startByte; i<
fNbytes; i++) {
322 static const Int_t fbits[256] = {
323 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
324 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
325 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
326 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
327 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
328 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
329 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
330 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
331 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
332 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
333 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
334 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
335 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
336 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
337 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
338 3,3,3,3,3,3,3,3,2,2,2,2,1,1,0,8};
342 UInt_t startByte = startBit/8;
345 for (i=ibit+1;i>0;i--) {
346 if ((
fAllBits[startByte] & (1<<(i-1))) == 0)
return 8*startByte+i-1;
350 for(i=startByte+1; i>0; i--) {
361 static const Int_t fbits[256] = {
362 8,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,
364 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
365 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
366 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
367 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
368 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
369 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
370 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
371 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
372 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
373 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
374 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
375 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
376 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
377 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
387 UInt_t startByte = startBit/8;
390 for (i=ibit;i<8;i++) {
391 if ((
fAllBits[startByte] & (1<<i)) != 0)
return 8*startByte+i;
395 for(i=startByte; i<
fNbytes; i++) {
406 static const Int_t fbits[256] = {
407 8,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
408 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
409 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
410 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
411 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
412 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
413 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
414 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
415 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
416 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
417 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
418 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
419 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
420 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
421 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
422 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
426 UInt_t startByte = startBit/8;
429 for (i=ibit+1;i>0;i--) {
430 if ((
fAllBits[startByte] & (1<<(i-1))) != 0)
return 8*startByte+i-1;
434 for(i=startByte+1; i>0; i--) {
447 for (
UInt_t j=0; j<8; ++j) {
470 for (
UInt_t j=0; j<8; ++j) {
471 if (val & 1) printf(
" bit:%4d = 1\n",count);
505 UInt_t nbytes=(nbits+7)>>3;
580 UInt_t nbytes = ((nbits+15)>>3)&~1;
587 for (
UInt_t i=0; i<nbytes; i+=2) {
596 UInt_t nbytes = ((nbits+31)>>3)&~3;
603 for (
UInt_t i=0; i<nbytes; i+=4) {
614 UInt_t nbytes = ((nbits+63)>>3)&~7;
621 for (
UInt_t i=0; i<nbytes; i+=8) {
638 UInt_t nSafeBytes = nBytes&~1;
641 for (
UInt_t i=0; i<nSafeBytes; i+=2) {
646 if (nBytes>nSafeBytes) {
647 cArray[nSafeBytes+1] =
fAllBits[nSafeBytes];
656 UInt_t nSafeBytes = nBytes&~3;
660 for (i=0; i<nSafeBytes; i+=4) {
667 for (i=0; i<nBytes-nSafeBytes; ++i) {
668 cArray[nSafeBytes + (3 - i)] =
fAllBits[nSafeBytes + i];
677 UInt_t nSafeBytes = nBytes&~7;
681 for (i=0; i<nSafeBytes; i+=8) {
692 for (i=0; i<nBytes-nSafeBytes; ++i) {
693 cArray[nSafeBytes + (7 - i)] =
fAllBits[nSafeBytes + i];
void DoRightShift(UInt_t shift)
Execute the left shift operation.
void DoAndEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero.
Bool_t operator==(const TBits &other) const
void Resize(UInt_t newlen)
void Clear(Option_t *option="")
Clear the value.
void DoXorEqual(const TBits &rhs)
Execute (*this) ^= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero.
void Print(Option_t *option="") const
Print the list of active bits.
UInt_t LastNullBit(UInt_t startBit=999999999) const
Return position of first null bit (starting from position 0 and up)
void ResetAllBits(Bool_t value=kFALSE)
Reset all bits to 0 (false).
void ReserveBytes(UInt_t nbytes)
Reverse each bytes.
void DoOrEqual(const TBits &rhs)
Execute (*this) &= rhs; Extra bits in rhs are ignored Missing bits in rhs are assumed to be zero.
void Paint(Option_t *option="")
Once implemented, it will draw the bit field as an histogram.
void Output(std::ostream &) const
Print the value to the std::ostream.
void Get(Char_t *array) const
Copy all the byes.
UInt_t FirstNullBit(UInt_t startBit=0) 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)
UInt_t CountBits(UInt_t startBit=0) const
Return number of bits set to 1 starting at bit startBit.
void Compact()
Reduce the storage used by the object to a minimun.
void DoLeftShift(UInt_t shift)
Execute the left shift operation.
virtual ~TBits()
TBits destructor.
TBits & operator=(const TBits &)
TBits assignment operator.
TBits(UInt_t nbits=8)
TBits constructor. All bits set to 0.
void DoFlip()
Execute ~(*this)
void Set(UInt_t nbits, const Char_t *array)
Set all the bytes.
UInt_t LastSetBit(UInt_t startBit=999999999) const
Return position of first non null bit (starting from position 0 and up)
Mother of all ROOT objects.
TObject & operator=(const TObject &rhs)
TObject assignment operator.