TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
A compact version of std::bitset. More...
#include <tsCompactBitSet.h>
Public Types | |
using | int_t = typename smaller_unsigned< BITS >::type |
The underlying unsigned integer type to represent the bit set. | |
Public Member Functions | |
template<class CONTAINER > requires std::integral<typename CONTAINER::value_type> | |
CompactBitSet (const CONTAINER &values) | |
Constructor from a container of integer values. | |
CompactBitSet (int_t value=0) | |
Constructor. | |
bool | all () const |
Check if all labels are set. | |
bool | any () const |
Check if at least one label is set. | |
void | flip () |
Flip all bits in the set. | |
bool | none () const |
Check if no label is set. | |
CompactBitSet< BITS > | operator& (const CompactBitSet< BITS > &p) const |
Binary and operator. | |
CompactBitSet< BITS > & | operator&= (const CompactBitSet< BITS > &p) |
Assign with binary and operator. | |
bool | operator== (const CompactBitSet< BITS > &p) const |
Equality operator. | |
CompactBitSet< BITS > | operator| (const CompactBitSet< BITS > &p) const |
Binary or operator. | |
CompactBitSet< BITS > & | operator|= (const CompactBitSet< BITS > &p) |
Assign with binary or operator. | |
CompactBitSet< BITS > | operator~ () const |
Negation unary operator. | |
void | reset () |
Reset all labels. | |
void | reset (size_t pos) |
Reset one label. | |
void | set () |
Set all labels. | |
void | set (size_t pos, bool value=true) |
Set or reset one label. | |
size_t | size () const |
Get the size in bits of the bit set. | |
bool | test (size_t pos) const |
Test is a label is set. | |
int_t | toInt () const |
Return the set of labels as a 32-bit integer. | |
Static Public Attributes | |
static constexpr int_t | ALL = int_t(BITS == 8 * sizeof(int_t) ? ~int_t(0) : ~(~uint64_t(0) << BITS)) |
The int_t value corresponding to all bits set. | |
static constexpr size_t | MAX = BITS - 1 |
Maximum value for bit position. | |
static constexpr size_t | SIZE = BITS |
Number of bits in this set. | |
A compact version of std::bitset.
This class is more efficient than std::bitset for small sizes, typically 32 bits or less.
Differences with std::bitset:
BITS | Number of bits. Must be in the range 0 to 64. |
|
inline |
Constructor.
[in] | value | Initial value as a bit mask. Bits are numbered from LSB to MSB. |
|
inline |
Constructor from a container of integer values.
CONTAINER | A container type of integer values. |
[in] | values | Initial label values to set. Bits are numbered from LSB to MSB. |
|
inline |
Equality operator.
[in] | p | Other instance to compare. |
|
inline |
Get the size in bits of the bit set.
|
inline |
Negation unary operator.
|
inline |
Binary or operator.
[in] | p | Other instance to compare. |
|
inline |
Binary and operator.
[in] | p | Other instance to compare. |
|
inline |
Assign with binary or operator.
[in] | p | Other instance to compare. |
|
inline |
Assign with binary and operator.
[in] | p | Other instance to compare. |
|
inline |
Check if all labels are set.
|
inline |
Check if at least one label is set.
|
inline |
Check if no label is set.
|
inline |
Set or reset one label.
[in] | pos | Label to alter, 0 to 31. |
[in] | value | Optional label value to set, true by default. |
|
inline |
Reset one label.
[in] | pos | Label to reset, 0 to 31. |
|
inline |
Test is a label is set.
[in] | pos | Label to test, 0 to 31. |
|
inline |
Return the set of labels as a 32-bit integer.