ROOT logo
ROOT » CORE » CONT » TBits

class TBits: public TObject


TBits

Container of bits

This class provides a simple container of bits.
Each bit can be set and tested via the functions SetBitNumber and
TestBitNumber.                                             .
The default value of all bits is kFALSE.
The size of the container is automatically extended when a bit
number is either set or tested.  To reduce the memory size of the
container use the Compact function, this will discard the memory
occupied by the upper bits that are 0.


Function Members (Methods)

public:
TBits(UInt_t nbits = 8)
TBits(const TBits&)
virtual~TBits()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidClear(Option_t* option = "")
virtual TObject*TObject::Clone(const char* newname = "") const
voidCompact()
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
UInt_tCountBits(UInt_t startBit = 0) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
UInt_tFirstNullBit(UInt_t startBit = 0) const
UInt_tFirstSetBit(UInt_t startBit = 0) const
voidGet(Char_t* array) const
voidGet(UChar_t* array) const
voidGet(Short_t* array) const
voidGet(UShort_t* array) const
voidGet(Int_t* array) const
voidGet(UInt_t* array) const
voidGet(Long64_t* array) const
voidGet(ULong64_t* array) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
UInt_tGetNbits() const
UInt_tGetNbytes() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
Bool_toperator!=(const TBits& other) const
TBits&operator&=(const TBits& rhs)
TBitsoperator<<(UInt_t rhs)
TBits&operator<<=(UInt_t rhs)
TBits&operator=(const TBits&)
Bool_toperator==(const TBits& other) const
TBitsoperator>>(UInt_t rhs)
TBits&operator>>=(UInt_t rhs)
TBits::TReferenceoperator[](UInt_t bitnumber)
Bool_toperator[](UInt_t bitnumber) const
TBits&operator^=(const TBits& rhs)
TBits&operator|=(const TBits& rhs)
TBitsoperator~()
voidOutput(ostream&) const
virtual voidPaint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidResetAllBits(Bool_t value = kFALSE)
voidTObject::ResetBit(UInt_t f)
voidResetBitNumber(UInt_t bitnumber)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidSet(UInt_t nbits, const Char_t* array)
voidSet(UInt_t nbits, const UChar_t* array)
voidSet(UInt_t nbits, const Short_t* array)
voidSet(UInt_t nbits, const UShort_t* array)
voidSet(UInt_t nbits, const Int_t* array)
voidSet(UInt_t nbits, const UInt_t* array)
voidSet(UInt_t nbits, const Long64_t* array)
voidSet(UInt_t nbits, const ULong64_t* array)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetBitNumber(UInt_t bitnumber, Bool_t value = kTRUE)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Bool_tTestBitNumber(UInt_t bitnumber) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
voidDoAndEqual(const TBits& rhs)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidDoFlip()
voidDoLeftShift(UInt_t shift)
voidDoOrEqual(const TBits& rhs)
voidDoRightShift(UInt_t shift)
voidDoXorEqual(const TBits& rhs)
voidTObject::MakeZombie()
voidReserveBytes(UInt_t nbytes)

Data Members

protected:
UChar_t*fAllBits[fNbytes] array of UChars
UInt_tfNbitsHighest bit set + 1
UInt_tfNbytesNumber of UChars in fAllBits

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TBits(UInt_t nbits = 8)
 TBits constructor.  All bits set to 0
TBits(const TBits& )
 TBits copy constructor
TBits& operator=(const TBits& )
 TBits assignment operator
~TBits()
 TBits destructor
void Clear(Option_t* option = "")
 Clear the value.
void Compact()
 Reduce the storage used by the object to a minimun
UInt_t CountBits(UInt_t startBit = 0) const
 Return number of bits set to 1 starting at bit startBit
void DoAndEqual(const TBits& rhs)
 Execute (*this) &= rhs;
 Extra bits in rhs are ignored
 Missing bits in rhs are assumed to be zero.
void DoOrEqual(const TBits& rhs)
 Execute (*this) &= rhs;
 Extra bits in rhs are ignored
 Missing bits in rhs are assumed to be zero.
void DoXorEqual(const TBits& rhs)
 Execute (*this) ^= rhs;
 Extra bits in rhs are ignored
 Missing bits in rhs are assumed to be zero.
void DoFlip()
 Execute ~(*this)
void DoLeftShift(UInt_t shift)
 Execute the left shift operation.
void DoRightShift(UInt_t shift)
 Execute the left shift operation.
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)
void Output(ostream& ) const
 Print the value to the ostream
void Paint(Option_t* option = "")
 Once implemented, it will draw the bit field as an histogram.
 use the TVirtualPainter as the usual trick
void Print(Option_t* option = "") const
 Print the list of active bits
void ResetAllBits(Bool_t value = kFALSE)
 Reset all bits to 0 (false).
void ReserveBytes(UInt_t nbytes)
 Reverse each bytes.
void Set(UInt_t nbits, const Char_t* array)
 Set all the bytes.
void Get(Char_t* array) const
 Copy all the byes.
void Set(UInt_t nbits, const Short_t* array)
 Set all the bytes.
void Set(UInt_t nbits, const Int_t* array)
 Set all the bytes.
void Set(UInt_t nbits, const Long64_t* array)
 Set all the bytes.
void Get(Short_t* array) const
 Get all the bytes.
void Get(Int_t* array) const
 Get all the bytes.
void Get(Long64_t* array) const
 Get all the bytes.
void Set(UInt_t nbits, const Short_t* array)
 make nbytes even so that the loop below is neat.
void Set(UInt_t nbits, const Int_t* array)
 make nbytes a multiple of 4 so that the loop below is neat.
void Set(UInt_t nbits, const Long64_t* array)
 make nbytes a multiple of 8 so that the loop below is neat.
void Get(Short_t* array) const
 Get all the bytes.
void Get(Int_t* array) const
 Get all the bytes.
void Get(Long64_t* array) const
 Get all the bytes.
Bool_t operator==(const TBits& other) const
 Compare object.
void SetBitNumber(UInt_t bitnumber, Bool_t value = kTRUE)
 Set bit number 'bitnumber' to be value
Bool_t TestBitNumber(UInt_t bitnumber) const
 Return the current value of the bit
void ResetBitNumber(UInt_t bitnumber)
Bool_t operator[](UInt_t bitnumber) const
Bool_t operator~()
 Flips the bit
TBits::TReference operator[](UInt_t bitnumber)
----- Accessors and operator
{ return TReference(*this,bitnumber); }
TBits& operator&=(const TBits& rhs)
{ DoAndEqual(rhs); return *this; }
TBits& operator|=(const TBits& rhs)
{ DoOrEqual(rhs); return *this; }
TBits& operator^=(const TBits& rhs)
{ DoXorEqual(rhs); return *this; }
TBits& operator<<=(UInt_t rhs)
{ DoLeftShift(rhs); return *this; }
TBits& operator>>=(UInt_t rhs)
{ DoRightShift(rhs); return *this; }
TBits operator<<(UInt_t rhs)
{ return TBits(*this)<<= rhs; }
TBits operator>>(UInt_t rhs)
{ return TBits(*this)>>= rhs; }
void Set(UInt_t nbits, const Char_t* array)
----- Optimized setters
 Each of these will replace the contents of the receiver with the bitvector
 in the parameter array.  The number of bits is changed to nbits.  If nbits
 is smaller than fNbits, the receiver will NOT be compacted.
void Get(Char_t* array) const
----- Optimized getters
 Each of these will replace the contents of the parameter array with the
 bits in the receiver.  The parameter array must be large enough to hold
 all of the bits in the receiver.
 Note on semantics: any bits in the parameter array that go beyond the
 number of the bits in the receiver will have an unspecified value.  For
 example, if you call Get(Int*) with an array of one integer and the TBits
 object has less than 32 bits, then the remaining bits in the integer will
 have an unspecified value.
UInt_t GetNbits() const
{ return fNbits; }
UInt_t GetNbytes() const
{ return fNbytes; }
Bool_t operator!=(const TBits& other) const
{ return !(*this==other); }