#include <tlbitfield.h>
Collaboration diagram for TLDynamicBitField< T >:
Public Types | |
typedef uint | nents_t |
Public Member Functions | |
TLDynamicBitField (size_t _N) | |
Creates an uninitialized bitfield of passed size (may be 0). | |
TLDynamicBitField (size_t _N, bool bitval) | |
Creates a bitfield of passed size (may be 0) with all elements set to passed value. | |
TLDynamicBitField (const TLDynamicBitField< T > &b) | |
Creates a copy of the passed bitfield. | |
~TLDynamicBitField () | |
Destructor frees memory. | |
TLDynamicBitField & | operator= (const TLDynamicBitField< T > &b) |
Assignment operator: copy bit values:. | |
void | resize (size_t newN) |
Resize the bitfield. | |
void | resize (size_t newN, bool ini_val) |
Resize the bitfield. | |
void | SetBit (size_t bit) |
Set a bit; bit in range 0..N-1; no range check! | |
void | ClrBit (size_t bit) |
Clear a bit; bit in range 0..N-1; no range check! | |
bool | GetBit (size_t bit) |
Query a bit value; bit in range 0..N-1; no range check! | |
void | AssBit (size_t bit, bool val) |
Assign bit value; bit in range 0..N-1; no range check! | |
void | SetAll () |
Set all bits (to 1). | |
void | ClrAll () |
Clear all bits (to 0). | |
size_t | CountSet () |
Count number of bits set. | |
size_t | CountClr () |
Count number of bits not set. | |
ssize_t | SearchFirstSet () |
Search bit address of first set (1) bit in bitfield. | |
ssize_t | SearchFirstClr () |
Search bit address of first cleared (0) bit in bitfield. | |
Private Member Functions | |
void | _SetAllEnts (T val) |
Used to set/clear _all_ bits. | |
void | _CopyFrom (const TLDynamicBitField< T > &b) |
Copy bit field with content. | |
void | _SetVals (size_t _N) |
Set various values. | |
void | _Initialize (size_t _N) |
Initialize object. | |
void | _Free () |
Free data. | |
Static Private Member Functions | |
nents_t | _NEntsOfN (size_t _N) |
Calculate number of entries for passed number of bits. | |
Private Attributes | |
size_t | N |
Number of bits in the bitfield. | |
nents_t | nents |
Number of entries in the bitfield array. | |
T * | bits |
The actual bitfield array [nents]. | |
T | exmask |
This mask contains all excess (unused) bits in bits[nents-1]. | |
Static Private Attributes | |
const T | band = T(8*sizeof(T)-1) |
AND mask for part of bit address stored inside one entry. | |
const int | bshift |
Number of bits to shift left to get entry index from bit address. | |
const size_t | bits_per_ent = 8*sizeof(T) |
Number of bits per entry:. | |
const T | all_clr = T(0) |
Constant of type T with all bits cleared. | |
const T | all_set = ~all_clr |
Constant of type T with all bits set. | |
Friends | |
int | DoTestBitFields () |
This is not as fast as TLStaticBitField.
Template parameter:
T: Type to use for bit storage. Recommend one word on the underlying architecture; probably size_t is a good choice.
Definition at line 283 of file tlbitfield.h.
|
Type for the number of entries; must be capable of representing N/(8*sizeof(T)). Definition at line 289 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::_CopyFrom(), TLDynamicBitField< T >::_NEntsOfN(), TLDynamicBitField< T >::_SetAllEnts(), TLDynamicBitField< T >::CountClr(), TLDynamicBitField< T >::CountSet(), TLDynamicBitField< T >::resize(), TLDynamicBitField< T >::SearchFirstClr(), and TLDynamicBitField< T >::SearchFirstSet(). |
|
Creates an uninitialized bitfield of passed size (may be 0).
Definition at line 349 of file tlbitfield.h. References TLDynamicBitField< T >::_Initialize(). |
|
Creates a bitfield of passed size (may be 0) with all elements set to passed value.
Definition at line 352 of file tlbitfield.h. References TLDynamicBitField< T >::_Initialize(), TLDynamicBitField< T >::_SetAllEnts(), TLDynamicBitField< T >::all_clr, and TLDynamicBitField< T >::all_set. |
|
Creates a copy of the passed bitfield.
Definition at line 355 of file tlbitfield.h. References TLDynamicBitField< T >::_CopyFrom(). |
|
Destructor frees memory.
Definition at line 358 of file tlbitfield.h. References TLDynamicBitField< T >::_Free(). |
|
Copy bit field with content.
For internal use only.
Definition at line 325 of file tlbitfield.h. References TLDynamicBitField< T >::bits, TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::N, TLDynamicBitField< T >::nents, and TLDynamicBitField< T >::nents_t. Referenced by TLDynamicBitField< T >::operator=(), and TLDynamicBitField< T >::TLDynamicBitField(). |
|
Free data.
For internal use only.
Definition at line 344 of file tlbitfield.h. References TLDynamicBitField< T >::bits, FREE(), TLDynamicBitField< T >::N, and TLDynamicBitField< T >::nents. Referenced by TLDynamicBitField< T >::operator=(), and TLDynamicBitField< T >::~TLDynamicBitField(). |
|
Initialize object.
For internal use only.
Definition at line 341 of file tlbitfield.h. References TLDynamicBitField< T >::_SetVals(), TLDynamicBitField< T >::bits, and TLDynamicBitField< T >::nents. Referenced by TLDynamicBitField< T >::TLDynamicBitField(). |
|
Calculate number of entries for passed number of bits.
Definition at line 331 of file tlbitfield.h. References TLDynamicBitField< T >::nents_t. Referenced by TLDynamicBitField< T >::_SetVals(), and TLDynamicBitField< T >::resize(). |
|
Used to set/clear _all_ bits.
For internal use only.
Definition at line 322 of file tlbitfield.h. References TLDynamicBitField< T >::bits, TLDynamicBitField< T >::nents, and TLDynamicBitField< T >::nents_t. Referenced by TLDynamicBitField< T >::ClrAll(), TLDynamicBitField< T >::SetAll(), and TLDynamicBitField< T >::TLDynamicBitField(). |
|
Set various values.
For internal use only.
Definition at line 334 of file tlbitfield.h. References TLDynamicBitField< T >::_NEntsOfN(), TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::N, TLDynamicBitField< T >::nents, and uint32. Referenced by TLDynamicBitField< T >::_Initialize(), and TLDynamicBitField< T >::resize(). |
|
Assign bit value; bit in range 0..N-1; no range check!
Definition at line 411 of file tlbitfield.h. References TLDynamicBitField< T >::ClrBit(), and TLDynamicBitField< T >::SetBit(). Referenced by DoTestBitFields(). |
|
Clear all bits (to 0).
Definition at line 418 of file tlbitfield.h. References TLDynamicBitField< T >::_SetAllEnts(), and TLDynamicBitField< T >::all_clr. Referenced by DoTestBitFields(). |
|
Clear a bit; bit in range 0..N-1; no range check!
Definition at line 405 of file tlbitfield.h. References TLDynamicBitField< T >::band, TLDynamicBitField< T >::bits, and TLDynamicBitField< T >::bshift. Referenced by TLDynamicBitField< T >::AssBit(), and DoTestBitFields(). |
|
Count number of bits not set.
Definition at line 431 of file tlbitfield.h. References TLDynamicBitField< T >::bits, CountBitsCleared(), TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::nents, and TLDynamicBitField< T >::nents_t. |
|
Count number of bits set.
Definition at line 422 of file tlbitfield.h. References TLDynamicBitField< T >::bits, CountBitsSet(), TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::nents, and TLDynamicBitField< T >::nents_t. Referenced by DoTestBitFields(). |
|
Query a bit value; bit in range 0..N-1; no range check!
Definition at line 408 of file tlbitfield.h. References TLDynamicBitField< T >::band, TLDynamicBitField< T >::bits, and TLDynamicBitField< T >::bshift. Referenced by DoTestBitFields(). |
|
Assignment operator: copy bit values:.
Definition at line 362 of file tlbitfield.h. References TLDynamicBitField< T >::_CopyFrom(), and TLDynamicBitField< T >::_Free(). |
|
Resize the bitfield. Data at the beginning of the bitfield is preserved; new data is initialized with passed value.
Definition at line 392 of file tlbitfield.h. References TLDynamicBitField< T >::all_clr, TLDynamicBitField< T >::all_set, TLDynamicBitField< T >::bits, TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::nents, TLDynamicBitField< T >::nents_t, and TLDynamicBitField< T >::resize(). |
|
Resize the bitfield. Data at the beginning of the bitfield is preserved; new data is not initialized. There is another version of this function which will initialize the new data.
Definition at line 375 of file tlbitfield.h. References TLDynamicBitField< T >::_NEntsOfN(), TLDynamicBitField< T >::_SetVals(), TLDynamicBitField< T >::bits, and TLDynamicBitField< T >::nents. Referenced by TLDynamicBitField< T >::resize(). |
|
Search bit address of first cleared (0) bit in bitfield.
Definition at line 458 of file tlbitfield.h. References TLDynamicBitField< T >::all_set, TLDynamicBitField< T >::bits, TLDynamicBitField< T >::bits_per_ent, TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::nents, TLDynamicBitField< T >::nents_t, SearchFirstClearedBit(), and ssize_t. Referenced by DoTestBitFields(). |
|
Search bit address of first set (1) bit in bitfield.
Definition at line 444 of file tlbitfield.h. References TLDynamicBitField< T >::all_clr, TLDynamicBitField< T >::bits, TLDynamicBitField< T >::bits_per_ent, TLDynamicBitField< T >::exmask, TLDynamicBitField< T >::nents, TLDynamicBitField< T >::nents_t, SearchFirstSetBit(), and ssize_t. Referenced by DoTestBitFields(). |
|
Set all bits (to 1).
Definition at line 415 of file tlbitfield.h. References TLDynamicBitField< T >::_SetAllEnts(), and TLDynamicBitField< T >::all_set. Referenced by DoTestBitFields(). |
|
Set a bit; bit in range 0..N-1; no range check!
Definition at line 402 of file tlbitfield.h. References TLDynamicBitField< T >::band, TLDynamicBitField< T >::bits, and TLDynamicBitField< T >::bshift. Referenced by TLDynamicBitField< T >::AssBit(), and DoTestBitFields(). |
|
Definition at line 23 of file test-bitfield.cc. |
|
Constant of type T with all bits cleared.
Definition at line 305 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::ClrAll(), TLDynamicBitField< T >::resize(), TLDynamicBitField< T >::SearchFirstSet(), and TLDynamicBitField< T >::TLDynamicBitField(). |
|
Constant of type T with all bits set.
Definition at line 307 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::resize(), TLDynamicBitField< T >::SearchFirstClr(), TLDynamicBitField< T >::SetAll(), and TLDynamicBitField< T >::TLDynamicBitField(). |
|
AND mask for part of bit address stored inside one entry.
Definition at line 293 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::ClrBit(), DoTestBitFields(), TLDynamicBitField< T >::GetBit(), and TLDynamicBitField< T >::SetBit(). |
|
|
Number of bits per entry:.
Definition at line 302 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::SearchFirstClr(), and TLDynamicBitField< T >::SearchFirstSet(). |
|
Initial value: sizeof(T)==1 ? 3 : sizeof(T)==2 ? 4 : sizeof(T)==4 ? 5 : sizeof(T)==8 ? 6 : sizeof(T)==16 ? 7 : 8
Definition at line 295 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::ClrBit(), DoTestBitFields(), TLDynamicBitField< T >::GetBit(), and TLDynamicBitField< T >::SetBit(). |
|
This mask contains all excess (unused) bits in bits[nents-1].
Definition at line 319 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::_CopyFrom(), TLDynamicBitField< T >::_SetVals(), TLDynamicBitField< T >::CountClr(), TLDynamicBitField< T >::CountSet(), DoTestBitFields(), TLDynamicBitField< T >::resize(), TLDynamicBitField< T >::SearchFirstClr(), and TLDynamicBitField< T >::SearchFirstSet(). |
|
Number of bits in the bitfield.
Definition at line 310 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::_CopyFrom(), TLDynamicBitField< T >::_Free(), and TLDynamicBitField< T >::_SetVals(). |
|
Number of entries in the bitfield array.
Definition at line 312 of file tlbitfield.h. Referenced by TLDynamicBitField< T >::_CopyFrom(), TLDynamicBitField< T >::_Free(), TLDynamicBitField< T >::_Initialize(), TLDynamicBitField< T >::_SetAllEnts(), TLDynamicBitField< T >::_SetVals(), TLDynamicBitField< T >::CountClr(), TLDynamicBitField< T >::CountSet(), DoTestBitFields(), TLDynamicBitField< T >::resize(), TLDynamicBitField< T >::SearchFirstClr(), and TLDynamicBitField< T >::SearchFirstSet(). |