HIBF 1.0.0-rc.1
|
An bit vector. More...
#include <hibf/misc/bit_vector.hpp>
Public Types | |
Associated types | |
using | iterator = bit_iterator<false> |
The iterator over the bits. | |
using | const_iterator = bit_iterator<true> |
The const iterator over the bits. | |
using | value_type = std::iter_value_t<iterator> |
The value type is bool . | |
using | reference = std::iter_reference_t<iterator> |
The reference type which is implemented as a proxy. | |
using | const_reference = std::iter_reference_t<const_iterator> |
The const reference type which is implemented as a proxy. | |
using | size_type = size_t |
The size_type. | |
using | difference_type = std::iter_difference_t<iterator> |
The difference type. | |
using | allocator_type = allocator_t |
The allocator type to use. | |
Public Member Functions | |
constexpr chunk_type const * | data () const noexcept |
constexpr chunk_type * | data () noexcept |
template<cereal_archive archive_t> | |
void | load (archive_t &archive) |
Serialisation support function. | |
template<cereal_archive archive_t> | |
void | save (archive_t &archive) const |
Serialisation support function. | |
Constructors, destructor and assignment | |
constexpr | bit_vector (allocator_type const &alloc=allocator_type{}) |
The default constructor which optionally sets the allocator. | |
constexpr | bit_vector (bit_vector const &)=default |
Default. | |
constexpr | bit_vector (bit_vector &&)=default |
Default. | |
constexpr bit_vector & | operator= (bit_vector const &)=default |
Default. | |
constexpr bit_vector & | operator= (bit_vector &&)=default |
Default. | |
constexpr | ~bit_vector ()=default |
Default. | |
constexpr | bit_vector (size_type const count, bool const bit, allocator_type const &alloc=allocator_type{}) |
Constructs the bit vector with count copies of elements with value bit . | |
constexpr | bit_vector (std::initializer_list< bool > list, allocator_type const &alloc=allocator_type{}) |
Constructs the container initialised with the elements in list . | |
constexpr | bit_vector (size_type const count, allocator_type const &alloc=allocator_type{}) |
Constructs the container with count default-inserted instances of bool . No copies are made. | |
Member functions | |
template<std::input_iterator iterator_t, std::sentinel_for< iterator_t > sentinel_t> requires std::assignable_from<bool &, std::iter_reference_t<iterator_t>> | |
constexpr void | assign (iterator_t first, sentinel_t last) |
Assigns values to the container. | |
constexpr void | assign (std::initializer_list< bool > const &ilist) |
Assigns values to the container. | |
constexpr void | assign (size_type const count, bool const bit) |
Assigns values to the container. | |
Element access | |
constexpr reference | operator[] (size_type const position) noexcept |
Access specified element. | |
constexpr const_reference | operator[] (size_type const position) const noexcept |
Access specified element. | |
constexpr reference | back () noexcept |
Access the last element. | |
constexpr const_reference | back () const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
constexpr bool | all () const noexcept |
Checks if all bits are set to true . | |
constexpr bool | any () const noexcept |
Checks if any bit is set to true . | |
constexpr bool | none () const noexcept |
Checks if none of the bits is set to true . | |
Capacity | |
constexpr size_type | size () const noexcept |
Returns the number of elements. | |
constexpr bool | empty () const noexcept |
Checks wether the container is empty. | |
constexpr size_type | capacity () const noexcept |
Returns the capacity. | |
constexpr void | reserve (size_type const new_capacity) |
Reserves storage. | |
Iterators | |
constexpr iterator | begin () noexcept |
Returns an iterator to the beginning. | |
constexpr const_iterator | begin () const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
constexpr const_iterator | cbegin () const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
constexpr iterator | end () noexcept |
Returns an iterator to the end. | |
constexpr const_iterator | end () const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
constexpr const_iterator | cend () const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
![]() | |
T | assign (T... args) |
T | at (T... args) |
T | back (T... args) |
T | begin (T... args) |
T | capacity (T... args) |
T | cbegin (T... args) |
T | cend (T... args) |
T | clear (T... args) |
T | crbegin (T... args) |
T | crend (T... args) |
T | data (T... args) |
T | emplace (T... args) |
T | emplace_back (T... args) |
T | empty (T... args) |
T | end (T... args) |
T | erase (T... args) |
T | front (T... args) |
T | get_allocator (T... args) |
T | insert (T... args) |
T | max_size (T... args) |
T | operator= (T... args) |
T | operator[] (T... args) |
T | pop_back (T... args) |
T | push_back (T... args) |
T | rbegin (T... args) |
T | rend (T... args) |
T | reserve (T... args) |
T | resize (T... args) |
T | shrink_to_fit (T... args) |
T | size (T... args) |
T | swap (T... args) |
T | vector (T... args) |
T | ~vector (T... args) |
Modifiers | |
constexpr void | push_back (bool bit) |
Adds an element to the end. | |
constexpr void | resize (size_type const count, bool const bit={}) |
Changes the number of elements stored, where additional copies of bit are appended. | |
constexpr void | clear () noexcept |
Erases all elements. After this call, size() returns zero. capacity() remains unchanged. | |
constexpr bit_vector & | operator&= (bit_vector const &rhs) noexcept |
Performs binary AND between this and rhs . | |
constexpr bit_vector & | operator|= (bit_vector const &rhs) noexcept |
Performs binary OR between this and rhs . | |
constexpr bit_vector & | operator^= (bit_vector const &rhs) noexcept |
Performs binary XOR between this and rhs . | |
constexpr bit_vector | operator~ () const noexcept |
Performs binary NOT. | |
constexpr bit_vector & | and_not (bit_vector const &rhs) noexcept |
Computes the bitwise a &= ~b operator without an additional copy. | |
constexpr bit_vector & | flip () noexcept |
Flips all bits in-place. | |
constexpr bit_vector & | flip (size_type position) |
Flips the bit at the given position. | |
constexpr void | swap (bit_vector &other) noexcept |
Exchanges the contents of the container with those of others. | |
constexpr friend bit_vector | operator& (bit_vector lhs, bit_vector const &rhs) noexcept |
Performs binary AND. | |
constexpr friend bit_vector | operator| (bit_vector lhs, bit_vector const &rhs) noexcept |
Performs binary OR. | |
constexpr friend bit_vector | operator^ (bit_vector lhs, bit_vector const &rhs) noexcept |
Performs binary XOR. | |
An bit vector.
Implements a bit vector on the basis of a std::vector with uint64_t
as value type. The bit vector can be dynamically resized and provides additional interfaces to apply efficient bit-operations on it.
The reference type is a special proxy that provides access to a single bit. Note that it is not a real reference but can be converter to a bool or assigned from a bool.
|
inlineconstexpr |
Constructs the bit vector with count
copies of elements with value bit
.
[in] | count | The number of elements to create the bit vector with. |
[in] | bit | The bit to set during initialisation. |
[in] | alloc | The allocator to use [optional]. |
|
inlineconstexpr |
Constructs the container initialised with the elements in list
.
[in] | list | An initialiser list with the bits set. |
[in] | alloc | The allocator to use [optional]. |
|
inlineconstexpr |
Constructs the container with count
default-inserted instances of bool
. No copies are made.
[in] | count | The number of elements to create the bit vector with. |
[in] | alloc | The allocator to use [optional]. |
|
inlineconstexpr |
Assigns values to the container.
iterator_t | The type of the iterator; must model std::input_iterator. |
sentinel_t | The type of the sentinel; must model std::sentinel_for iterator_t . |
[in] | first | An first element to copy elements from. |
[in] | last | The end of the range to copy elements from. |
Replaces the contents with copies of the range ‘[first, last)’. The behaviour is undefined if either argument is an iterator to *this
.
All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
If an exception is thrown this function has no effect (strong exception guarantee).
Linear in distance between first and last.
|
inlineconstexpr |
Assigns values to the container.
[in] | ilist | The initialiser list with the elements to insert. |
Replaces the contents with the elements from the initializer list ilist.
All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
If an exception is thrown this function has no effect (strong exception guarantee).
Linear in ilist.size()
.
|
inlineconstexpr |
Assigns values to the container.
[in] | count | The new size of the container. |
[in] | bit | The value to initialize elements of the container with. |
Replaces the contents with count
copies of value bit
.
All iterators, pointers and references to the elements of the container are invalidated. The past-the-end iterator is also invalidated.
If an exception is thrown this function has no effect (strong exception guarantee).
Linear in count.
|
inlineconstexprnoexcept |
Access the last element.
Calling back on an empty container causes underfined behaviour.
Throws nothing.
Constant.
|
inlineconstexpr |
Reserves storage.
[in] | new_capacity | The new capacity of the bit vector. |
Increase the capacity of the vector to a value that's greater or equal to new_capacity. If new_capacity is greater than the current capacity(), new storage is allocated, otherwise the method does nothing. reserve() does not change the size of the vector. If new_capacity is greater than capacity(), all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
std::length_error if new_capacity > max_size()
or any exception thrown by allocator_t::allocate(). If an exception is thrown this function has no effect (strong exception guarantee).
|
inlineconstexpr |
Adds an element to the end.
bit | The bit to add to the end. |
Appends the given element value to the end of the container.
If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.
If an exception is thrown (which can be due to allocator_t::allocate(), this function has no effect (strong exception guarantee).
Amortised constant.
|
inline |
Serialisation support function.
archive_t | Type of archive ; must satisfy seqan::hibf::cereal_archive. |
[in] | archive | The archive being serialised from/to. |
|
inline |
Serialisation support function.
archive_t | Type of archive ; must satisfy seqan::hibf::cereal_archive. |
[in] | archive | The archive being serialised from/to. |