dynamic_bitset 1.3.2
Simple Useful Libraries: C++17/20 header-only dynamic bitset
|
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, Allocator > | operator<< (size_type shift) const |
Performs binary shift right of shift bits. | |
constexpr dynamic_bitset< Block, Allocator > | operator>> (size_type shift) const |
Performs binary shift left of shift bits. | |
constexpr dynamic_bitset< Block, Allocator > | operator~ () 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) noexcept(noexcept(std::swap(m_blocks, other.m_blocks))) |
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, _Alloc > | to_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_type * | data () noexcept |
Return a pointer to the underlying array serving as blocks storage. | |
constexpr const block_type * | data () 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, Allocator > | operator& (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, Allocator > | operator| (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, Allocator > | operator^ (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, Allocator > | operator- (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) noexcept(noexcept(bitset1.swap(bitset2))) |
Exchange the content of bitset1 and bitset2 . | |
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).
Block | Block type to use for storing the bits, must be an unsigned integral type |
Allocator | Allocator type to use for memory management, must meet the standard requirements of Allocator |
Allocator sul::dynamic_bitset< Block, Allocator >::allocator_type |
Same type as Allocator
.
Block sul::dynamic_bitset< Block, Allocator >::block_type |
Same type as Block
.
bool sul::dynamic_bitset< Block, Allocator >::const_reference |
Const reference to a sul::dynamic_bitset bit, type bool.
size_t sul::dynamic_bitset< Block, Allocator >::size_type |
Type used to represent the size of a sul::dynamic_bitset.
|
constexprdefault |
Copy constructor.
|
constexprdefaultnoexcept |
Move constructor.
|
explicitconstexpr |
Constructs an empty sul::dynamic_bitset.
A copy of allocator
will be used for memory management.
[in] | allocator | Allocator to use for memory management |
|
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.
[in] | nbits | Number of bits of the sul::dynamic_bitset |
[in] | init_val | Value to initialize the sul::dynamic_bitset with |
[in] | allocator | Allocator to use for memory management |
nbits
/ bits_per_block.
|
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.
[in] | init_vals | Value of the sul::dynamic_bitset first blocks |
[in] | allocator | Allocator to use for memory management |
init_vals.size()
.
|
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()
)[.
[in] | str | String containing the part to use |
[in] | pos | Starting position of the string part to use in str |
[in] | n | Number of characters of str to use from the starting position |
[in] | zero | Character used to represent false bits in str |
[in] | one | Character used to represent true bits in str |
[in] | allocator | Allocator to use for memory management |
_CharT | Character type of the string |
_Traits | Traits class specifying the operations on the character type of the string |
n
, str.size()
- pos
).
|
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()
)[.
[in] | str | String containing the part to use |
[in] | pos | Starting position of the string part to use in str |
[in] | n | Number of characters of str to use from the starting position |
[in] | zero | Character used to represent false bits in str |
[in] | one | Character used to represent true bits in str |
[in] | allocator | Allocator to use for memory management |
_CharT | Character type of the string |
_Traits | Traits class specifying the operations on the character type of the string |
_Alloc | Allocator type used to allocate internal storage of the string |
n
, str.size()
- pos
).
|
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
))[.
[in] | str | String containing the part to use |
[in] | pos | Starting position of the string part to use |
[in] | n | Number of characters to use from the starting position |
[in] | zero | Character used to represent false bits in the string |
[in] | one | Character used to represent 1 true bitsn the string |
[in] | allocator | Allocator to use for memory management |
_CharT | Character type of the string |
_Traits | Traits class specifying the operations on the character type of the string |
n
, _Traits::length
(str
) - pos
).
|
defaultnoexcept |
Destructor.
|
nodiscardconstexpr |
Checks if all bits are set to true.
|
nodiscardconstexpr |
Checks if any bits are set to true.
|
constexpr |
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.
[in] | block | Block of bits to add |
|
constexpr |
Append blocks of bits from the range [first
, last
[ at the end of the dynamic_bitset.
[in] | first | First iterator of the range |
[in] | last | Last iterator of the range (after the last element to add) |
BlockInputIterator | Type of the range iterators |
first
, last
) * bits_per_block.
|
constexpr |
Append blocks of bits from blocks
at the end of the sul::dynamic_bitset.
[in] | blocks | Blocks of bits to add |
blocks
. Additional complexity possible due to reallocation if capacity is less than size() + blocks.size()
* bits_per_block.
|
nodiscardconstexprnoexcept |
Give the number of bits that the sul::dynamic_bitset has currently allocated space for.
|
constexpr |
Clears the sul::dynamic_bitset, resize it to 0.
Equivalent to:
|
nodiscardconstexprnoexcept |
Count the number of bits set to true.
Return 0 if the sul::dynamic_bitset is empty.
|
nodiscardconstexprnoexcept |
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).
|
nodiscardconstexprnoexcept |
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).
|
nodiscardconstexprnoexcept |
Checks if the sul::dynamic_bitset is empty.
Equivalent to:
|
nodiscardconstexpr |
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.
|
nodiscardconstexpr |
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.
[in] | prev | Position of the bit preceding the search range |
prev
, or npos if no bits are set after prev
prev
.
|
constexpr |
Flip all the bits of the sul::dynamic_bitset.
|
constexpr |
Flip the bit at the position pos
.
[in] | pos | Position of the bit to reset |
|
constexpr |
Flip the bits of the range [pos
, pos
+ len
[.
[in] | pos | Position of the first bit of the range |
[in] | len | Length of the range |
len
.
|
nodiscardconstexpr |
Gets the associated allocator.
|
nodiscardconstexpr |
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:
[in] | bitset | The sul::dynamic_bitset for which to check if this sul::dynamic_bitset intersects |
bitset
, false otherwise
|
nodiscardconstexpr |
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:
[in] | bitset | The sul::dynamic_bitset for which to check if this sul::dynamic_bitset is a proper subset |
bitset
, false otherwise
|
nodiscardconstexpr |
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:
[in] | bitset | The sul::dynamic_bitset for which to check if this sul::dynamic_bitset is a subset |
bitset
, false otherwise
|
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:
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.
function | Function to call on all bits on, take the current bit position as first argument and parameters as next arguments |
parameters | Extra parameters for function |
Function | Type of function , must take a size_t as first argument and Parameters as next arguments |
Parameters | Type of parameters |
|
nodiscardconstexpr |
Checks if none of the bits are set to true.
|
nodiscardconstexprnoexcept |
Give the number of blocks used by the sul::dynamic_bitset.
|
constexpr |
Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs
.
[in] | rhs | Right hand side sul::dynamic_bitset of the operator |
|
constexpr |
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:
[in] | rhs | Right hand side sul::dynamic_bitset of the operator |
|
nodiscardconstexpr |
Performs binary shift right of shift
bits.
Zeroes are shifted in. Does nothing if shift
== 0.
Equivalent to:
[in] | shift | Number of positions to shift the bits |
|
constexpr |
Performs binary shift left of shift
bits.
Zeroes are shifted in, does nothing if shift
== 0.
[in] | shift | Number of positions to shift the bits |
|
constexprdefault |
Copy assignment operator.
|
constexprdefaultnoexcept |
Move assignment operator.
|
nodiscardconstexpr |
Performs binary shift left of shift
bits.
Zeroes are shifted in. Does nothing if shift
== 0.
Equivalent to:
[in] | shift | Number of positions to shift the bits |
|
constexpr |
Performs binary shift right of shift
bits.
Zeroes are shifted in, does nothing if shift
== 0.
[in] | shift | Number of positions to shift the bits |
|
nodiscardconstexpr |
|
nodiscardconstexpr |
Accesses the bit at position pos
.
[in] | pos | Position of the bit to access |
|
constexpr |
Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs
.
[in] | rhs | Right hand side sul::dynamic_bitset of the operator |
|
constexpr |
Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs
.
[in] | rhs | Right hand side sul::dynamic_bitset of the operator |
|
nodiscardconstexpr |
Performs a unary NOT on all bits.
Equivalent to:
|
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.
|
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.
[in] | value | Value of the bit to add |
|
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.
[in] | num_bits | New capacity of the sul::dynamic_bitset |
|
constexpr |
Reset all the bits of the sul::dynamic_bitset to false.
|
constexpr |
Reset the bit at the position pos
to false.
[in] | pos | Position of the bit to reset |
|
constexpr |
Reset the bits of the range [pos
, pos
+ len
[ to false.
[in] | pos | Position of the first bit of the range |
[in] | len | Length of the range |
len
.
|
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
.
[in] | nbits | New size of the sul::dynamic_bitset |
[in] | value | Value of the new bits |
nbits
. Additional complexity possible due to reallocation if capacity is less than nbits
.
|
constexpr |
Set all the bits of the sul::dynamic_bitset to true.
|
constexpr |
Set the bit at the position pos
to true or value value
.
[in] | pos | Position of the bit to set |
[in] | value | Value to set the bit to |
|
constexpr |
Set the bits of the range [pos
, pos
+ len
[ to value value
.
Does nothing if len
== 0.
[in] | pos | Position of the first bit of the range |
[in] | len | Length of the range |
[in] | value | Value to set the bits to |
len
.
|
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.
|
nodiscardconstexprnoexcept |
Give the number of bits of the sul::dynamic_bitset.
|
constexprnoexcept |
Exchanges the bits of this sul::dynamic_bitset with those of other
.
All reference on bits of the sul::dynamic_bitset are invalidated.
other | sul::dynamic_bitset to exchange bits with |
|
nodiscardconstexpr |
Test the value of the bit at position pos
.
[in] | pos | Position of the bit to test |
|
nodiscardconstexpr |
Test the value of the bit at position pos
and set it to true or value value
.
[in] | pos | Position of the bit to test and set |
[in] | value | Value to set the bit to |
|
nodiscardconstexpr |
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.
[in] | zero | Character to use to represent false |
[in] | one | Character to use to represent true |
_CharT | Character type of the string |
_Traits | Traits class specifying the operations on the character type of the string |
_Alloc | Allocator type used to allocate internal storage of the string |
|
nodiscardconstexpr |
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.
std::overflow_error | if the value is too large to be represented in an unsigned long long |
|
nodiscardconstexpr |
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.
std::overflow_error | if the value is too large to be represented in an unsigned long |
|
related |
Test if two sul::dynamic_bitset content are different.
Defined as:
see sul::dynamic_bitset::operator==() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
|
related |
Performs binary AND on corresponding pairs of bits of lhs
and rhs
.
Defined as:
see sul::dynamic_bitset::operator&=() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
and rhs
|
related |
Performs binary difference between bits of lhs
and rhs
.
Defined as:
see sul::dynamic_bitset::operator-=() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
and 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:
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block_ | Block type used by lhs and rhs for storing the bits |
Allocator_ | Allocator type used by lhs and rhs for memory management |
lhs
is "less than" rhs
|
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.
os | Character stream to write to | |
[in] | bitset | sul::dynamic_bitset to write |
_CharT | Character type of the character stream |
_Traits | Traits class specifying the operations on the character type of the character stream |
Block | Block type used by bitset for storing the bits |
Allocator | Allocator type used by bitset for memory management |
os
|
related |
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:
see sul::dynamic_bitset::operator<() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
is "less than or equal to" rhs
|
friend |
Test if two sul::dynamic_bitset have the same content.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block_ | Block type used by lhs and rhs for storing the bits |
Allocator_ | Allocator type used by lhs and rhs for memory management |
|
related |
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:
see sul::dynamic_bitset::operator<() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
is "greater than" rhs
|
related |
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:
see sul::dynamic_bitset::operator<() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
is "greater than or equal to" rhs
|
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').
is | Character stream to read from |
bitset | sul::dynamic_bitset to write to |
_CharT | Character type of the character stream |
_Traits | Traits class specifying the operations on the character type of the character stream |
Block | Block type used by bitset for storing the bits |
Allocator | Allocator type used by bitset for memory management |
is
|
related |
Performs binary XOR on corresponding pairs of bits of lhs
and rhs
.
Defined as:
see sul::dynamic_bitset::operator^=() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
and rhs
|
related |
Performs binary OR on corresponding pairs of bits of lhs
and rhs
.
Defined as:
see sul::dynamic_bitset::operator|=() for more informations.
[in] | lhs | The left hand side sul::dynamic_bitset of the operator |
[in] | rhs | The right hand side sul::dynamic_bitset of the operator |
Block | Block type used by lhs and rhs for storing the bits |
Allocator | Allocator type used by lhs and rhs for memory management |
lhs
and rhs
|
related |
Exchange the content of bitset1
and bitset2
.
Defined as:
see sul::dynamic_bitset::swap() for more informations.
bitset1 | sul::dynamic_bitset to be swapped |
bitset2 | sul::dynamic_bitset to be swapped |
Block | Block type used by bitset for storing the bits |
Allocator | Allocator type used by bitset for memory management |
|
staticconstexpr |
Number of bits that can be stored in a block.
|
staticconstexpr |
Maximum value of size_type, returned for invalid positions.