62template<
typename TInterface, TInterface TEnd, TInterface TBegin= 0>
67 static_assert( !(TBegin > TEnd),
"First Idx greater or equal than last index + 1" );
70 template<
typename TBitSetCM,
bool isReverse>
class TBidiIterator;
103 constexpr static int wordIdx(TInterface b)
noexcept
109 constexpr static int bitIdx (TInterface b)
noexcept {
111 &&
int(b) <
int(TEnd),
112 "LANG",
"Given bit index out of bounds: {} <= {} < {} ",
152 template<
typename TBitSetCM>
157 template<
typename T,
bool isReverse>
friend class TBidiIterator;
169 constexpr Reference(TBitSetCM& set, TInterface b) noexcept
187 constexpr TInterface
Bit() const noexcept {
return TInterface(
bit); }
204 constexpr operator bool() noexcept {
return bitSet->Test(
bit); }
228 constexpr TBitSet(
const std::nullptr_t&)
noexcept {}
256 template <
typename... T>
268 template <
typename... T>
270 TBitSet&
Set( TInterface firstBit, T&&... furtherBits )
noexcept {
272 if constexpr (
sizeof...(furtherBits) > 0)
281 template <
typename... T>
285 if constexpr (
sizeof...(furtherBits) > 0)
286 Reset(furtherBits...);
294 template <
typename... T>
296 TBitSet&
Flip( TInterface firstBit, T&&... furtherBits )
noexcept {
298 if constexpr (
sizeof...(furtherBits) > 0)
299 Flip(furtherBits...);
332 bool All() const noexcept {
342 bool Any() const noexcept {
381 template<
bool TRequires=QtyWords==1>
requires TRequires
constexpr TWord&
Export() noexcept {
return words[ 0]; }
382 template<
bool TRequires=QtyWords==1>
requires TRequires
const constexpr TWord Export() const noexcept {
return words[ 0]; }
383 template<
bool TRequires=QtyWords!=1>
requires TRequires
constexpr TWord&
Export(
int wordIdx)
noexcept {
386 template<
bool TRequires=QtyWords!=1>
requires TRequires
const constexpr TWord Export(
int wordIdx)
const noexcept {
409 template<
bool TRequires=QtyWords==1>
413 template<
bool TRequires=QtyWords!=1>
428 if(
words[w] != rhs.words[w] )
465 "Negative value {} for TBitSet shift operation given.", cnt )
476 for(
int w=
QtyWords -1; w >= 0; --w )
477 target.words[w]= w - offW >= 0 ?
words[w - offW]
481 for(
int w=
QtyWords -1; w >= 0; --w )
482 target.words[w]= w >= offW ? (
TWord(
words[w - offW] << offB)
496 "Negative value {} for TBitSet shift operation given.", cnt )
548 {
return Reference<TBitSet>(*
this, bit); }
554 const Reference<const TBitSet>
operator[](
int bit)
const noexcept
555 {
return Reference<const TBitSet>(*
this, bit); }
571 template<
typename TBitSetCM,
bool isReverse>
592 ref.bit= TInterface(
int(
ref.bit) + 1);
595 while(
int(
ref.bit) <
int(TEnd)) {
606 if(
int(
ref.bit) >
int(TEnd))
607 ref.bit= TInterface(TEnd);
612 ref.bit= TInterface(
int(
ref.bit) + trailingZeros - bIdx);
623 ref.bit= TInterface(
int(
ref.bit) - 1);
626 while(
int(
ref.bit) >=
int(TBegin)) {
638 ref.bit= TInterface(
int(
ref.bit) - bIdx -1);
639 if(
int(
ref.bit) <
int(TBegin) -1)
640 ref.bit= TInterface(
int(TBegin) - 1);
645 ref.bit= TInterface(
int(
ref.bit)
658 :
ref(bitSet, startBit) {}
747 {
return ++
Iterator(*
this, TInterface(TBegin - 1) + skip); }
769 {
return ++
ConstIterator(*
this, TInterface(TBegin-1) + skip ); }
776 {
return ++
ConstIterator(*
this, TInterface(TBegin-1) + skip ); }
812DOX_MARKER([DOX_MANUAL_ALIASES_BITSET])
814template<
int TEnd,
int TBegin= 0,
typename TInterface=
int>
816DOX_MARKER([DOX_MANUAL_ALIASES_BITSET])
837template<
typename TInterface, TInterface TEnd, TInterface TBegin>
844 result.
Import( lhs.Export() & rhs.Export() );
846 for (
int w = 0; w < alib::lang::TBitSet<TInterface,TEnd,TBegin>::QtyWords; ++w)
847 result.
Import( lhs.Export(w) & rhs.Export(w), w );
862template<
typename TInterface, TInterface TEnd, TInterface TBegin>
869 result.
Import( lhs.Export() | rhs.Export() );
871 for (
int w = 0; w < alib::lang::TBitSet<TInterface,TEnd,TBegin>::QtyWords; ++w)
872 result.
Import( lhs.Export(w) | rhs.Export(w), w );
887template<
typename TInterface, TInterface TEnd, TInterface TBegin>
894 result.
Import( lhs.Export() ^ rhs.Export() );
896 for (
int w = 0; w < alib::lang::TBitSet<TInterface,TEnd,TBegin>::QtyWords; ++w)
897 result.
Import( lhs.Export(w) ^ rhs.Export(w), w );
Reference & operator=(const Reference &other) noexcept=default
constexpr Reference(TBitSetCM &set, TInterface b) noexcept
constexpr class TBitSet & TBitSet() noexcept
~Reference() noexcept
Destructor. (Is declared constexpr with C++23.)
constexpr Reference & Flip() noexcept
constexpr TInterface Bit() const noexcept
constexpr const class TBitSet & TBitSet() const noexcept
constexpr Reference & operator=(bool val) noexcept
constexpr bool operator==(const Reference &rhs) const noexcept=default
constexpr bool operator~() noexcept
constexpr Reference(const Reference &) noexcept=default
Defaulted copy constructor.
TInterface value_type
Implementation of std::iterator_traits.
TBidiIterator operator--(int)
TBidiIterator operator++(int)
Reference< TBitSetCM > & reference
Implementation of std::iterator_traits.
bool operator>=(TBidiIterator other) const
bool operator!=(const TBidiIterator &other) const
bool operator>(TBidiIterator other) const
void pointer
Implementation of std::iterator_traits.
bool operator<=(TBidiIterator other) const
TBidiIterator & operator--()
TBidiIterator & operator++()
TBidiIterator(TBitSetCM &bitSet, TInterface startBit)
bool operator<(TBidiIterator other) const
bool operator==(const TBidiIterator &other) const
int difference_type
Implementation of std::iterator_traits.
std::bidirectional_iterator_tag iterator_category
Implementation of std::iterator_traits.
ConstReverseIterator rend() const
constexpr bool All() const noexcept
constexpr TBitSet(TWord preset) noexcept
constexpr TBitSet & Flip() noexcept
Flips all bits from 0 to 1 and vice versa.
static constexpr TWord mask(int wIdx) noexcept
constexpr TBitSet & operator&=(const TBitSet &rhs) noexcept
constexpr void shiftRight(int cnt, TBitSet &target) const noexcept
constexpr TBitSet & Reset(TInterface firstBit, T &&... furtherBits) noexcept
constexpr TBitSet & operator|=(const TBitSet &rhs) noexcept
constexpr TBitSet() noexcept
Default constructor initializing all bits to not set.
TBidiIterator< TBitSet, false > Iterator
constexpr int Count() const noexcept
constexpr TBitSet & Set(TInterface bit, bool val) noexcept
ReverseIterator rbegin(int skip=0)
constexpr TBitSet & Set(TInterface firstBit, T &&... furtherBits) noexcept
constexpr TBitSet & Reset() noexcept
Sets all bits to 0.
constexpr bool operator==(const TBitSet &rhs) const noexcept
constexpr TWord & word(TInterface b) noexcept
constexpr TBitSet & operator^=(const TBitSet &rhs) noexcept
constexpr TBitSet(bool preset) noexcept
TBidiIterator< TBitSet, true > ReverseIterator
constexpr TBitSet operator>>(int cnt) const noexcept
ConstIterator cbegin(int skip=0) const
static constexpr int bitIdx(TInterface b) noexcept
static constexpr int QtyWords
ConstReverseIterator rbegin(int skip=0) const
constexpr bool Test(TInterface bit) noexcept
TBidiIterator< const TBitSet, true > ConstReverseIterator
std::conditional_t<(Capacity > bitsof(long)), unsigned long long, std::conditional_t<(Capacity > bitsof(int)), unsigned long, std::conditional_t<(Capacity > bitsof(short)), unsigned int, std::conditional_t<(Capacity > bitsof(char)), unsigned short, unsigned char > > > > TWord
constexpr const TWord & Export(int wordIdx) const noexcept
static constexpr TWord mask1101(TInterface b) noexcept
constexpr const TWord & word(TInterface b) const noexcept
constexpr TBitSet operator~() const noexcept
constexpr void Import(TWord val, int wordIdx) noexcept
static constexpr TWord mask0010(TInterface b) noexcept
constexpr const Reference< const TBitSet > operator[](int bit) const noexcept
ConstReverseIterator crbegin(int skip=0) const
constexpr TBitSet & Flip(TInterface firstBit, T &&... furtherBits) noexcept
constexpr Reference< TBitSet > operator[](TInterface bit) noexcept
constexpr TBitSet & Set() noexcept
Sets all bits to 1.
static constexpr int Capacity
Iterator begin(int skip=0)
constexpr bool Any() const noexcept
constexpr TBitSet(const std::nullptr_t &) noexcept
constexpr TWord & Export(int wordIdx) noexcept
ConstIterator cend() const
ConstIterator begin(int skip=0) const
constexpr TBitSet & operator<<=(int cnt) noexcept
TWord words[QtyWords ? QtyWords :1]
constexpr TBitSet & operator>>=(int cnt) noexcept
TBidiIterator< const TBitSet, false > ConstIterator
ConstIterator end() const
constexpr bool None() const noexcept
ConstReverseIterator crend() const
constexpr TBitSet operator<<(int cnt) const noexcept
static constexpr int wordIdx(TInterface b) noexcept
constexpr void shiftLeft(int cnt, TBitSet &target) const noexcept
#define ALIB_ASSERT_ERROR(cond, domain,...)
platform_specific integer
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator&(const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
constexpr int CLZ(TIntegral value)
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator^(const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
constexpr TIntegral UpperMask()
constexpr int CTZ(TIntegral value)
constexpr TIntegral LowerMask()
ALIB_EXPORT constexpr alib::lang::TBitSet< TInterface, TEnd, TBegin > operator|(const alib::lang::TBitSet< TInterface, TEnd, TBegin > &lhs, const alib::lang::TBitSet< TInterface, TEnd, TBegin > &rhs) noexcept
constexpr int BitCount(TIntegral value)
lang::TBitSet< int, TEnd, TBegin > BitSet
Type alias in namespace alib.