dynamic_bitset 1.3.0
Simple Useful Libraries: C++17/20 header-only dynamic bitset
Loading...
Searching...
No Matches
sul::dynamic_bitset< Block, Allocator > Class Template Reference

Dynamic bitset. More...

#include <sul/dynamic_bitset.hpp>

Classes

class  reference
 Reference to a sul::dynamic_bitset bit. More...
 

Public Types

typedef size_t size_type
 Type used to represent the size of a sul::dynamic_bitset.
 
typedef Block block_type
 Same type as Block.
 
typedef Allocator allocator_type
 Same type as Allocator.
 
typedef bool const_reference
 Const reference to a sul::dynamic_bitset bit, type bool.
 

Public Member Functions

constexpr dynamic_bitset (const dynamic_bitset< Block, Allocator > &other)=default
 Copy constructor.
 
constexpr dynamic_bitset (dynamic_bitset< Block, Allocator > &&other) noexcept=default
 Move constructor.
 
constexpr dynamic_bitset< Block, Allocator > & operator= (const dynamic_bitset< Block, Allocator > &other)=default
 Copy assignment operator.
 
constexpr dynamic_bitset< Block, Allocator > & operator= (dynamic_bitset< Block, Allocator > &&other) noexcept=default
 Move assignment operator.
 
constexpr dynamic_bitset (const allocator_type &allocator=allocator_type())
 Constructs an empty sul::dynamic_bitset.
 
constexpr dynamic_bitset (size_type nbits, unsigned long long init_val=0, const allocator_type &allocator=allocator_type())
 Constructs a sul::dynamic_bitset of nbits bits from an initial value.
 
constexpr dynamic_bitset (std::initializer_list< block_type > init_vals, const allocator_type &allocator=allocator_type())
 Constructs a sul::dynamic_bitset using init_vals to initialize the first blocks.
 
template<typename _CharT , typename _Traits >
constexpr dynamic_bitset (std::basic_string_view< _CharT, _Traits > str, typename std::basic_string_view< _CharT, _Traits >::size_type pos=0, typename std::basic_string_view< _CharT, _Traits >::size_type n=std::basic_string_view< _CharT, _Traits >::npos, _CharT zero=_CharT('0'), _CharT one=_CharT('1'), const allocator_type &allocator=allocator_type())
 Constructs a sul::dynamic_bitset from a string or a part of a string.
 
template<typename _CharT , typename _Traits , typename _Alloc >
constexpr dynamic_bitset (const std::basic_string< _CharT, _Traits, _Alloc > &str, typename std::basic_string< _CharT, _Traits, _Alloc >::size_type pos=0, typename std::basic_string< _CharT, _Traits, _Alloc >::size_type n=std::basic_string< _CharT, _Traits, _Alloc >::npos, _CharT zero=_CharT('0'), _CharT one=_CharT('1'), const allocator_type &allocator=allocator_type())
 Constructs a sul::dynamic_bitset from a string or a part of a string.
 
template<typename _CharT , typename _Traits = std::char_traits<_CharT>>
constexpr dynamic_bitset (const _CharT *str, typename std::basic_string< _CharT >::size_type pos=0, typename std::basic_string< _CharT >::size_type n=std::basic_string< _CharT >::npos, _CharT zero=_CharT('0'), _CharT one=_CharT('1'), const allocator_type &allocator=allocator_type())
 Constructs a sul::dynamic_bitset from a string or a part of a string.
 
 ~dynamic_bitset () noexcept=default
 Destructor.
 
constexpr void resize (size_type nbits, bool value=false)
 Resize the sul::dynamic_bitset to contain nbits bits.
 
constexpr void clear ()
 Clears the sul::dynamic_bitset, resize it to 0.
 
constexpr void push_back (bool value)
 Add a new bit with the value value at the end of the sul::dynamic_bitset.
 
constexpr void pop_back ()
 Remove the last bit of the sul::dynamic_bitset.
 
constexpr void append (block_type block)
 Append a block of bits block at the end of the sul::dynamic_bitset.
 
constexpr void append (std::initializer_list< block_type > blocks)
 Append blocks of bits from blocks at the end of the sul::dynamic_bitset.
 
template<typename BlockInputIterator >
constexpr void append (BlockInputIterator first, BlockInputIterator last)
 Append blocks of bits from the range [first, last[ at the end of the dynamic_bitset.
 
constexpr dynamic_bitset< Block, Allocator > & operator&= (const dynamic_bitset< Block, Allocator > &rhs)
 Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitset< Block, Allocator > & operator|= (const dynamic_bitset< Block, Allocator > &rhs)
 Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitset< Block, Allocator > & operator^= (const dynamic_bitset< Block, Allocator > &rhs)
 Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitset< Block, Allocator > & operator-= (const dynamic_bitset< Block, Allocator > &rhs)
 Sets the bits to the result of the binary difference between the bits of *this and rhs.
 
constexpr dynamic_bitset< Block, Allocator > & operator<<= (size_type shift)
 Performs binary shift left of shift bits.
 
constexpr dynamic_bitset< Block, Allocator > & operator>>= (size_type shift)
 Performs binary shift right of shift bits.
 
constexpr dynamic_bitset< Block, Allocatoroperator<< (size_type shift) const
 Performs binary shift right of shift bits.
 
constexpr dynamic_bitset< Block, Allocatoroperator>> (size_type shift) const
 Performs binary shift left of shift bits.
 
constexpr dynamic_bitset< Block, Allocatoroperator~ () const
 Performs a unary NOT on all bits.
 
constexpr dynamic_bitset< Block, Allocator > & set (size_type pos, size_type len, bool value)
 Set the bits of the range [pos, pos + len[ to value value.
 
constexpr dynamic_bitset< Block, Allocator > & set (size_type pos, bool value=true)
 Set the bit at the position pos to true or value value.
 
constexpr dynamic_bitset< Block, Allocator > & set ()
 Set all the bits of the sul::dynamic_bitset to true.
 
constexpr dynamic_bitset< Block, Allocator > & reset (size_type pos, size_type len)
 Reset the bits of the range [pos, pos + len[ to false.
 
constexpr dynamic_bitset< Block, Allocator > & reset (size_type pos)
 Reset the bit at the position pos to false.
 
constexpr dynamic_bitset< Block, Allocator > & reset ()
 Reset all the bits of the sul::dynamic_bitset to false.
 
constexpr dynamic_bitset< Block, Allocator > & flip (size_type pos, size_type len)
 Flip the bits of the range [pos, pos + len[.
 
constexpr dynamic_bitset< Block, Allocator > & flip (size_type pos)
 Flip the bit at the position pos.
 
constexpr dynamic_bitset< Block, Allocator > & flip ()
 Flip all the bits of the sul::dynamic_bitset.
 
constexpr bool test (size_type pos) const
 Test the value of the bit at position pos.
 
constexpr bool test_set (size_type pos, bool value=true)
 Test the value of the bit at position pos and set it to true or value value.
 
constexpr bool all () const
 Checks if all bits are set to true.
 
constexpr bool any () const
 Checks if any bits are set to true.
 
constexpr bool none () const
 Checks if none of the bits are set to true.
 
constexpr size_type count () const noexcept
 Count the number of bits set to true.
 
constexpr reference operator[] (size_type pos)
 Accesses the bit at position pos.
 
constexpr const_reference operator[] (size_type pos) const
 Accesses the bit at position pos.
 
constexpr size_type size () const noexcept
 Give the number of bits of the sul::dynamic_bitset.
 
constexpr size_type num_blocks () const noexcept
 Give the number of blocks used by the sul::dynamic_bitset.
 
constexpr bool empty () const noexcept
 Checks if the sul::dynamic_bitset is empty.
 
constexpr size_type capacity () const noexcept
 Give the number of bits that the sul::dynamic_bitset has currently allocated space for.
 
constexpr void reserve (size_type num_bits)
 Increase the capacity of the sul::dynamic_bitset to a value that's greater or equal to num_bits.
 
constexpr void shrink_to_fit ()
 Requests the removal of unused capacity.
 
constexpr bool is_subset_of (const dynamic_bitset< Block, Allocator > &bitset) const
 Determines if this sul::dynamic_bitset is a subset of bitset.
 
constexpr bool is_proper_subset_of (const dynamic_bitset< Block, Allocator > &bitset) const
 Determines if this sul::dynamic_bitset is a proper subset of bitset.
 
constexpr bool intersects (const dynamic_bitset< Block, Allocator > &bitset) const
 Determines if this sul::dynamic_bitset and bitset intersect.
 
constexpr size_type find_first () const
 Find the position of the first bit set in the sul::dynamic_bitset starting from the least-significant bit.
 
constexpr size_type find_next (size_type prev) const
 Find the position of the first bit set in the range [prev + 1, size()[ of the sul::dynamic_bitset starting from the position prev + 1.
 
constexpr void swap (dynamic_bitset< Block, Allocator > &other)
 Exchanges the bits of this sul::dynamic_bitset with those of other.
 
constexpr allocator_type get_allocator () const
 Gets the associated allocator.
 
template<typename _CharT = char, typename _Traits = std::char_traits<_CharT>, typename _Alloc = std::allocator<_CharT>>
constexpr std::basic_string< _CharT, _Traits, _Allocto_string (_CharT zero=_CharT('0'), _CharT one=_CharT('1')) const
 Generate a string representation of the sul::dynamic_bitset.
 
constexpr unsigned long to_ulong () const
 Converts the contents of the bitset to an unsigned long integer.
 
constexpr unsigned long long to_ullong () const
 Converts the contents of the bitset to an unsigned long long integer.
 
template<typename Function , typename... Parameters>
constexpr void iterate_bits_on (Function &&function, Parameters &&... parameters) const
 Iterate on the sul::dynamic_bitset and call function with the position of the bits on.
 
constexpr block_typedata () noexcept
 Return a pointer to the underlying array serving as blocks storage.
 
constexpr const block_typedata () const noexcept
 Return a pointer to the underlying array serving as blocks storage.
 

Static Public Attributes

static constexpr size_type bits_per_block = std::numeric_limits<block_type>::digits
 Number of bits that can be stored in a block.
 
static constexpr size_type npos = std::numeric_limits<size_type>::max()
 Maximum value of size_type, returned for invalid positions.
 

Friends

template<typename Block_ , typename Allocator_ >
constexpr bool operator== (const dynamic_bitset< Block_, Allocator_ > &lhs, const dynamic_bitset< Block_, Allocator_ > &rhs)
 Test if two sul::dynamic_bitset have the same content.
 
template<typename Block_ , typename Allocator_ >
constexpr bool operator< (const dynamic_bitset< Block_, Allocator_ > &lhs, const dynamic_bitset< Block_, Allocator_ > &rhs)
 Test if lhs is "less than" rhs. The comparison of the two dynamic_bitset is first on numbers their content represent and then on their size.
 

Related Symbols

(Note that these are not member symbols.)

template<typename Block , typename Allocator >
constexpr bool operator!= (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Test if two sul::dynamic_bitset content are different.
 
template<typename Block , typename Allocator >
constexpr bool operator<= (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Test if lhs is "less than or equal to" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.
 
template<typename Block , typename Allocator >
constexpr bool operator> (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Test if lhs is "greater than" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.
 
template<typename Block , typename Allocator >
constexpr bool operator>= (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Test if lhs is "greater than or equal to" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.
 
template<typename Block , typename Allocator >
constexpr dynamic_bitset< Block, Allocatoroperator& (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Performs binary AND on corresponding pairs of bits of lhs and rhs.
 
template<typename Block , typename Allocator >
constexpr dynamic_bitset< Block, Allocatoroperator| (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Performs binary OR on corresponding pairs of bits of lhs and rhs.
 
template<typename Block , typename Allocator >
constexpr dynamic_bitset< Block, Allocatoroperator^ (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Performs binary XOR on corresponding pairs of bits of lhs and rhs.
 
template<typename Block , typename Allocator >
constexpr dynamic_bitset< Block, Allocatoroperator- (const dynamic_bitset< Block, Allocator > &lhs, const dynamic_bitset< Block, Allocator > &rhs)
 Performs binary difference between bits of lhs and rhs.
 
template<typename _CharT , typename _Traits , typename Block , typename Allocator >
constexpr std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &os, const dynamic_bitset< Block, Allocator > &bitset)
 Insert a string representation of this sul::dynamic_bitset to a character stream.
 
template<typename _CharT , typename _Traits , typename Block , typename Allocator >
constexpr std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &is, dynamic_bitset< Block, Allocator > &bitset)
 Extract a sul::dynamic_bitset from a character stream using its string representation.
 
template<typename Block , typename Allocator >
constexpr void swap (dynamic_bitset< Block, Allocator > &bitset1, dynamic_bitset< Block, Allocator > &bitset2)
 Exchange the content of bitset1 and bitset2.
 

Detailed Description

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
class sul::dynamic_bitset< Block, Allocator >

Dynamic bitset.

Data structure used to store a vector of bits and apply binary operations to it. The bits are stored in an optimized way in an underling block type. It is highly inspired by std::bitset but with a run-time changeable size.

Preconditions are checked with assert but no exception will be thrown if one is violated (as with std::bitset).

Remarks
It is not a Container as it does not provide iterators because of the reference proxy class used to access the bits.
Template Parameters
BlockBlock type to use for storing the bits, must be an unsigned integral type
AllocatorAllocator type to use for memory management, must meet the standard requirements of Allocator
Since
1.0.0

Member Typedef Documentation

◆ allocator_type

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
typedef Allocator sul::dynamic_bitset< Block, Allocator >::allocator_type

Same type as Allocator.

Since
1.0.0

◆ block_type

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
typedef Block sul::dynamic_bitset< Block, Allocator >::block_type

Same type as Block.

Since
1.0.0

◆ const_reference

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
typedef bool sul::dynamic_bitset< Block, Allocator >::const_reference

Const reference to a sul::dynamic_bitset bit, type bool.

Since
1.0.0

◆ size_type

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
typedef size_t sul::dynamic_bitset< Block, Allocator >::size_type

Type used to represent the size of a sul::dynamic_bitset.

Since
1.0.0

Constructor & Destructor Documentation

◆ dynamic_bitset() [1/8]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( const dynamic_bitset< Block, Allocator > & other)
constexprdefault

Copy constructor.

Since
1.0.0

◆ dynamic_bitset() [2/8]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( dynamic_bitset< Block, Allocator > && other)
constexprdefaultnoexcept

Move constructor.

Since
1.0.0

◆ dynamic_bitset() [3/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( const allocator_type & allocator = allocator_type())
explicitconstexpr

Constructs an empty sul::dynamic_bitset.

A copy of allocator will be used for memory management.

Parameters
[in]allocatorAllocator to use for memory management
Complexity
Constant.
Since
1.0.0

◆ dynamic_bitset() [4/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( size_type nbits,
unsigned long long init_val = 0,
const allocator_type & allocator = allocator_type() )
explicitconstexpr

Constructs a sul::dynamic_bitset of nbits bits from an initial value.

The first bits are initialized with the bits from init_val, if nbits > std::numeric_limits<unsigned long long>::digits , all other bits are initialized to false. A copy of allocator will be used for memory management.

Parameters
[in]nbitsNumber of bits of the sul::dynamic_bitset
[in]init_valValue to initialize the sul::dynamic_bitset with
[in]allocatorAllocator to use for memory management
Complexity
Linear in nbits / bits_per_block.
Since
1.0.0

◆ dynamic_bitset() [5/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( std::initializer_list< block_type > init_vals,
const allocator_type & allocator = allocator_type() )
constexpr

Constructs a sul::dynamic_bitset using init_vals to initialize the first blocks.

The size of the newly created sul::dynamic_bitset is init_vals.size() * bits_per_block. A copy of allocator will be used for memory management.

Parameters
[in]init_valsValue of the sul::dynamic_bitset first blocks
[in]allocatorAllocator to use for memory management
Complexity
Linear in init_vals.size().
Since
1.0.0

◆ dynamic_bitset() [6/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( std::basic_string_view< _CharT, _Traits > str,
typename std::basic_string_view< _CharT, _Traits >::size_type pos = 0,
typename std::basic_string_view< _CharT, _Traits >::size_type n = std::basic_string_view<_CharT_Traits>::npos,
_CharT zero = _CharT('0'),
_CharT one = _CharT('1'),
const allocator_type & allocator = allocator_type() )
explicitconstexpr

Constructs a sul::dynamic_bitset from a string or a part of a string.

Construct the sul::dynamic_bitset using the characters from str in the range [pos, std::min(pos + n, str.size())[.

Parameters
[in]strString containing the part to use
[in]posStarting position of the string part to use in str
[in]nNumber of characters of str to use from the starting position
[in]zeroCharacter used to represent false bits in str
[in]oneCharacter used to represent true bits in str
[in]allocatorAllocator to use for memory management
Template Parameters
_CharTCharacter type of the string
_TraitsTraits class specifying the operations on the character type of the string
Precondition
Dynamic bitset.
Definition dynamic_bitset.hpp:172
constexpr size_type size() const noexcept
Give the number of bits of the sul::dynamic_bitset.
Definition dynamic_bitset.hpp:2817
Complexity
Linear in std::min(n, str.size() - pos).
Since
1.0.0

◆ dynamic_bitset() [7/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( const std::basic_string< _CharT, _Traits, _Alloc > & str,
typename std::basic_string< _CharT, _Traits, _Alloc >::size_type pos = 0,
typename std::basic_string< _CharT, _Traits, _Alloc >::size_type n = std::basic_string<_CharT_Traits_Alloc>::npos,
_CharT zero = _CharT('0'),
_CharT one = _CharT('1'),
const allocator_type & allocator = allocator_type() )
explicitconstexpr

Constructs a sul::dynamic_bitset from a string or a part of a string.

Construct the sul::dynamic_bitset using the characters from str in the range [pos, std::min(pos + n, str.size())[.

Parameters
[in]strString containing the part to use
[in]posStarting position of the string part to use in str
[in]nNumber of characters of str to use from the starting position
[in]zeroCharacter used to represent false bits in str
[in]oneCharacter used to represent true bits in str
[in]allocatorAllocator to use for memory management
Template Parameters
_CharTCharacter type of the string
_TraitsTraits class specifying the operations on the character type of the string
_AllocAllocator type used to allocate internal storage of the string
Precondition
Complexity
Linear in std::min(n, str.size() - pos).
Since
1.0.0

◆ dynamic_bitset() [8/8]

constexpr sul::dynamic_bitset< Block, Allocator >::dynamic_bitset ( const _CharT * str,
typename std::basic_string< _CharT >::size_type pos = 0,
typename std::basic_string< _CharT >::size_type n = std::basic_string<_CharT>::npos,
_CharT zero = _CharT('0'),
_CharT one = _CharT('1'),
const allocator_type & allocator = allocator_type() )
explicitconstexpr

Constructs a sul::dynamic_bitset from a string or a part of a string.

Construct the sul::dynamic_bitset using the characters from str in the range [pos, std::min(pos + n, _Traits::length(str))[.

Parameters
[in]strString containing the part to use
[in]posStarting position of the string part to use
[in]nNumber of characters to use from the starting position
[in]zeroCharacter used to represent false bits in the string
[in]oneCharacter used to represent 1 true bitsn the string
[in]allocatorAllocator to use for memory management
Template Parameters
_CharTCharacter type of the string
_TraitsTraits class specifying the operations on the character type of the string
Precondition
pos < _Traits::length(str)
Complexity
Linear in std::min(n, _Traits::length(str) - pos).
Since
1.0.0

◆ ~dynamic_bitset()

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
sul::dynamic_bitset< Block, Allocator >::~dynamic_bitset ( )
defaultnoexcept

Destructor.

Since
1.0.0

Member Function Documentation

◆ all()

constexpr bool sul::dynamic_bitset< Block, Allocator >::all ( ) const
constexpr

Checks if all bits are set to true.

Returns
true if all bits are set to true, otherwise false
Remarks
Return true if the sul::dynamic_bitset is empty, the logic is that you are checking if all bits are set to true, meaning none of them is set to false, and in an empty sul::dynamic_bitset no bits are set to false.
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ any()

constexpr bool sul::dynamic_bitset< Block, Allocator >::any ( ) const
constexpr

Checks if any bits are set to true.

Returns
true if any of the bits is set to true, otherwise false
Remarks
Return false if the sul::dynamic_bitset is empty, the logic is you are checking if there is at least one bit set to true and in an empty dynamic_bitset there is no bit set to true.
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ append() [1/3]

Append a block of bits block at the end of the sul::dynamic_bitset.

Increase the size of the sul::dynamic_bitset by bits_per_block.

Parameters
[in]blockBlock of bits to add
Complexity
Amortized constant.
Since
1.0.0

◆ append() [2/3]

Append blocks of bits from the range [first, last[ at the end of the dynamic_bitset.

Parameters
[in]firstFirst iterator of the range
[in]lastLast iterator of the range (after the last element to add)
Template Parameters
BlockInputIteratorType of the range iterators
Complexity
Linear in the size of the range. Additional complexity possible due to reallocation if capacity is less than size() + std::distance(first, last) * bits_per_block.
Since
1.0.0

◆ append() [3/3]

constexpr void sul::dynamic_bitset< Block, Allocator >::append ( std::initializer_list< block_type > blocks)
constexpr

Append blocks of bits from blocks at the end of the sul::dynamic_bitset.

Parameters
[in]blocksBlocks of bits to add
Complexity
Linear in the size of blocks. Additional complexity possible due to reallocation if capacity is less than size() + blocks.size() * bits_per_block.
Since
1.0.0

◆ capacity()

Give the number of bits that the sul::dynamic_bitset has currently allocated space for.

Returns
Capacity of the currently allocated storage.
Complexity
Constant.
Since
1.0.0

◆ clear()

Clears the sul::dynamic_bitset, resize it to 0.

Equivalent to:

this.resize(0);
constexpr void resize(size_type nbits, bool value=false)
Resize the sul::dynamic_bitset to contain nbits bits.
Definition dynamic_bitset.hpp:2266
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ count()

Count the number of bits set to true.

Return 0 if the sul::dynamic_bitset is empty.

Returns
The number of bits that are set to true
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ data() [1/2]

Return a pointer to the underlying array serving as blocks storage.

The pointer is such that range [data(); data() + num_blocks()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

Postcondition
The bits past the end of the sul::dynamic_bitset in the last block are guaranteed to be 0s, example:
// random bitset of size 11
std::minstd_rand rand(std::random_device{}());
std::bernoulli_distribution dist;
for(size_t i = 0; i < 11; ++i)
{
}
// the bitset use 2 blocks of 8 bits
// check that unused bits are set to 0
assert(*(bitset.data() + 1) >> 3 == 0);
constexpr void push_back(bool value)
Add a new bit with the value value at the end of the sul::dynamic_bitset.
Definition dynamic_bitset.hpp:2305
constexpr dynamic_bitset(const dynamic_bitset< Block, Allocator > &other)=default
Copy constructor.
constexpr block_type * data() noexcept
Return a pointer to the underlying array serving as blocks storage.
Definition dynamic_bitset.hpp:3092
Remarks
If the sul::dynamic_bitset is empty, this function may or may not return a null pointer.
Returns
A pointer to the underlying array serving as blocks storage
Complexity
Constant.
Since
1.2.0

◆ data() [2/2]

Return a pointer to the underlying array serving as blocks storage.

The pointer is such that range [data(); data() + num_blocks()) is always a valid range, even if the container is empty (data() is not dereferenceable in that case).

Postcondition
The bits past the end of the sul::dynamic_bitset in the last block are guaranteed to be 0s, example:
// random bitset of size 11
std::minstd_rand rand(std::random_device{}());
std::bernoulli_distribution dist;
for(size_t i = 0; i < 11; ++i)
{
}
// the bitset use 2 blocks of 8 bits
// check that unused bits are set to 0
assert(*(bitset.data() + 1) >> 3 == 0);
Remarks
If the sul::dynamic_bitset is empty, this function may or may not return a null pointer.
Returns
A pointer to the underlying array serving as blocks storage
Complexity
Constant.
Since
1.2.0

◆ empty()

constexpr bool sul::dynamic_bitset< Block, Allocator >::empty ( ) const
constexprnoexcept

Checks if the sul::dynamic_bitset is empty.

Equivalent to:

size() == 0;
Returns
true if the sul::dynamic_bitset is empty, false otherwise
Complexity
Constant.
Since
1.0.0

◆ find_first()

Find the position of the first bit set in the sul::dynamic_bitset starting from the least-significant bit.

Give the lowest index of the sul::dynamic_bitset with a bit set, or npos if no bits are set.

Returns
The position of the first bit set, or npos if no bits are set
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ find_next()

Find the position of the first bit set in the range [prev + 1, size()[ of the sul::dynamic_bitset starting from the position prev + 1.

Give the lowest index superior to prev of the sul::dynamic_bitset with a bit set, or npos if no bits are set after the index prev.
If prev + 1 >= size(), return npos.

Parameters
[in]prevPosition of the bit preceding the search range
Returns
The position of the first bit set after prev, or npos if no bits are set after prev
Complexity
Linear in size() - prev.
Since
1.0.0

◆ flip() [1/3]

Flip all the bits of the sul::dynamic_bitset.

Returns
A reference to the sul::dynamic_bitset *this
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ flip() [2/3]

Flip the bit at the position pos.

Parameters
[in]posPosition of the bit to reset
Returns
A reference to the sul::dynamic_bitset *this
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ flip() [3/3]

Flip the bits of the range [pos, pos + len[.

Parameters
[in]posPosition of the first bit of the range
[in]lenLength of the range
Returns
A reference to the sul::dynamic_bitset *this
Precondition
(pos < size()) && ((len == 0) || (pos + len - 1 < size()))
Complexity
Linear in len.
Since
1.0.0

◆ get_allocator()

Gets the associated allocator.

Returns
The associated allocator.
Complexity
Constant.
Since
1.0.0

◆ intersects()

constexpr bool sul::dynamic_bitset< Block, Allocator >::intersects ( const dynamic_bitset< Block, Allocator > & bitset) const
constexpr

Determines if this sul::dynamic_bitset and bitset intersect.

This sul::dynamic_bitset intersects with bitset if for at least one bit set in this sul::dynamic_bitset, the corresponding bit in bitset a is also set. In other words two bitsets intersect if they have at least one bit set in common.

Less efficient but equivalent way to get this result:

res = (this & bitset).any();
constexpr bool any() const
Checks if any bits are set to true.
Definition dynamic_bitset.hpp:2744
Parameters
[in]bitsetThe sul::dynamic_bitset for which to check if this sul::dynamic_bitset intersects
Returns
true if this sul::dynamic_bitset intersects with bitset, false otherwise
Precondition
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ is_proper_subset_of()

constexpr bool sul::dynamic_bitset< Block, Allocator >::is_proper_subset_of ( const dynamic_bitset< Block, Allocator > & bitset) const
constexpr

Determines if this sul::dynamic_bitset is a proper subset of bitset.

This sul::dynamic_bitset is a proper subset of bitset if, for every bit that is set in this sul::dynamic_bitset, the corresponding bit in bitset a is also set and if this sul::dynamic_bitset is different from bitset.

Less efficient but equivalent way to get this result:

res = ((this != bitset) && (this & ~bitset).none());
Parameters
[in]bitsetThe sul::dynamic_bitset for which to check if this sul::dynamic_bitset is a proper subset
Returns
true if this sul::dynamic_bitset is a proper subset of bitset, false otherwise
Remarks
The relation "is a proper subset of" is asymmetric (A being a proper subset of B imply that B is not a proper subset of A).
Precondition
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ is_subset_of()

constexpr bool sul::dynamic_bitset< Block, Allocator >::is_subset_of ( const dynamic_bitset< Block, Allocator > & bitset) const
constexpr

Determines if this sul::dynamic_bitset is a subset of bitset.

This sul::dynamic_bitset is a subset of bitset if, for every bit that is set in this sul::dynamic_bitset, the corresponding bit in bitset a is also set.

Less efficient but equivalent way to get this result:

res = (this & ~bitset).none();
constexpr bool none() const
Checks if none of the bits are set to true.
Definition dynamic_bitset.hpp:2757
Parameters
[in]bitsetThe sul::dynamic_bitset for which to check if this sul::dynamic_bitset is a subset
Returns
true if this sul::dynamic_bitset is a subset of bitset, false otherwise
Remarks
The relation "is a subset of" is not symmetric (A being a subset of B doesn't imply that B is a subset of A) but is antisymmetric (if A is a subset of B and B is a subset of A, then A == B).
Precondition
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ iterate_bits_on()

template<typename Function , typename... Parameters>
constexpr void sul::dynamic_bitset< Block, Allocator >::iterate_bits_on ( Function && function,
Parameters &&... parameters ) const
constexpr

Iterate on the sul::dynamic_bitset and call function with the position of the bits on.

For each set bit, function is called as follow:

std::invoke(std::forward<Function>(function), bit_pos, std::forward<Parameters>(parameters)...))

where bit_pos is the position of the current bit on. Thus function should take a size_t for the current set bit position as first argument, also parameters can be used to pass additional arguments to function when it is called by this method.

function can return nothing or a bool, if it return a bool, the return value indicate if the iteration should continue, true to continue the iteration, false to stop, this make it easy to do an early exit.

Parameters
functionFunction to call on all bits on, take the current bit position as first argument and parameters as next arguments
parametersExtra parameters for function
Template Parameters
FunctionType of function, must take a size_t as first argument and Parameters as next arguments
ParametersType of parameters
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ none()

constexpr bool sul::dynamic_bitset< Block, Allocator >::none ( ) const
constexpr

Checks if none of the bits are set to true.

Returns
true if none of the bits is set to true, otherwise false
Remarks
Return true if the sul::dynamic_bitset is empty, the logic is that you are checking if there is no bit set to true and in an empty sul::dynamic_bitset there is no bit that can be set to true.
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ num_blocks()

Give the number of blocks used by the sul::dynamic_bitset.

Returns
The number of blocks used by the sul::dynamic_bitset
Complexity
Constant.
Since
1.0.0

◆ operator&=()

Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsRight hand side sul::dynamic_bitset of the operator
Returns
A reference to the sul::dynamic_bitset *this
Precondition
size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator-=()

Sets the bits to the result of the binary difference between the bits of *this and rhs.

Less efficient but equivalent way to get this result:

this &= ~rhs;
Parameters
[in]rhsRight hand side sul::dynamic_bitset of the operator
Returns
A reference to the sul::dynamic_bitset *this
Precondition
size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator<<()

Performs binary shift right of shift bits.

Zeroes are shifted in. Does nothing if shift == 0.
Equivalent to:

Parameters
[in]shiftNumber of positions to shift the bits
Returns
A new sul::dynamic_bitset containing the shifted bits
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator<<=()

Performs binary shift left of shift bits.

Zeroes are shifted in, does nothing if shift == 0.

Parameters
[in]shiftNumber of positions to shift the bits
Returns
A reference to the sul::dynamic_bitset *this
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator=() [1/2]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr dynamic_bitset< Block, Allocator > & sul::dynamic_bitset< Block, Allocator >::operator= ( const dynamic_bitset< Block, Allocator > & other)
constexprdefault

Copy assignment operator.

Since
1.0.0

◆ operator=() [2/2]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr dynamic_bitset< Block, Allocator > & sul::dynamic_bitset< Block, Allocator >::operator= ( dynamic_bitset< Block, Allocator > && other)
constexprdefaultnoexcept

Move assignment operator.

Since
1.0.0

◆ operator>>()

Performs binary shift left of shift bits.

Zeroes are shifted in. Does nothing if shift == 0.
Equivalent to:

Parameters
[in]shiftNumber of positions to shift the bits
Returns
A new sul::dynamic_bitset containing the shifted bits
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator>>=()

Performs binary shift right of shift bits.

Zeroes are shifted in, does nothing if shift == 0.

Parameters
[in]shiftNumber of positions to shift the bits
Returns
A reference to the sul::dynamic_bitset *this
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator[]() [1/2]

Accesses the bit at position pos.

Parameters
[in]posPosition of the bit to access
Returns
A reference object which allows writing to the requested bit
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ operator[]() [2/2]

Accesses the bit at position pos.

Parameters
[in]posPosition of the bit to access
Returns
The value of the requested bit
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ operator^=()

Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsRight hand side sul::dynamic_bitset of the operator
Returns
A reference to the sul::dynamic_bitset *this
Precondition
size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator|=()

Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsRight hand side sul::dynamic_bitset of the operator
Returns
A reference to the sul::dynamic_bitset *this
Precondition
size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator~()

Performs a unary NOT on all bits.

Equivalent to:

constexpr dynamic_bitset< Block, Allocator > & flip(size_type pos, size_type len)
Flip the bits of the range [pos, pos + len[.
Definition dynamic_bitset.hpp:2627
Returns
A copy of *this with all bits flipped
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ pop_back()

constexpr void sul::dynamic_bitset< Block, Allocator >::pop_back ( )
constexpr

Remove the last bit of the sul::dynamic_bitset.

Decrease the size of the sul::dynamic_bitset by one, does nothing if the dynamic_bitset is empty.

Complexity
Constant.
Since
1.0.0

◆ push_back()

constexpr void sul::dynamic_bitset< Block, Allocator >::push_back ( bool value)
constexpr

Add a new bit with the value value at the end of the sul::dynamic_bitset.

Increase the size of the bitset by one, the added bit becomes the most-significant bit.

Parameters
[in]valueValue of the bit to add
Complexity
Amortized constant.
Since
1.0.0

◆ reserve()

constexpr void sul::dynamic_bitset< Block, Allocator >::reserve ( size_type num_bits)
constexpr

Increase the capacity of the sul::dynamic_bitset to a value that's greater or equal to num_bits.

If num_bits is greater than the current capacity, new storage is allocated and all reference on bits of the sul::dynamic_bitset are invalidated, otherwise the method does nothing.

Parameters
[in]num_bitsNew capacity of the sul::dynamic_bitset
Complexity
At most linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ reset() [1/3]

Reset all the bits of the sul::dynamic_bitset to false.

Returns
A reference to the sul::dynamic_bitset *this
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ reset() [2/3]

Reset the bit at the position pos to false.

Parameters
[in]posPosition of the bit to reset
Returns
A reference to the sul::dynamic_bitset *this
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ reset() [3/3]

Reset the bits of the range [pos, pos + len[ to false.

Parameters
[in]posPosition of the first bit of the range
[in]lenLength of the range
Returns
A reference to the sul::dynamic_bitset *this
Precondition
(pos < size()) && ((len == 0) || (pos + len - 1 < size()))
Complexity
Linear in len.
Since
1.0.0

◆ resize()

constexpr void sul::dynamic_bitset< Block, Allocator >::resize ( size_type nbits,
bool value = false )
constexpr

Resize the sul::dynamic_bitset to contain nbits bits.

Bits keep the value they had before the resize and, if nbits is greater than the current size, new bit are initialized to value.

Parameters
[in]nbitsNew size of the sul::dynamic_bitset
[in]valueValue of the new bits
Complexity
Linear in the difference between the current size and nbits. Additional complexity possible due to reallocation if capacity is less than nbits.
Since
1.0.0

◆ set() [1/3]

Set all the bits of the sul::dynamic_bitset to true.

Returns
A reference to the sul::dynamic_bitset *this
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ set() [2/3]

Set the bit at the position pos to true or value value.

Parameters
[in]posPosition of the bit to set
[in]valueValue to set the bit to
Returns
A reference to the sul::dynamic_bitset *this
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ set() [3/3]

Set the bits of the range [pos, pos + len[ to value value.

Does nothing if len == 0.

Parameters
[in]posPosition of the first bit of the range
[in]lenLength of the range
[in]valueValue to set the bits to
Returns
A reference to the sul::dynamic_bitset *this
Precondition
(pos < size()) && ((len == 0) || (pos + len - 1 < size()))
Complexity
Linear in len.
Since
1.0.0

◆ shrink_to_fit()

constexpr void sul::dynamic_bitset< Block, Allocator >::shrink_to_fit ( )
constexpr

Requests the removal of unused capacity.

It is a non-binding request to reduce the capacity to the size. It depends on the implementation of std::vector whether the request is fulfilled.
If reallocation occurs, all reference on bits of the sul::dynamic_bitset are invalidated.

Complexity
At most linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ size()

Give the number of bits of the sul::dynamic_bitset.

Returns
The number of bits of the sul::dynamic_bitset
Complexity
Constant.
Since
1.0.0

◆ swap()

Exchanges the bits of this sul::dynamic_bitset with those of other.

All reference on bits of the sul::dynamic_bitset are invalidated.

Parameters
othersul::dynamic_bitset to exchange bits with
Complexity
Constant.
Since
1.0.0

◆ test()

constexpr bool sul::dynamic_bitset< Block, Allocator >::test ( size_type pos) const
constexpr

Test the value of the bit at position pos.

Parameters
[in]posPosition of the bit to test
Returns
The tested bit value
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ test_set()

constexpr bool sul::dynamic_bitset< Block, Allocator >::test_set ( size_type pos,
bool value = true )
constexpr

Test the value of the bit at position pos and set it to true or value value.

Parameters
[in]posPosition of the bit to test and set
[in]valueValue to set the bit to
Returns
The tested bit value
Precondition
pos < size()
Complexity
Constant.
Since
1.0.0

◆ to_string()

constexpr std::basic_string< _CharT, _Traits, _Alloc > sul::dynamic_bitset< Block, Allocator >::to_string ( _CharT zero = _CharT('0'),
_CharT one = _CharT('1') ) const
constexpr

Generate a string representation of the sul::dynamic_bitset.

Uses zero to represent bits with value of false and one to represent bits with value of true. The resulting string contains size() characters with the first character corresponds to the last (size() - 1th) bit and the last character corresponding to the first bit.

Parameters
[in]zeroCharacter to use to represent false
[in]oneCharacter to use to represent true
Template Parameters
_CharTCharacter type of the string
_TraitsTraits class specifying the operations on the character type of the string
_AllocAllocator type used to allocate internal storage of the string
Returns
The string representing the sul::dynamic_bitset content
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ to_ullong()

constexpr unsigned long long sul::dynamic_bitset< Block, Allocator >::to_ullong ( ) const
constexpr

Converts the contents of the bitset to an unsigned long long integer.

The first bit of the bitset corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.

Returns
The numeric value corresponding to the bitset contents.
Exceptions
std::overflow_errorif the value is too large to be represented in an unsigned long long
Complexity
Constant.
Since
1.3.0

◆ to_ulong()

constexpr unsigned long sul::dynamic_bitset< Block, Allocator >::to_ulong ( ) const
constexpr

Converts the contents of the bitset to an unsigned long integer.

The first bit of the bitset corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.

Returns
The numeric value corresponding to the bitset contents.
Exceptions
std::overflow_errorif the value is too large to be represented in an unsigned long
Complexity
Constant.
Since
1.3.0

Friends And Related Symbol Documentation

◆ operator!=()

Test if two sul::dynamic_bitset content are different.

Defined as:

return !(lhs == rhs);

see sul::dynamic_bitset::operator==() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
true if they does not contain the same bits, false otherwise
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator&()

Performs binary AND on corresponding pairs of bits of lhs and rhs.

Defined as:

see sul::dynamic_bitset::operator&=() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
A sul::dynamic_bitset with each bit being the result of a binary AND between the corresponding pair of bits of lhs and rhs
Precondition
lhs.size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator-()

Performs binary difference between bits of lhs and rhs.

Defined as:

see sul::dynamic_bitset::operator-=() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
A sul::dynamic_bitset with each bit being the result of the binary difference between the corresponding bits of lhs and rhs
Precondition
lhs.size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator<

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr bool operator< ( const dynamic_bitset< Block_, Allocator_ > & lhs,
const dynamic_bitset< Block_, Allocator_ > & rhs )
friend

Test if lhs is "less than" rhs. The comparison of the two dynamic_bitset is first on numbers their content represent and then on their size.

The size comparison is necessary for the comparison operators to keep their properties. For example without the size comparison the "<=" operator (defined for "A <= B" by "!(B < A)") would no longer be antisymmetric (if A <= B and B <= A, then A == B) because operator==() compare the sul::dynamic_bitset as a container and not a number. For example with bitsets A(0011) and B(011), without the size comparison B < A would be false, A <= B would be true, B <= A would be true, but A == B would be false, breaking the antisymmetric property of the operator. Thus, to respect the properties of the operators, the size is used as a secondary criteria for the comparison of sul::dynamic_bitset which content represent the same number. Therefore, for the previous example with bitsets A(0011) and B(011), B < A is true, A <= B is false, B <= A is true and A == B is false.

If comparing bitsets A and B with the content of A representing the number a, and the content of B representing the number b, this operator would work as follow:

if(a == b)
{
return A.size() < B.size();
}
else
{
return a < b;
}
Remarks
The empty sul::dynamic_bitset is the "lowest" of all bitset and for 0-only bitsets comparison, the shortest is the lowest.
Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
Block_Block type used by lhs and rhs for storing the bits
Allocator_Allocator type used by lhs and rhs for memory management
Returns
true if lhs is "less than" rhs
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator<<()

constexpr std::basic_ostream< _CharT, _Traits > & operator<< ( std::basic_ostream< _CharT, _Traits > & os,
const dynamic_bitset< Block, Allocator > & bitset )
related

Insert a string representation of this sul::dynamic_bitset to a character stream.

The string representation written is the same as if generated with sul::dynamic_bitset::to_string() with default parameter, using '1' for true bits and '0' for false bits.

Parameters
osCharacter stream to write to
[in]bitsetsul::dynamic_bitset to write
Template Parameters
_CharTCharacter type of the character stream
_TraitsTraits class specifying the operations on the character type of the character stream
BlockBlock type used by bitset for storing the bits
AllocatorAllocator type used by bitset for memory management
Returns
os
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator<=()

Test if lhs is "less than or equal to" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.

Defined as:

return !(rhs < lhs);

see sul::dynamic_bitset::operator<() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
true if lhs is "less than or equal to" rhs
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator==

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr bool operator== ( const dynamic_bitset< Block_, Allocator_ > & lhs,
const dynamic_bitset< Block_, Allocator_ > & rhs )
friend

Test if two sul::dynamic_bitset have the same content.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
Block_Block type used by lhs and rhs for storing the bits
Allocator_Allocator type used by lhs and rhs for memory management
Returns
true if they contain the same bits, false otherwise
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator>()

Test if lhs is "greater than" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.

Defined as:

return rhs < lhs;

see sul::dynamic_bitset::operator<() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
true if lhs is "greater than" rhs
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator>=()

Test if lhs is "greater than or equal to" rhs. The comparison of the two sul::dynamic_bitset is first on numbers their content represent and then on their size.

Defined as:

return !(lhs < rhs);

see sul::dynamic_bitset::operator<() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
true if lhs is "greater than or equal to" rhs
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator>>()

constexpr std::basic_istream< _CharT, _Traits > & operator>> ( std::basic_istream< _CharT, _Traits > & is,
dynamic_bitset< Block, Allocator > & bitset )
related

Extract a sul::dynamic_bitset from a character stream using its string representation.

The string representation expected is the same as if generated with sul::dynamic_bitset::to_string() with default parameter, using '1' for true bits and '0' for false bits. On success the content of bitset is cleared before writing to it. The extraction starts by skipping leading whitespace then take the characters one by one and stop if is.good() return false or the next character is neither _CharT('0') nor _CharT('1').

Parameters
isCharacter stream to read from
bitsetsul::dynamic_bitset to write to
Template Parameters
_CharTCharacter type of the character stream
_TraitsTraits class specifying the operations on the character type of the character stream
BlockBlock type used by bitset for storing the bits
AllocatorAllocator type used by bitset for memory management
Returns
is
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator^()

Performs binary XOR on corresponding pairs of bits of lhs and rhs.

Defined as:

see sul::dynamic_bitset::operator^=() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
A sul::dynamic_bitset with each bit being the result of a binary XOR between the corresponding pair of bits of lhs and rhs
Precondition
lhs.size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ operator|()

Performs binary OR on corresponding pairs of bits of lhs and rhs.

Defined as:

see sul::dynamic_bitset::operator|=() for more informations.

Parameters
[in]lhsThe left hand side sul::dynamic_bitset of the operator
[in]rhsThe right hand side sul::dynamic_bitset of the operator
Template Parameters
BlockBlock type used by lhs and rhs for storing the bits
AllocatorAllocator type used by lhs and rhs for memory management
Returns
A sul::dynamic_bitset with each bit being the result of a binary OR between the corresponding pair of bits of lhs and rhs
Precondition
lhs.size() == rhs.size()
Complexity
Linear in the size of the sul::dynamic_bitset.
Since
1.0.0

◆ swap()

constexpr void swap ( dynamic_bitset< Block, Allocator > & bitset1,
dynamic_bitset< Block, Allocator > & bitset2 )
related

Exchange the content of bitset1 and bitset2.

Defined as:

constexpr void swap(dynamic_bitset< Block, Allocator > &other)
Exchanges the bits of this sul::dynamic_bitset with those of other.
Definition dynamic_bitset.hpp:2955

see sul::dynamic_bitset::swap() for more informations.

Parameters
bitset1sul::dynamic_bitset to be swapped
bitset2sul::dynamic_bitset to be swapped
Template Parameters
BlockBlock type used by bitset for storing the bits
AllocatorAllocator type used by bitset for memory management
Complexity
Constant.
Since
1.0.0

Member Data Documentation

◆ bits_per_block

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr size_type sul::dynamic_bitset< Block, Allocator >::bits_per_block = std::numeric_limits<block_type>::digits
staticconstexpr

Number of bits that can be stored in a block.

Since
1.0.0

◆ npos

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
constexpr size_type sul::dynamic_bitset< Block, Allocator >::npos = std::numeric_limits<size_type>::max()
staticconstexpr

Maximum value of size_type, returned for invalid positions.

Since
1.0.0

The documentation for this class was generated from the following file: