This class is an improved replica of std::bitset and hence stores and exposes a set of bits. The differences (advantages) of this class to the standard type are:
char, short, int, long and long long. If even larger bitsets are requested, the size becomes a multiple of the size of long long.int to a custom type which is statically castable to int, by providing the defaulted template parameter TInterface accordingly. This avoids the need for statically casting the index type with every invocation of an interface method.0 and in this case avoids the need for subtraction of the (fixed) start value of a range with every invocation of an interface method.std::bitset<N>::to_ulong() / to_ullong(), the standard type allows the export of the internal value only to 64-bit values (on common platforms). If the higher bits are to be exported, the bitset has to be shifted, which is inefficient and destructive (a copy has to be taken).In respect to performance, this type equals a typical implementation std::bitset.
int.| TInterface | The interface type to denote bit position values. This type has to be statically castable to and constructible from int. |
| TEnd | The last index of the interface type plus 1. |
| TBegin | The first index of the interface type. (Defaults to 0.) |
Definition at line 63 of file bitset.inl.
Inner Type Index: | |
| class | Reference |
| class | TBidiIterator |
Public Type Index: | |
| using | ConstIterator = TBidiIterator<const TBitSet, false> |
| The constant iterator type. | |
| using | ConstReverseIterator = TBidiIterator<const TBitSet, true> |
| Same as ConstIterator, but working from the end to the start of the TBitSet. | |
| using | Iterator = TBidiIterator<TBitSet, false> |
| using | ReverseIterator = TBidiIterator<TBitSet, true> |
| Same as Iterator, but working from the end to the start of the TBitSet. | |
| using | TWord |
Public Static Field Index: | |
| static constexpr int | Capacity |
| static constexpr int | QtyWords |
| The size of the TWord array containing the bits. | |
Public Method Index: | |
| constexpr | TBitSet () noexcept |
| Default constructor initializing all bits to not set. | |
| constexpr | TBitSet (bool preset) noexcept |
| constexpr | TBitSet (const std::nullptr_t &) noexcept |
| constexpr | TBitSet (TWord preset) noexcept |
| constexpr bool | All () const noexcept |
| constexpr bool | Any () const noexcept |
| Iterator | begin (int skip=0) |
| ConstIterator | begin (int skip=0) const |
| ConstIterator | cbegin (int skip=0) const |
| ConstIterator | cend () const |
| constexpr int | Count () const noexcept |
| ConstReverseIterator | crbegin (int skip=0) const |
| ConstReverseIterator | crend () const |
| Iterator | end () |
| ConstIterator | end () const |
| constexpr const TWord & | Export (int wordIdx) const noexcept |
| constexpr TWord & | Export (int wordIdx) noexcept |
| constexpr TBitSet & | Flip () noexcept |
Flips all bits from 0 to 1 and vice versa. | |
| template<typename... T> | |
| constexpr TBitSet & | Flip (TInterface firstBit, T &&... furtherBits) noexcept |
| constexpr void | Import (TWord val, int wordIdx) noexcept |
| constexpr bool | None () const noexcept |
| constexpr TBitSet & | operator&= (const TBitSet &rhs) noexcept |
| constexpr TBitSet | operator<< (int cnt) const noexcept |
| constexpr TBitSet & | operator<<= (int cnt) noexcept |
| constexpr bool | operator== (const TBitSet &rhs) const noexcept |
| constexpr TBitSet | operator>> (int cnt) const noexcept |
| constexpr TBitSet & | operator>>= (int cnt) noexcept |
| constexpr const Reference< const TBitSet > | operator[] (int bit) const noexcept |
| constexpr Reference< TBitSet > | operator[] (TInterface bit) noexcept |
| constexpr TBitSet & | operator^= (const TBitSet &rhs) noexcept |
| constexpr TBitSet & | operator|= (const TBitSet &rhs) noexcept |
| constexpr TBitSet | operator~ () const noexcept |
| ReverseIterator | rbegin (int skip=0) |
| ConstReverseIterator | rbegin (int skip=0) const |
| ReverseIterator | rend () |
| ConstReverseIterator | rend () const |
| constexpr TBitSet & | Reset () noexcept |
Sets all bits to 0. | |
| template<typename... T> | |
| constexpr TBitSet & | Reset (TInterface firstBit, T &&... furtherBits) noexcept |
| constexpr TBitSet & | Set () noexcept |
Sets all bits to 1. | |
| template<typename... T> | |
| constexpr TBitSet & | Set (TInterface bit, bool val) noexcept |
| template<typename... T> | |
| constexpr TBitSet & | Set (TInterface firstBit, T &&... furtherBits) noexcept |
| constexpr bool | Test (TInterface bit) noexcept |
Protected Static Method Index: | |
| static constexpr int | bitIdx (TInterface b) noexcept |
| static constexpr TWord | mask (int wIdx) noexcept |
| static constexpr TWord | mask0010 (TInterface b) noexcept |
| static constexpr TWord | mask1101 (TInterface b) noexcept |
| static constexpr int | wordIdx (TInterface b) noexcept |
Protected Field Index: | |
| TWord | words [QtyWords ? QtyWords :1] |
Protected Method Index: | |
| constexpr void | shiftLeft (int cnt, TBitSet &target) const noexcept |
| constexpr void | shiftRight (int cnt, TBitSet &target) const noexcept |
| constexpr const TWord & | word (TInterface b) const noexcept |
| constexpr TWord & | word (TInterface b) noexcept |
| using alib::lang::TBitSet< TInterface, TEnd, TBegin >::ConstIterator = TBidiIterator<const TBitSet, false> |
The constant iterator type.
Definition at line 737 of file bitset.inl.
| using alib::lang::TBitSet< TInterface, TEnd, TBegin >::ConstReverseIterator = TBidiIterator<const TBitSet, true> |
Same as ConstIterator, but working from the end to the start of the TBitSet.
Definition at line 740 of file bitset.inl.
| using alib::lang::TBitSet< TInterface, TEnd, TBegin >::Iterator = TBidiIterator<TBitSet, false> |
Iterator type, implementing the standard library concept of RandomAccessIterator .
Definition at line 731 of file bitset.inl.
| using alib::lang::TBitSet< TInterface, TEnd, TBegin >::ReverseIterator = TBidiIterator<TBitSet, true> |
Same as Iterator, but working from the end to the start of the TBitSet.
Definition at line 734 of file bitset.inl.
| using alib::lang::TBitSet< TInterface, TEnd, TBegin >::TWord |
The type that is used to store the bits in. Template programming code chooses the smallest fitting integral. If Capacity exceeds the type long long, an array of long long, field QtyWords will become greater than 1.
Definition at line 84 of file bitset.inl.
|
staticconstexpr |
The number of bits in the range resulting from template parameters TBegin and TEnd.
Definition at line 77 of file bitset.inl.
|
staticconstexpr |
The size of the TWord array containing the bits.
Definition at line 91 of file bitset.inl.
|
protected |
The array of integrals containing the bits needed. The unused upper bits in the last word are always kept 0.
Definition at line 97 of file bitset.inl.
|
inlineconstexprnoexcept |
Default constructor initializing all bits to not set.
Definition at line 223 of file bitset.inl.
|
inlineconstexprnoexcept |
Constructor taking a tag-type. This constructor omits any value initialization and has to be called by providing nullptr as the argument.
Definition at line 228 of file bitset.inl.
|
inlineconstexprnoexcept |
Constructor which takes an external TWord which initializes the first word. If constexpr field QtyWords is greater than 1, the other bits are set to 0 and can be set using method Import or of course using other interface methods.
| preset | The preset value for the bits. |
Definition at line 234 of file bitset.inl.
|
inlineconstexprnoexcept |
Constructor which takes an external TWord which initializes the first word. If constexpr field QtyWords is greater than 1, the other bits are set to 0 and can be set using method Import or of course using other interface methods.
| preset | The preset value for the bits. |
Definition at line 244 of file bitset.inl.
|
inlineconstexprnoexcept |
Tests if any bit is set.
true if all bits are set, false otherwise. Definition at line 332 of file bitset.inl.
|
inlineconstexprnoexcept |
Tests if any bit is set.
true if at least one bit is set, false otherwise. Definition at line 342 of file bitset.inl.
|
inline |
Returns an iterator pointing to the first (lowest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 746 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the first (lowest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 768 of file bitset.inl.
|
inlinestaticconstexprprotectednoexcept |
Helper to determine the bit index in the actual word.
| b | The absolute index. |
Definition at line 109 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the first (lowest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 775 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the non-existing bit behind the highest one.
Definition at line 784 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns the number of bits set to true in this set.
Definition at line 322 of file bitset.inl.
|
inline |
Returns a const reverse iterator pointing to the last (highest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 801 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the non-existing bit before the lowest one.
Definition at line 806 of file bitset.inl.
|
inline |
Returns an iterator pointing to the non-existing bit behind the highest one.
Definition at line 751 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the non-existing bit behind the highest one.
Definition at line 780 of file bitset.inl.
|
inlineconstexprnoexcept |
Const version of Export.
| wordIdx | The subset of bits to receive. ATTENTION: See non-constant variant Export on this parameter! |
Definition at line 378 of file bitset.inl.
|
inlineconstexprnoexcept |
Exports the internal integral(s) holding the bits.
sizeof(long long) * 8. In that case, field QtyWords provides the number of words that are exportable.0 adresses bits 0..63, 1 bits 64..127 and so forth.| wordIdx | The subset of bits to receive. (See note above!) |
Definition at line 370 of file bitset.inl.
|
inlineconstexprnoexcept |
Flips all bits from 0 to 1 and vice versa.
Definition at line 309 of file bitset.inl.
|
inlineconstexprnoexcept |
Flips one or more bits from 0 to 1 and vice versa.
| firstBit | The index of the bit to flip. |
| furtherBits | An optional continued list of indices of bits to flip. |
this object. Definition at line 296 of file bitset.inl.
|
inlineconstexprnoexcept |
Imports the data from (a) given integral(s).
sizeof(long long) * 8. In that case, field QtyWords provides the number of words that are importable.0 address bits 0..63, 1 bits 64..127 and so forth.| val | The value to import. |
| wordIdx | The subset of bits to overwrite. (See note above!) |
Definition at line 406 of file bitset.inl.
|
inlinestaticconstexprprotectednoexcept |
Returns a bitmask with all used bits set.
| wIdx | The index of the word in array words. |
-1, and a mask that covers the remaining bits if wIdx targets the last word. Definition at line 131 of file bitset.inl.
|
inlinestaticconstexprprotectednoexcept |
Returns a bitmask with only the given bit set.
| b | The index of the bit to set. |
Definition at line 140 of file bitset.inl.
|
inlinestaticconstexprprotectednoexcept |
Returns a bitmask with only the given bit unset.
| b | The index of the bit to unset. |
Definition at line 145 of file bitset.inl.
|
inlineconstexprnoexcept |
Tests if not any bit is set.
false if at least one bit is set, true otherwise. Definition at line 352 of file bitset.inl.
|
inlineconstexprnoexcept |
Sets the bits to the result of binary AND on corresponding pairs of bits of this and other.
| rhs | The other TBitSet to compare this with. |
this object. Definition at line 436 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns a temporary copy of this with a shift to the left (towards higher index positions).
| cnt | The number of positions to shift. |
Definition at line 524 of file bitset.inl.
|
inlineconstexprnoexcept |
Shifts the bits of this object to the left (towards higher index positions).
| cnt | The number of positions to shift. |
Definition at line 530 of file bitset.inl.
|
inlineconstexprnoexcept |
Compares this bitset with another bitset of equal size.
| rhs | The other TBitSet to compare this with. |
true if all bits are equal, false otherwise. Definition at line 426 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns a temporary copy of this with a shift to the right (towards lower index positions).
| cnt | The number of positions to shift. |
Definition at line 535 of file bitset.inl.
|
inlineconstexprnoexcept |
Shifts the bits of this object to the left right (towards lower index positions).
| cnt | The number of positions to shift. |
Definition at line 541 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns a const reference to a specific bit.
| bit | The bit to create a reference for. |
Definition at line 554 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns a reference to a specific bit.
| bit | The bit to create a reference for. |
Definition at line 547 of file bitset.inl.
|
inlineconstexprnoexcept |
Sets the bits to the result of binary XOR on corresponding pairs of bits of this and other.
| rhs | The other TBitSet to compare this with. |
this object. Definition at line 446 of file bitset.inl.
|
inlineconstexprnoexcept |
Sets the bits to the result of binary OR on corresponding pairs of bits of this and other.
| rhs | The other TBitSet to compare this with. |
this object. Definition at line 441 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns a temporary copy of this with all bits flipped (binary NOT)..
Definition at line 450 of file bitset.inl.
|
inline |
Returns a reverse iterator pointing to the last (highest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 757 of file bitset.inl.
|
inline |
Returns a const reverse iterator pointing to the last (highest) bit set.
| skip | Defaults to 0. If set, denotes the amount of bits which are not examined at the beginning of the iteration. Must not be negative. |
Definition at line 790 of file bitset.inl.
|
inline |
Returns an iterator pointing to the non-existing bit before the lowest one.
Definition at line 762 of file bitset.inl.
|
inline |
Returns a const iterator pointing to the non-existing bit before the lowest one.
Definition at line 795 of file bitset.inl.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Sets one or more bits to 0.
| firstBit | The index of the first bit to clear. |
| furtherBits | An optional continued list of bit-indices. |
this object. Definition at line 283 of file bitset.inl.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Sets the bit to 1.
| bit | The index of the bit to set. |
| val | true or false to set or clear bit bit. |
this object. Definition at line 258 of file bitset.inl.
|
inlineconstexprnoexcept |
Sets one or more bits to 1.
| firstBit | The index of the first bit to set. |
| furtherBits | An optional continued list of bit-indices. |
this object. Definition at line 270 of file bitset.inl.
|
inlineconstexprprotectednoexcept |
Stores a shifted result in target. This protected method is accessible via operator<<() (which creates and returns a temporary target) and operator<<=(), which passes this to parameter target.
| cnt | The number of positions to shift. |
| target | The target object. |
Definition at line 463 of file bitset.inl.
|
inlineconstexprprotectednoexcept |
Stores a shifted result in target. This protected method is accessible via operator>>() (which creates and returns a temporary target) and operator>>=(), which passes this to parameter target.
| cnt | The number of positions to shift. |
| target | The target object. |
Definition at line 494 of file bitset.inl.
|
inlineconstexprnoexcept |
Returns true if the bit is set, false otherwise.
| bit | Denotes the bit to test. |
Definition at line 316 of file bitset.inl.
|
inlineconstexprprotectednoexcept |
Helper receive a const reference word from the array of words.
| b | The bit to address index. |
Definition at line 125 of file bitset.inl.
|
inlineconstexprprotectednoexcept |
Helper receive the word from the array of words.
| b | The bit to address index. |
Definition at line 120 of file bitset.inl.
|
inlinestaticconstexprprotectednoexcept |
Helper to determine the bit index in the actual word.
| b | The absolute index. |
Definition at line 103 of file bitset.inl.