boost::dynamic_bitset
The dynamic_bitset template represents a set of bits.
Synopsis
Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>
template<
typename Block = unsigned long,
typename AllocatorOrContainer = std::allocator<Block>>
class dynamic_bitset;
Template parameters
-
BlockThe integer type in which the bits are stored. Defaults tounsigned long. -
AllocatorOrContainerEither an allocator (to use for all internal memory management) or a container of Block's. Defaults tostd::allocator< Block >.
Concepts modeled
DefaultConstructible, CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable, EqualityComparable, LessThanComparable.
Type requirements
Block is a cv‐unqualified unsigned integer type other than bool.
AllocatorOrContainer is taken as a container if it has a nested value_type which is Block, a member resize() taking a size, and an operator[] taking an index; otherwise, it is taken as an allocator. A type which is neither (for instance, std::list< Block >, which has no operator[]) is rejected by a static_assert.
If AllocatorOrContainer is an allocator, it satisfies the standard requirements for an allocator of Block, and the bits are stored in a std::vector< Block, AllocatorOrContainer >.
If AllocatorOrContainer is a container (for instance, a boost::container::small_vector< Block, N > or a std::deque< Block >), the bits are stored in an object of that type, which must provide, with the same semantics as for std::vector: the nested types allocator_type, iterator and const_iterator, the latter two being at least LegacyBidirectionalIterators; default, copy and move construction, construction from an allocator_type, and copy and move assignment; the members begin(), end(), cbegin(), cend(), size(), max_size(), empty(), get_allocator(), operator[], back(), resize( n ), resize( n, value ), push_back(), pop_back(), insert( pos, first, last ) and clear(); operator==; and swapping by an unqualified call to swap(), with std::swap() visible. In addition, capacity(), reserve(), shrink_to_fit() and the allocator‐extended copy and move constructors use further members of the container (capacity(), reserve(), a member swap(), and allocator‐extended copy and move constructors), as documented for each of them, and can't be used with a container which lacks them (for instance, std::deque has no capacity(), so the first three can't be used with it). Many members access the blocks through operator[], so they are efficient only if it takes constant time.
None of the following may throw an exception: the members begin(), end(), cbegin(), cend(), size(), max_size(), capacity(), get_allocator(), back() and clear() of the container, its operator==, its operator[] with a valid index, and the operations of its iterators on valid iterators. (The noexcept members of dynamic_bitset rely on that.)
Types
Name |
Description |
A proxy class to simulate lvalues of bit type. |
|
Optional zero‐copy serialization support. |
Type Aliases
Name |
Description |
The allocator used for all memory allocations: |
|
The same type as |
|
A read‐only iterator into the bitset. |
|
The type bool. |
|
A reverse read‐only iterator into the bitset. |
|
A signed integral type that can represent the difference between any two iterators into the same bitset. The same type as |
|
A read/write iterator into the bitset. |
|
A reverse read/write reverse iterator into the bitset. |
|
An unsigned integral type that can represent the size of the bitset. See |
|
The type bool, i.e. the type of the value of a bit. |
Member Functions
Name |
Description |
|
Constructors |
|
Destructor. |
Assignment operators |
|
Checks whether all bits in |
|
Checks whether any bits in |
|
|
|
A checked version of |
|
|
|
Returns the total number of elements that |
|
Returns a read‐only iterator that refers to the least significant bit in the bitset. |
|
Returns a read‐only iterator that refers to one past the most significant bit in the bitset. |
|
Clears the bitset, i.e. makes its size zero. |
|
Returns the number of bits in this bitset that are set. |
|
Returns a read‐only reverse iterator that refers to the most significant bit in the bitset. |
|
Returns a read‐only reverse iterator that refers to one before the least significant bit in the bitset. |
|
Checks whether this bitset has size zero. |
|
|
|
Returns the bitset made of the bits of |
|
Finds the first set bit in |
|
Finds the first unset bit in |
|
Finds the first bit set in |
|
Finds the first unset bit in |
|
|
|
Returns a copy of the allocator that this bitset currently uses. |
|
Checks whether |
|
Checks whether |
|
Checks whether |
|
Returns the maximum size of a bitset of this type. |
|
Checks whether this bitset has no set bit. |
|
Returns the number of blocks in this bitset. |
|
Bitwise‐ANDs all the bits in this bitset with the bits in |
|
Computes the set difference of this bitset and the |
|
Shifts the bits in this bitset to the left by |
|
Returns a shifted copy of |
|
Shifts the bits in this bitset to the right by |
|
Subscript operators |
|
Bitwise‐XORs all the bits in this bitset with the bits in |
|
Bitwise‐ORs all the bits in this bitset with the bits in |
|
Returns a copy of |
|
Decreases the size of the bitset by one, removing the most significant bit. |
|
Decreases the size of the bitset by one, removing the least significant bit. |
|
Increases the size of the bitset by one, and sets the value of the new most significant bit to |
|
Increases the size of the bitset by one, and sets the value of the new least significant bit to |
|
|
|
|
|
Informs the bitset of a planned change in size, so that it can manage the storage allocation accordingly. |
|
|
|
Changes the number of bits of the bitset to |
|
|
|
Requests the bitset to reduce memory use by removing unused capacity. |
|
Returns the number of bits in this bitset. |
|
Swaps the contents of this bitset and bitset |
|
Tests the bit at the given position. |
|
Sets bit |
|
Returns the numeric value corresponding to the bits in |
|
Returns a representation of |
|
Returns the numeric value corresponding to the bits in |
|
Returns a shifted copy of |
Static Data Members
Name |
Description |
The number of bits the type |
|
The maximum value of |
Friends
Name |
Description |
|
|
Computes a hash value for a |
|
|
|
Less‐than operator |
|
Equality operator |
Non-Member Functions
Name |
Description |
Compares two bitsets. |
|
Performs a bitwise‐AND of two bitsets. |
|
Calculates the set difference of two bitsets. |
|
Compares two bitsets. |
|
Compares two bitsets. |
|
Compares two bitsets. |
|
Compares two bitsets. |
|
Compares two bitsets. |
|
Performs a bitwise‐XOR of two bitsets. |
|
Performs a bitwise‐OR of two bitsets. |
|
Exchanges the contents of |
|
Writes the bits of the bitset into the iterator |
|
Replaces the contents of the string |
Created with MrDocs