Loading...
Searching...
No Matches
dynamic_bitset.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <bit>
#include <istream>
#include <vector>
#include <seqan3/core/concept/cereal.hpp>
#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/utility/detail/integer_traits.hpp>
#include <seqan3/utility/range/to.hpp>
#include <seqan3/utility/views/interleave.hpp>
#include <seqan3/utility/views/repeat_n.hpp>
namespace seqan3
{
template <size_t bit_capacity = 58>
class dynamic_bitset
{
private:
template <size_t>
friend class dynamic_bitset;
struct bitfield
{
uint64_t size : 6u;
uint64_t bits : 58u;
};
bitfield data{0u, 0u}; // Specifying values prevents ICE on gcc < 9 when comparing to default constructed bitset
class reference_proxy_type
{
public:
constexpr reference_proxy_type() noexcept = default;
constexpr reference_proxy_type(reference_proxy_type const &) noexcept = default;
constexpr reference_proxy_type(reference_proxy_type &&) noexcept = default;
constexpr reference_proxy_type & operator=(reference_proxy_type const rhs) noexcept
{
rhs ? set() : reset();
return *this;
}
constexpr reference_proxy_type & operator=(bool const value) noexcept
{
value ? set() : reset();
return *this;
}
~reference_proxy_type() noexcept = default;
constexpr reference_proxy_type(bitfield & internal_, size_t const pos) noexcept :
internal{internal_},
mask{1ULL << pos}
{}
constexpr operator bool() const noexcept
{
return static_cast<bool>(internal.bits & mask);
}
constexpr bool operator~() const noexcept
{
return !static_cast<bool>(internal.bits & mask);
}
constexpr reference_proxy_type & operator|=(bool const value)
{
if (value)
set();
return *this;
}
constexpr reference_proxy_type & operator&=(bool const value)
{
if (!value)
reset();
return *this;
}
constexpr reference_proxy_type & operator^=(bool const value)
{
operator bool() && value ? reset() : set();
return *this;
}
private:
bitfield & internal;
uint64_t mask;
constexpr void set() noexcept
{
internal.bits |= mask;
}
constexpr void reset() noexcept
{
internal.bits &= ~mask;
}
};
public:
static_assert(bit_capacity <= 58, "The capacity of the dynamic_bitset exceeds the limit of 58.");
using value_type = bool;
using reference = reference_proxy_type;
using const_reference = bool;
using iterator = detail::random_access_iterator<dynamic_bitset>;
using const_iterator = detail::random_access_iterator<dynamic_bitset const>;
using difference_type = ptrdiff_t;
using size_type = detail::min_viable_uint_t<bit_capacity>;
constexpr dynamic_bitset() noexcept = default;
constexpr dynamic_bitset(dynamic_bitset const &) noexcept = default;
constexpr dynamic_bitset(dynamic_bitset &&) noexcept = default;
constexpr dynamic_bitset & operator=(dynamic_bitset const &) noexcept = default;
constexpr dynamic_bitset & operator=(dynamic_bitset &&) noexcept = default;
~dynamic_bitset() noexcept = default;
constexpr dynamic_bitset(uint64_t const value)
{
if (std::popcount(value >> 58u) != 0u)
throw std::invalid_argument{"The dynamic_bitset can be at most 58 long."};
data.bits |= value;
data.size |= std::bit_width(value);
}
template <std::forward_iterator begin_it_type, typename end_it_type>
requires std::sentinel_for<end_it_type, begin_it_type>
&& std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr dynamic_bitset(begin_it_type begin_it, end_it_type end_it) noexcept : dynamic_bitset{}
{
assign(begin_it, end_it);
}
template <std::ranges::input_range other_range_t>
requires (!std::same_as<std::remove_cvref_t<other_range_t>, dynamic_bitset>)
explicit constexpr dynamic_bitset(other_range_t && range) noexcept :
dynamic_bitset{std::ranges::begin(range), std::ranges::end(range)}
{}
constexpr dynamic_bitset(size_type const n, value_type const value) noexcept : dynamic_bitset{}
{
assign(n, value);
}
constexpr dynamic_bitset & operator=(std::initializer_list<value_type> const ilist) noexcept
{
assign(std::ranges::begin(ilist), std::ranges::end(ilist));
return *this;
}
template <size_t N>
constexpr dynamic_bitset(char const (&lit)[N]) : dynamic_bitset{}
{
static_assert(N <= bit_capacity + 1, "Length of string literal exceeds capacity of dynamic_bitset.");
assign(lit);
}
template <size_t N>
constexpr dynamic_bitset & operator=(char const (&lit)[N])
{
static_assert(N <= bit_capacity + 1, "Length of string literal exceeds capacity of dynamic_bitset.");
assign(lit);
return *this;
}
template <size_t N>
constexpr void assign(char const (&lit)[N])
{
static_assert(N <= bit_capacity + 1, "Length of string literal exceeds capacity of dynamic_bitset.");
assert(lit[N - 1] == '\0');
uint64_t value{};
for (size_t i = 0; i != N - 1; ++i)
{
if (lit[i] == '0')
{
value <<= 1;
}
else if (lit[i] == '1')
{
value <<= 1;
value |= 1u;
}
else
{
throw std::invalid_argument{"The string to construct a dynamic_bitset from may only contain 0 and 1."};
}
}
*this = value;
resize(N - 1);
}
constexpr void assign(std::initializer_list<value_type> const ilist) noexcept
{
assign(std::ranges::begin(ilist), std::ranges::end(ilist));
}
constexpr void assign(size_type const count, value_type const value) noexcept
{
clear();
auto tmp = views::repeat_n(value, count);
assign(std::ranges::begin(tmp), std::ranges::end(tmp));
}
template <std::ranges::input_range other_range_t>
requires std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr void assign(other_range_t && range) noexcept
{
assign(std::ranges::begin(range), std::ranges::end(range));
}
template <std::forward_iterator begin_it_type, typename end_it_type>
requires std::sentinel_for<end_it_type, begin_it_type>
&& std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr void assign(begin_it_type begin_it, end_it_type end_it) noexcept
{
clear();
insert(cbegin(), begin_it, end_it);
}
constexpr iterator begin() noexcept
{
return iterator{*this};
}
constexpr const_iterator begin() const noexcept
{
return const_iterator{*this};
}
constexpr const_iterator cbegin() const noexcept
{
return begin();
}
constexpr iterator end() noexcept
{
return iterator{*this, size()};
}
constexpr const_iterator end() const noexcept
{
return const_iterator{*this, size()};
}
constexpr const_iterator cend() const noexcept
{
return end();
}
constexpr dynamic_bitset & operator&=(dynamic_bitset const & rhs) noexcept
{
assert(size() == rhs.size());
data.bits &= rhs.data.bits;
return *this;
}
constexpr dynamic_bitset & operator|=(dynamic_bitset const & rhs) noexcept
{
assert(size() == rhs.size());
data.bits |= rhs.data.bits;
return *this;
}
constexpr dynamic_bitset & operator^=(dynamic_bitset const & rhs) noexcept
{
assert(size() == rhs.size());
data.bits ^= rhs.data.bits;
return *this;
}
constexpr dynamic_bitset operator~() const noexcept
{
dynamic_bitset tmp{*this};
tmp.flip();
return tmp;
}
constexpr dynamic_bitset & operator<<=(size_t const count) noexcept
{
assert(count > 0);
assert(count < size());
data.bits <<= count;
data.bits &= (1ULL << size()) - 1ULL;
return *this;
}
constexpr dynamic_bitset & operator>>=(size_t const count) noexcept
{
assert(count > 0);
assert(count < size());
data.bits >>= count;
return *this;
}
constexpr dynamic_bitset operator>>(size_t const count) const noexcept
{
assert(count > 0);
assert(count < size());
dynamic_bitset tmp{*this};
tmp >>= count;
return tmp;
}
constexpr dynamic_bitset operator<<(size_t const count) const noexcept
{
assert(count > 0);
assert(count < size());
dynamic_bitset tmp{*this};
tmp <<= count;
return tmp;
}
constexpr dynamic_bitset & set() noexcept
{
data.bits |= (1ULL << size()) - 1ULL;
return *this;
}
constexpr dynamic_bitset & set(size_t const i, bool const value = true)
{
at(i) = value;
return *this;
}
constexpr dynamic_bitset & reset() noexcept
{
data.bits = 0u;
return *this;
}
constexpr dynamic_bitset & reset(size_t const i)
{
set(i, false);
return *this;
}
constexpr dynamic_bitset & flip() noexcept
{
data.bits = ~data.bits;
data.bits &= (1ULL << size()) - 1ULL;
return *this;
}
constexpr dynamic_bitset & flip(size_t const i)
{
at(i) ? reset(i) : set(i);
return *this;
}
constexpr bool all() const noexcept
{
return count() == size();
}
constexpr bool any() const noexcept
{
return count() != 0;
}
constexpr bool none() const noexcept
{
return count() == 0;
}
constexpr size_type count() const noexcept
{
return std::popcount(data.bits);
}
constexpr reference at(size_t const i)
{
if (i >= size()) // [[unlikely]]
throw std::out_of_range{"Trying to access position " + std::to_string(i)
+ " in a seqan3::dynamic_bitset of size " + std::to_string(size()) + "."};
return (*this)[i];
}
constexpr const_reference at(size_t const i) const
{
if (i >= size()) // [[unlikely]]
throw std::out_of_range{"Trying to access position " + std::to_string(i)
+ " in a seqan3::dynamic_bitset of size " + std::to_string(size()) + "."};
return (*this)[i];
}
constexpr const_reference test(size_t const i) const
{
return at(i);
}
constexpr reference operator[](size_t const i) noexcept
{
assert(i < size());
return {data, i};
}
constexpr const_reference operator[](size_t const i) const noexcept
{
assert(i < size());
return data.bits & 1ULL << i;
}
constexpr reference front() noexcept
{
assert(size() > 0);
return (*this)[0];
}
constexpr const_reference front() const noexcept
{
assert(size() > 0);
return (*this)[0];
}
constexpr reference back() noexcept
{
assert(size() > 0);
return (*this)[size() - 1];
}
constexpr const_reference back() const noexcept
{
assert(size() > 0);
return (*this)[size() - 1];
}
constexpr bitfield * raw_data() noexcept
{
return &data;
}
constexpr bitfield const * raw_data() const noexcept
{
return &data;
}
constexpr bool empty() const noexcept
{
return size() == 0;
}
constexpr size_type size() const noexcept
{
return data.size;
}
constexpr size_type max_size() const noexcept
{
return capacity();
}
constexpr size_type capacity() const noexcept
{
return bit_capacity;
}
constexpr void reserve(size_t) const noexcept
{
// no-op
}
constexpr void shrink_to_fit() const noexcept
{
// no-op
}
constexpr void clear() noexcept
{
data.size &= 0ULL;
data.bits &= 0ULL;
}
constexpr iterator insert(const_iterator pos, value_type const value) noexcept
{
return insert(pos, 1, value);
}
constexpr iterator insert(const_iterator pos, size_type const count, value_type const value) noexcept
{
auto tmp = views::repeat_n(value, count);
return insert(pos, std::ranges::begin(tmp), std::ranges::end(tmp));
}
template <std::forward_iterator begin_it_type, typename end_it_type>
requires std::sentinel_for<end_it_type, begin_it_type>
&& std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr iterator insert(const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept
{
auto const pos_as_num = std::ranges::distance(cbegin(), pos);
auto const length = std::ranges::distance(begin_it, end_it);
if (length == 0)
return begin(); // nothing to insert
size_type const tmp_size{size()};
resize(tmp_size + length);
for (size_type i = tmp_size + length - 1; i > pos_as_num + length - 1; --i)
(*this)[i] = (*this)[i - length];
// std::ranges::copy(begin_it, end_it, (*this)[pos_as_num]);
for (auto i = pos_as_num; begin_it != end_it; ++i, ++begin_it)
(*this)[i] = *begin_it;
return begin() + pos_as_num;
}
constexpr iterator insert(const_iterator pos, std::initializer_list<value_type> const & ilist) noexcept
{
return insert(pos, ilist.begin(), ilist.end());
}
constexpr iterator erase(const_iterator begin_it, const_iterator end_it) noexcept
{
if (begin_it >= end_it) // [[unlikely]]
return begin() + std::ranges::distance(cbegin(), end_it);
auto const length = std::ranges::distance(begin_it, end_it);
auto out_it = begin() + std::ranges::distance(cbegin(), begin_it);
while (end_it != cend())
*(out_it++) = *(end_it++);
resize(size() - length);
return begin() + std::ranges::distance(cbegin(), begin_it);
}
constexpr iterator erase(const_iterator pos) noexcept
{
return erase(pos, pos + 1);
}
constexpr void push_back(value_type const value) noexcept
{
assert(size() < bit_capacity);
resize(size() + 1);
(*this)[size() - 1] = value;
}
constexpr void pop_back() noexcept
{
assert(size() > 0);
resize(size() - 1);
}
constexpr void resize(size_type const count, value_type const value = false) noexcept
{
assert(count <= bit_capacity);
// Enlarging.
data.bits |= value && count > size() ? ((1ULL << (count - size())) - 1) << size() : 0ULL;
// Set size bits.
data.size = count;
// Shrinking.
data.bits &= (1ULL << size()) - 1ULL;
}
constexpr void swap(dynamic_bitset & rhs) noexcept
{
bitfield tmp = std::move(data);
data = std::move(rhs.data);
rhs.data = std::move(tmp);
}
constexpr void swap(dynamic_bitset && rhs) noexcept
{
data = std::move(rhs.data);
}
friend constexpr void swap(dynamic_bitset & lhs, dynamic_bitset & rhs) noexcept
{
lhs.swap(rhs);
}
template <size_t cap>
requires (cap <= bit_capacity)
friend constexpr dynamic_bitset operator&(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
assert(lhs.size() == rhs.size());
dynamic_bitset tmp{lhs};
tmp &= rhs;
return tmp;
}
template <size_t cap>
requires (cap <= bit_capacity)
friend constexpr dynamic_bitset operator^(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
assert(lhs.size() == rhs.size());
dynamic_bitset tmp{lhs};
tmp ^= rhs;
return tmp;
}
template <size_t cap>
requires (cap <= bit_capacity)
friend constexpr dynamic_bitset operator|(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
assert(lhs.size() == rhs.size());
dynamic_bitset tmp{lhs};
tmp |= rhs;
return tmp;
}
template <size_t cap>
friend constexpr bool operator==(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return lhs.data.size == rhs.raw_data()->size && lhs.data.bits == rhs.raw_data()->bits;
}
template <size_t cap>
friend constexpr bool operator!=(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return !(lhs == rhs);
}
template <size_t cap>
friend constexpr bool operator<(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return lhs.data.bits < rhs.raw_data()->bits;
}
template <size_t cap>
friend constexpr bool operator>(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return lhs.data.bits > rhs.raw_data()->bits;
}
template <size_t cap>
friend constexpr bool operator<=(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return !(lhs > rhs);
}
template <size_t cap>
friend constexpr bool operator>=(dynamic_bitset const & lhs, dynamic_bitset<cap> const & rhs) noexcept
{
return !(lhs < rhs);
}
template <typename char_t = char>
std::string to_string(char_t zero = char_t{'0'}, char_t one = char_t{'1'}) const
{
std::string str{};
str.reserve(size());
for (bool const bit : std::views::reverse(*this))
bit ? str.push_back(one) : str.push_back(zero);
return str;
}
inline constexpr unsigned long to_ulong() const
{
if constexpr (std::numeric_limits<unsigned long>::max() < std::numeric_limits<size_t>::max())
{
if (data.bits > std::numeric_limits<unsigned long>::max())
throw std::overflow_error{"seqan3::dynamic_bitset cannot be represented as unsigned long."};
}
return static_cast<unsigned long>(data.bits);
}
inline constexpr unsigned long long to_ullong() const
{
if constexpr (std::numeric_limits<unsigned long long>::max() < std::numeric_limits<size_t>::max())
{
if (data.bits >= std::numeric_limits<unsigned long long>::max())
throw std::overflow_error{"seqan3::dynamic_bitset cannot be represented as unsigned long long."};
}
return static_cast<unsigned long long>(data.bits);
}
friend std::ostream & operator<<(std::ostream & os, dynamic_bitset const & arg)
{
os << arg.to_string();
return os;
}
friend std::istream & operator>>(std::istream & is, dynamic_bitset & arg)
{
// Check if stream is ok and skip leading whitespaces.
std::istream::sentry s(is);
if (s)
{
arg.clear(); // clear the bitset
std::streamsize num_char =
(is.width() > 0) ? std::min<std::streamsize>(is.width(), arg.max_size()) : arg.max_size();
assert(num_char > 0);
std::vector<bool> tmp{};
tmp.reserve(num_char);
for (std::streamsize n = num_char; n > 0 && (is.peek() == is.widen('0') || is.peek() == is.widen('1')); --n)
{
char c = is.get();
c == is.widen('0') ? tmp.push_back(false) : tmp.push_back(true);
}
arg.assign(std::views::reverse(tmp));
if (arg.size() == 0) // nothing extracted so we set the fail bit.
is.setstate(std::ios_base::failbit); // LCOV_EXCL_LINE
is.width(0); // cancel the effects of std::setw, if any.
}
return is;
}
template <cereal_archive archive_t>
void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
{
uint64_t size = data.size;
archive(size);
data.size = size;
uint64_t bits = data.bits;
archive(bits);
data.bits = bits;
}
};
template <size_t bit_capacity>
struct dynamic_bitset_printer<dynamic_bitset<bit_capacity>>
{
template <typename stream_t, typename arg_t>
constexpr void operator()(stream_t & stream, arg_t && arg) const
{
stream << (std::string_view{arg.to_string()} | views::interleave(4, std::string_view{"'"})
| ranges::to<std::string>());
}
};
} // namespace seqan3
namespace std
{
template <size_t cap>
struct hash<seqan3::dynamic_bitset<cap>>
{
size_t operator()(seqan3::dynamic_bitset<cap> const arg) const noexcept
{
return static_cast<size_t>(arg.to_ullong());
}
};
} //namespace std
std::istream
std::ostream
std::string
std::string_view
cereal.hpp
Adaptions of concepts from the Cereal library.
seqan3::dynamic_bitset
A constexpr bitset implementation with dynamic size at compile time.
Definition dynamic_bitset.hpp:53
seqan3::dynamic_bitset::operator<<
constexpr dynamic_bitset operator<<(size_t const count) const noexcept
Performs binary shift left.
Definition dynamic_bitset.hpp:828
seqan3::dynamic_bitset::dynamic_bitset
friend class dynamic_bitset
Befriend other template instantiations of dynamic_bitset.
Definition dynamic_bitset.hpp:57
seqan3::dynamic_bitset::insert
constexpr iterator insert(const_iterator pos, value_type const value) noexcept
Inserts value before pos in the container.
Definition dynamic_bitset.hpp:1346
seqan3::dynamic_bitset::size
constexpr size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition dynamic_bitset.hpp:1232
seqan3::dynamic_bitset::insert
constexpr iterator insert(const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept
Inserts elements from initializer list before pos in the container.
Definition dynamic_bitset.hpp:1444
seqan3::dynamic_bitset::size_type
detail::min_viable_uint_t< bit_capacity > size_type
An unsigned integer type (usually std::size_t).
Definition dynamic_bitset.hpp:208
seqan3::dynamic_bitset::operator<<=
constexpr dynamic_bitset & operator<<=(size_t const count) noexcept
Performs binary shift left on the current object.
Definition dynamic_bitset.hpp:742
seqan3::dynamic_bitset::any
constexpr bool any() const noexcept
Checks if any bit is set.
Definition dynamic_bitset.hpp:1017
seqan3::dynamic_bitset::resize
constexpr void resize(size_type const count, value_type const value=false) noexcept
Resizes the container to contain count elements.
Definition dynamic_bitset.hpp:1588
seqan3::dynamic_bitset::operator<
friend constexpr bool operator<(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1742
seqan3::dynamic_bitset::test
constexpr const_reference test(size_t const i) const
Returns the i-th element.
Definition dynamic_bitset.hpp:1076
seqan3::dynamic_bitset::back
constexpr reference back() noexcept
Returns the last element.
Definition dynamic_bitset.hpp:1165
seqan3::dynamic_bitset::operator>>
friend std::istream & operator>>(std::istream &is, dynamic_bitset &arg)
Formatted input for the seqan3::dynamic_bitset.
Definition dynamic_bitset.hpp:1902
seqan3::dynamic_bitset::clear
constexpr void clear() noexcept
Removes all elements from the container.
Definition dynamic_bitset.hpp:1321
seqan3::dynamic_bitset::count
constexpr size_type count() const noexcept
Returns the number of set bits.
Definition dynamic_bitset.hpp:1036
seqan3::dynamic_bitset::front
constexpr reference front() noexcept
Returns the first element.
Definition dynamic_bitset.hpp:1135
seqan3::dynamic_bitset::empty
constexpr bool empty() const noexcept
Checks whether the container is empty.
Definition dynamic_bitset.hpp:1212
seqan3::dynamic_bitset::max_size
constexpr size_type max_size() const noexcept
Returns the maximum number of elements the container is able to hold and resolves to bit_capacity.
Definition dynamic_bitset.hpp:1257
seqan3::dynamic_bitset::shrink_to_fit
constexpr void shrink_to_fit() const noexcept
Since the capacity is fixed on compile time, this is a no-op.
Definition dynamic_bitset.hpp:1295
seqan3::dynamic_bitset::operator&=
constexpr dynamic_bitset & operator&=(dynamic_bitset const &rhs) noexcept
Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.
Definition dynamic_bitset.hpp:625
seqan3::dynamic_bitset::all
constexpr bool all() const noexcept
Checks if all bit are set.
Definition dynamic_bitset.hpp:1007
seqan3::dynamic_bitset::flip
constexpr dynamic_bitset & flip() noexcept
Flips all bits (binary NOT).
Definition dynamic_bitset.hpp:964
seqan3::dynamic_bitset::operator==
friend constexpr bool operator==(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1722
seqan3::dynamic_bitset::reference
reference_proxy_type reference
A proxy type that enables assignment.
Definition dynamic_bitset.hpp:178
seqan3::dynamic_bitset::assign
constexpr void assign(char const (&lit)[N])
Assign from literal.
Definition dynamic_bitset.hpp:418
seqan3::dynamic_bitset::begin
constexpr const_iterator begin() const noexcept
Returns the begin to the dynamic_bitset.
Definition dynamic_bitset.hpp:560
seqan3::dynamic_bitset::to_ulong
constexpr unsigned long to_ulong() const
Converts the dynamic_bitset to an unsigned long integer.
Definition dynamic_bitset.hpp:1830
seqan3::dynamic_bitset::assign
constexpr void assign(begin_it_type begin_it, end_it_type end_it) noexcept
Assign from pair of iterators.
Definition dynamic_bitset.hpp:534
seqan3::dynamic_bitset::swap
constexpr void swap(dynamic_bitset &rhs) noexcept
Swap contents with another instance.
Definition dynamic_bitset.hpp:1614
seqan3::dynamic_bitset::dynamic_bitset
constexpr dynamic_bitset(other_range_t &&range) noexcept
Construct from a different range.
Definition dynamic_bitset.hpp:295
seqan3::dynamic_bitset::swap
constexpr void swap(dynamic_bitset &&rhs) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition dynamic_bitset.hpp:1622
seqan3::dynamic_bitset::dynamic_bitset
constexpr dynamic_bitset(char const (&lit)[N])
Construction from literal.
Definition dynamic_bitset.hpp:365
seqan3::dynamic_bitset::at
constexpr reference at(size_t const i)
Returns the i-th element.
Definition dynamic_bitset.hpp:1058
seqan3::dynamic_bitset::operator=
constexpr dynamic_bitset & operator=(std::initializer_list< value_type > const ilist) noexcept
Assign from std::initializer_list.
Definition dynamic_bitset.hpp:335
seqan3::dynamic_bitset::reset
constexpr dynamic_bitset & reset(size_t const i)
Sets the i'th bit to false.
Definition dynamic_bitset.hpp:939
seqan3::dynamic_bitset::erase
constexpr iterator erase(const_iterator pos) noexcept
Removes specified elements from the container.
Definition dynamic_bitset.hpp:1509
seqan3::dynamic_bitset::capacity
constexpr size_type capacity() const noexcept
Returns the number of elements that the container is able to hold and resolves to bit_capacity.
Definition dynamic_bitset.hpp:1277
seqan3::dynamic_bitset::raw_data
constexpr bitfield const * raw_data() const noexcept
Direct access to the underlying bit field.
Definition dynamic_bitset.hpp:1188
seqan3::dynamic_bitset::push_back
constexpr void push_back(value_type const value) noexcept
Appends the given element value to the end of the container.
Definition dynamic_bitset.hpp:1531
seqan3::dynamic_bitset::cbegin
constexpr const_iterator cbegin() const noexcept
Returns the begin to the dynamic_bitset.
Definition dynamic_bitset.hpp:566
seqan3::dynamic_bitset::insert
constexpr iterator insert(const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept
Inserts elements from range [begin_it, end_it) before pos in the container.
Definition dynamic_bitset.hpp:1404
seqan3::dynamic_bitset::operator>>
constexpr dynamic_bitset operator>>(size_t const count) const noexcept
Performs binary shift right.
Definition dynamic_bitset.hpp:799
seqan3::dynamic_bitset::dynamic_bitset
constexpr dynamic_bitset(begin_it_type begin_it, end_it_type end_it) noexcept
Construct from two iterators.
Definition dynamic_bitset.hpp:271
seqan3::dynamic_bitset::operator[]
constexpr const_reference operator[](size_t const i) const noexcept
Returns the i-th element.
Definition dynamic_bitset.hpp:1111
seqan3::dynamic_bitset::to_ullong
constexpr unsigned long long to_ullong() const
Converts the dynamic_bitset to an unsigned long long integer.
Definition dynamic_bitset.hpp:1857
seqan3::dynamic_bitset::back
constexpr const_reference back() const noexcept
Returns the last element.
Definition dynamic_bitset.hpp:1172
seqan3::dynamic_bitset::set
constexpr dynamic_bitset & set() noexcept
Sets all bits to 1.
Definition dynamic_bitset.hpp:856
seqan3::dynamic_bitset::raw_data
constexpr bitfield * raw_data() noexcept
Direct access to the underlying bit field.
Definition dynamic_bitset.hpp:1182
seqan3::dynamic_bitset::operator<<
friend std::ostream & operator<<(std::ostream &os, dynamic_bitset const &arg)
Formatted output for the seqan3::dynamic_bitset.
Definition dynamic_bitset.hpp:1883
seqan3::dynamic_bitset::end
constexpr iterator end() noexcept
Returns iterator past the end of the dynamic_bitset.
Definition dynamic_bitset.hpp:581
seqan3::dynamic_bitset::pop_back
constexpr void pop_back() noexcept
Removes the last element of the container.
Definition dynamic_bitset.hpp:1556
seqan3::dynamic_bitset::at
constexpr const_reference at(size_t const i) const
Returns the i-th element.
Definition dynamic_bitset.hpp:1067
seqan3::dynamic_bitset::operator>=
friend constexpr bool operator>=(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1772
seqan3::dynamic_bitset::begin
constexpr iterator begin() noexcept
Returns the begin to the dynamic_bitset.
Definition dynamic_bitset.hpp:554
seqan3::dynamic_bitset::assign
constexpr void assign(std::initializer_list< value_type > const ilist) noexcept
Assign from std::initializer_list.
Definition dynamic_bitset.hpp:460
seqan3::dynamic_bitset::set
constexpr dynamic_bitset & set(size_t const i, bool const value=true)
Sets the i'th bit to value.
Definition dynamic_bitset.hpp:884
seqan3::dynamic_bitset::reset
constexpr dynamic_bitset & reset() noexcept
Sets all bits to 0.
Definition dynamic_bitset.hpp:912
seqan3::dynamic_bitset::cend
constexpr const_iterator cend() const noexcept
Returns iterator past the end of the dynamic_bitset.
Definition dynamic_bitset.hpp:593
seqan3::dynamic_bitset::none
constexpr bool none() const noexcept
Checks if no bit is set.
Definition dynamic_bitset.hpp:1027
seqan3::dynamic_bitset::operator~
constexpr dynamic_bitset operator~() const noexcept
Returns a temporary copy of *this with all bits flipped (binary NOT).
Definition dynamic_bitset.hpp:715
seqan3::dynamic_bitset::const_reference
bool const_reference
Equals the value_type.
Definition dynamic_bitset.hpp:184
seqan3::dynamic_bitset::end
constexpr const_iterator end() const noexcept
Returns iterator past the end of the dynamic_bitset.
Definition dynamic_bitset.hpp:587
seqan3::dynamic_bitset::operator=
constexpr dynamic_bitset & operator=(char const (&lit)[N])
Assign from literal.
Definition dynamic_bitset.hpp:391
seqan3::dynamic_bitset::swap
friend constexpr void swap(dynamic_bitset &lhs, dynamic_bitset &rhs) noexcept
Swap contents with another instance.
Definition dynamic_bitset.hpp:1645
seqan3::dynamic_bitset::assign
constexpr void assign(size_type const count, value_type const value) noexcept
Assign with count times value.
Definition dynamic_bitset.hpp:481
seqan3::dynamic_bitset::difference_type
ptrdiff_t difference_type
A std::ptrdiff_t.
Definition dynamic_bitset.hpp:202
seqan3::dynamic_bitset::dynamic_bitset
constexpr dynamic_bitset() noexcept=default
Defaulted.
seqan3::dynamic_bitset::front
constexpr const_reference front() const noexcept
Returns the first element.
Definition dynamic_bitset.hpp:1142
seqan3::dynamic_bitset::assign
constexpr void assign(other_range_t &&range) noexcept
Assign from a different range.
Definition dynamic_bitset.hpp:507
seqan3::dynamic_bitset::to_string
std::string to_string(char_t zero=char_t{ '0'}, char_t one=char_t{ '1'}) const
Converts the dynamic_bitset to a std::string.
Definition dynamic_bitset.hpp:1804
seqan3::dynamic_bitset::operator^=
constexpr dynamic_bitset & operator^=(dynamic_bitset const &rhs) noexcept
Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.
Definition dynamic_bitset.hpp:685
seqan3::dynamic_bitset::erase
constexpr iterator erase(const_iterator begin_it, const_iterator end_it) noexcept
Removes specified elements from the container.
Definition dynamic_bitset.hpp:1472
seqan3::dynamic_bitset::reserve
constexpr void reserve(size_t) const noexcept
Since the capacity is fixed on compile time, this is a no-op.
Definition dynamic_bitset.hpp:1286
seqan3::dynamic_bitset::operator>>=
constexpr dynamic_bitset & operator>>=(size_t const count) noexcept
Performs binary shift right on the current object.
Definition dynamic_bitset.hpp:771
seqan3::dynamic_bitset::operator|=
constexpr dynamic_bitset & operator|=(dynamic_bitset const &rhs) noexcept
Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.
Definition dynamic_bitset.hpp:655
seqan3::dynamic_bitset::operator<=
friend constexpr bool operator<=(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1762
seqan3::dynamic_bitset::iterator
detail::random_access_iterator< dynamic_bitset > iterator
The iterator type of this container (a random access iterator).
Definition dynamic_bitset.hpp:190
seqan3::dynamic_bitset::dynamic_bitset
constexpr dynamic_bitset(size_type const n, value_type const value) noexcept
Construct with n times value.
Definition dynamic_bitset.hpp:315
seqan3::dynamic_bitset::insert
constexpr iterator insert(const_iterator pos, size_type const count, value_type const value) noexcept
Inserts count copies of value before position in the container.
Definition dynamic_bitset.hpp:1371
seqan3::dynamic_bitset::value_type
bool value_type
Equals bool.
Definition dynamic_bitset.hpp:172
seqan3::dynamic_bitset::const_iterator
detail::random_access_iterator< dynamic_bitset const > const_iterator
The const_iterator type of this container (a random access iterator).
Definition dynamic_bitset.hpp:196
seqan3::dynamic_bitset::operator[]
constexpr reference operator[](size_t const i) noexcept
Returns the i-th element.
Definition dynamic_bitset.hpp:1104
seqan3::dynamic_bitset::operator>
friend constexpr bool operator>(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1752
seqan3::dynamic_bitset::operator!=
friend constexpr bool operator!=(dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
Performs element-wise comparison.
Definition dynamic_bitset.hpp:1732
seqan3::dynamic_bitset::flip
constexpr dynamic_bitset & flip(size_t const i)
Flips the i'th bit (binary NOT).
Definition dynamic_bitset.hpp:992
debug_stream_type.hpp
Provides seqan3::debug_stream and related types.
std::istream::get
T get(T... args)
seqan3::ranges::to
seqan::stl::ranges::to to
Converts a range to a container. <dl class="no-api">This entity is not part of the SeqAn API....
Definition to.hpp:23
seqan3::views::repeat_n
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition repeat_n.hpp:88
seqan3::views::interleave
constexpr auto interleave
A view that interleaves a given range into another range at regular intervals.
Definition interleave.hpp:374
std::hash< seqan3::dynamic_bitset< cap > >::hash
T hash(T... args)
std::initializer_list
integer_traits.hpp
Provides metaprogramming utilities for integer types.
interleave.hpp
Provides seqan3::views::interleave.
std::invalid_argument
istream
std::numeric_limits::max
T max(T... args)
std::min
T min(T... args)
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
std
SeqAn specific customisations in the standard namespace.
std::out_of_range
std::overflow_error
std::istream::peek
T peek(T... args)
std::string::push_back
T push_back(T... args)
repeat_n.hpp
Provides seqan3::views::repeat_n.
std::string::reserve
T reserve(T... args)
std::istream::sentry
std::istream::setstate
T setstate(T... args)
std::streamsize
seqan3::dynamic_bitset_printer< dynamic_bitset< bit_capacity > >::operator()
constexpr void operator()(stream_t &stream, arg_t &&arg) const
Prints the dynamic bitset.
Definition dynamic_bitset.hpp:1969
seqan3::dynamic_bitset_printer
Definition default_printer.hpp:34
std::hash< seqan3::dynamic_bitset< cap > >::operator()
size_t operator()(seqan3::dynamic_bitset< cap > const arg) const noexcept
Compute the hash for a seqan3::dynamic_bitset.
Definition dynamic_bitset.hpp:1997
to.hpp
Provides seqan3::ranges::to.
std::to_string
T to_string(T... args)
vector
std::istream::widen
T widen(T... args)
std::istream::width
T width(T... args)
Hide me