20#include <seqan3/contrib/sdsl-lite.hpp>
59template <writable_semialphabet alphabet_type>
60 requires std::regular<alphabet_type>
67 static_assert(bits_per_letter <= 64,
"alphabet must be representable in at most 64bit.");
70 using data_type = seqan3::contrib::sdsl::int_vector<bits_per_letter>;
76 class reference_proxy_type :
public alphabet_proxy<reference_proxy_type, alphabet_type>
85 std::ranges::range_reference_t<data_type> internal_proxy;
88 constexpr void on_update()
noexcept
95 using base_t::operator=;
101 reference_proxy_type() =
delete;
102 constexpr reference_proxy_type(reference_proxy_type
const &)
noexcept =
default;
103 constexpr reference_proxy_type(reference_proxy_type &&)
noexcept =
default;
104 constexpr reference_proxy_type & operator=(reference_proxy_type
const &)
noexcept =
default;
105 constexpr reference_proxy_type & operator=(reference_proxy_type &&)
noexcept =
default;
106 ~reference_proxy_type()
noexcept =
default;
109 reference_proxy_type(std::ranges::range_reference_t<data_type>
const internal)
noexcept :
110 internal_proxy{internal}
122 template <
typename t>
123 requires std::is_same_v<std::ranges::range_value_t<std::remove_cvref_t<t>>, alphabet_type>
151 using iterator = detail::random_access_iterator<bitpacked_sequence>;
194 template <
typename other_range_t>
195 requires (!std::same_as<bitpacked_sequence, std::remove_cvref_t<other_range_t>>)
235 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
237 requires std::sentinel_for<end_iterator_type, begin_iterator_type>
238 && std::common_reference_with<std::iter_value_t<begin_iterator_type>,
value_type>
293 template <std::ranges::input_range other_range_t>
295 requires std::common_reference_with<std::ranges::range_value_t<other_range_t>,
value_type>
338 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
340 requires std::sentinel_for<end_iterator_type, begin_iterator_type>
341 && std::common_reference_with<std::iter_value_t<begin_iterator_type>,
value_type>
457 throw std::out_of_range{
"Trying to access element behind the last in bitpacked_sequence."};
467 throw std::out_of_range{
"Trying to access element behind the last in bitpacked_sequence."};
548 return (*
this)[
size() - 1];
555 return (*
this)[
size() - 1];
636 return data.max_size();
654 return data.capacity();
701 data.shrink_to_fit();
747 return insert(pos, 1, value);
806 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
808 requires std::sentinel_for<end_iterator_type, begin_iterator_type>
809 && std::common_reference_with<std::iter_value_t<begin_iterator_type>,
value_type>
813 auto v = std::ranges::subrange<begin_iterator_type, end_iterator_type>{begin_it, end_it}
868 if (begin_it >= end_it)
902 return erase(pos, pos + 1);
924 data.push_back(
to_rank(value));
992 data.resize(count,
to_rank(value));
1055 return data ==
rhs.data;
1064 return data !=
rhs.data;
1073 return data <
rhs.data;
1082 return data >
rhs.data;
1091 return data <=
rhs.data;
1100 return data >=
rhs.data;
1111 template <cereal_archive archive_t>
Provides seqan3::alphabet_proxy.
Adaptions of concepts from the Cereal library.
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets.
Definition alphabet_proxy.hpp:62
constexpr reference_proxy_type & assign_rank(alphabet_rank_t< alphabet_type > const r) noexcept
Assigns a rank.
Definition alphabet_proxy.hpp:142
constexpr auto to_rank() const noexcept
Returns the rank.
Definition alphabet_proxy.hpp:204
A space-optimised version of std::vector that compresses multiple letters into a single byte.
Definition bitpacked_sequence.hpp:62
void assign(size_type const count, value_type const value)
Assign with count times value.
Definition bitpacked_sequence.hpp:315
alphabet_type value_type
Equals the alphabet_type.
Definition bitpacked_sequence.hpp:135
std::ranges::range_difference_t< data_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition bitpacked_sequence.hpp:161
iterator insert(const_iterator pos, begin_iterator_type begin_it, end_iterator_type end_it)
Inserts elements from range [begin_it, end_it) before position in the container.
Definition bitpacked_sequence.hpp:807
constexpr bitpacked_sequence(bitpacked_sequence &&)=default
Defaulted.
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition bitpacked_sequence.hpp:900
reference_proxy_type reference
A proxy type (models seqan3::writable_semialphabet) that enables assignment, think of it as value_typ...
Definition bitpacked_sequence.hpp:141
constexpr bool operator>(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition bitpacked_sequence.hpp:1080
size_type max_size() const noexcept
Returns the maximum number of elements the container is able to hold due to system or library impleme...
Definition bitpacked_sequence.hpp:634
bool empty() const noexcept
Checks whether the container is empty.
Definition bitpacked_sequence.hpp:595
reference operator[](size_type const i) noexcept
Return the i-th element.
Definition bitpacked_sequence.hpp:489
const_reference back() const noexcept
Return the last element.
Definition bitpacked_sequence.hpp:552
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition bitpacked_sequence.hpp:397
iterator erase(const_iterator begin_it, const_iterator end_it)
Removes specified elements from the container.
Definition bitpacked_sequence.hpp:866
iterator insert(const_iterator pos, value_type const value)
Inserts value before position in the container.
Definition bitpacked_sequence.hpp:745
~bitpacked_sequence()=default
Defaulted.
void resize(size_type const count, value_type const value)
Resizes the container to contain count elements.
Definition bitpacked_sequence.hpp:989
void clear() noexcept
Removes all elements from the container.
Definition bitpacked_sequence.hpp:720
constexpr bool operator<=(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition bitpacked_sequence.hpp:1089
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition bitpacked_sequence.hpp:423
constexpr bool operator>=(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition bitpacked_sequence.hpp:1098
constexpr bitpacked_sequence(bitpacked_sequence const &)=default
Defaulted.
void push_back(value_type const value)
Appends the given element value to the end of the container.
Definition bitpacked_sequence.hpp:922
const_reference at(size_type const i) const
Return the i-th element.
Definition bitpacked_sequence.hpp:463
constexpr bool operator!=(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition bitpacked_sequence.hpp:1062
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition bitpacked_sequence.hpp:417
void assign(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition bitpacked_sequence.hpp:360
void reserve(size_type const new_cap)
Increase the capacity to a value that's greater or equal to new_cap.
Definition bitpacked_sequence.hpp:677
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition bitpacked_sequence.hpp:391
detail::random_access_iterator< bitpacked_sequence const > const_iterator
The const_iterator type of this container (a random access iterator).
Definition bitpacked_sequence.hpp:156
bitpacked_sequence(std::initializer_list< value_type > ilist)
Construct from std::initializer_list.
Definition bitpacked_sequence.hpp:256
void shrink_to_fit()
Requests the removal of unused capacity.
Definition bitpacked_sequence.hpp:699
const_reference operator[](size_type const i) const noexcept
Return the i-th element.
Definition bitpacked_sequence.hpp:496
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition bitpacked_sequence.hpp:385
std::ranges::range_size_t< data_type > size_type
An unsigned integer type (usually std::size_t)
Definition bitpacked_sequence.hpp:166
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition bitpacked_sequence.hpp:652
void assign(other_range_t &&range)
Assign from a different range.
Definition bitpacked_sequence.hpp:294
detail::random_access_iterator< bitpacked_sequence > iterator
The iterator type of this container (a random access iterator).
Definition bitpacked_sequence.hpp:151
alphabet_type const_reference
Equals the alphabet_type / value_type.
Definition bitpacked_sequence.hpp:146
iterator insert(const_iterator pos, std::initializer_list< value_type > const &ilist)
Inserts elements from initializer list before position in the container.
Definition bitpacked_sequence.hpp:840
reference at(size_type const i)
Return the i-th element.
Definition bitpacked_sequence.hpp:453
bitpacked_sequence(begin_iterator_type begin_it, end_iterator_type end_it)
Construct from pair of iterators.
Definition bitpacked_sequence.hpp:236
friend constexpr void swap(bitpacked_sequence &lhs, bitpacked_sequence &rhs) noexcept
Swap contents with another instance.
Definition bitpacked_sequence.hpp:1033
const_reference front() const noexcept
Return the first element. Calling front on an empty container is undefined.
Definition bitpacked_sequence.hpp:524
constexpr bitpacked_sequence & operator=(bitpacked_sequence const &)=default
Defaulted.
constexpr data_type const & raw_data() const noexcept
Provides direct, unsafe access to underlying data structures.
Definition bitpacked_sequence.hpp:573
constexpr bool operator==(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition bitpacked_sequence.hpp:1053
friend constexpr void swap(bitpacked_sequence &&lhs, bitpacked_sequence &&rhs) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bitpacked_sequence.hpp:1039
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition bitpacked_sequence.hpp:429
bitpacked_sequence(size_type const count, value_type const value)
Construct with count times value.
Definition bitpacked_sequence.hpp:215
bitpacked_sequence & operator=(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition bitpacked_sequence.hpp:272
void resize(size_type const count)
Resizes the container to contain count elements.
Definition bitpacked_sequence.hpp:979
void pop_back()
Removes the last element of the container.
Definition bitpacked_sequence.hpp:945
reference back() noexcept
Return the last element.
Definition bitpacked_sequence.hpp:545
iterator insert(const_iterator pos, size_type const count, value_type const value)
Inserts count copies of value before position in the container.
Definition bitpacked_sequence.hpp:771
bitpacked_sequence()=default
Defaulted.
constexpr void swap(bitpacked_sequence &&rhs) noexcept
Swap contents with another instance.
Definition bitpacked_sequence.hpp:1014
bitpacked_sequence(other_range_t &&range)
Construct from a different range.
Definition bitpacked_sequence.hpp:197
constexpr data_type & raw_data() noexcept
Provides direct, unsafe access to underlying data structures.
Definition bitpacked_sequence.hpp:567
constexpr bool operator<(bitpacked_sequence const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition bitpacked_sequence.hpp:1071
constexpr void swap(bitpacked_sequence &rhs) noexcept
Swap contents with another instance.
Definition bitpacked_sequence.hpp:1008
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition bitpacked_sequence.hpp:613
reference front() noexcept
Return the first element. Calling front on an empty container is undefined.
Definition bitpacked_sequence.hpp:517
constexpr bitpacked_sequence & operator=(bitpacked_sequence &&)=default
Defaulted.
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Assign from pair of iterators.
Definition bitpacked_sequence.hpp:339
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition to_rank.hpp:63
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition alphabet/concept.hpp:288
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition alphabet/concept.hpp:152
Provides math related functionality.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides the seqan3::detail::random_access_iterator class.
Provides seqan3::views::to_char.
Provides seqan3::views::to_rank.
Provides seqan3::views::convert.