|
SeqAn3
3.0.1
The Modern C++ library for sequence analysis.
|
|
Go to the documentation of this file.
15 #include <type_traits>
17 #include <sdsl/int_vector.hpp>
62 template <writable_semialphabet alphabet_type>
70 static constexpr
size_t bits_per_letter =
std::ceil(std::log2(alphabet_size<alphabet_type>));
72 static_assert(bits_per_letter <= 64,
"alphabet must be representable in at most 64bit.");
75 using data_type = sdsl::int_vector<bits_per_letter>;
82 class reference_proxy_type :
public alphabet_proxy<reference_proxy_type, alphabet_type>
94 constexpr
void on_update() noexcept
96 internal_proxy = static_cast<base_t &>(*this).
to_rank();
101 using base_t::operator=;
106 reference_proxy_type() =
delete;
108 constexpr reference_proxy_type(reference_proxy_type
const &) noexcept =
default;
109 constexpr reference_proxy_type(reference_proxy_type &&) noexcept =
default;
110 constexpr reference_proxy_type &
operator=(reference_proxy_type
const &) noexcept =
default;
111 constexpr reference_proxy_type &
operator=(reference_proxy_type &&) noexcept =
default;
112 ~reference_proxy_type() noexcept =
default;
116 internal_proxy{
internal}
118 static_cast<base_t &>(*this).assign_rank(
internal);
126 template <
typename t>
127 requires std::is_same_v<value_type_t<remove_cvref_t<t>>, alphabet_type>
128 static constexpr
bool has_same_value_type_v =
true;
142 using iterator = detail::random_access_iterator<bitcompressed_vector>;
144 using const_iterator = detail::random_access_iterator<bitcompressed_vector const>;
153 using allocator_type = void;
179 template <std::ranges::input_range other_range_t>
181 requires has_same_value_type_v<other_range_t>
218 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
221 requires std::sentinel_for<end_iterator_type, begin_iterator_type> &&
273 template <std::ranges::input_range other_range_t>
316 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
317 void assign(begin_iterator_type begin_it, end_iterator_type end_it)
319 requires std::sentinel_for<end_iterator_type, begin_iterator_type> &&
429 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
439 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
514 return (*
this)[
size()-1];
521 return (*
this)[
size()-1];
539 constexpr data_type
const &
raw_data() const noexcept
596 return data.max_size();
616 return data.capacity();
639 data.reserve(new_cap);
659 data.shrink_to_fit();
702 return insert(pos, 1, value);
728 data.insert(data.begin() + pos_as_num,
count,
to_rank(value));
730 return begin() + pos_as_num;
757 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
760 requires std::sentinel_for<end_iterator_type, begin_iterator_type> &&
766 auto v = std::ranges::subrange<begin_iterator_type, end_iterator_type>{begin_it, end_it}
767 | views::convert<value_type>
769 data.insert(data.begin() + pos_as_num, seqan3::begin(v), seqan3::end(v));
771 return begin() + pos_as_num;
818 if (begin_it >= end_it)
824 data.erase(data.cbegin() + begin_it_pos,
825 data.cbegin() + end_it_pos);
827 return begin() + begin_it_pos;
851 return erase(pos, pos + 1);
871 data.push_back(
to_rank(value));
991 return data == rhs.data;
997 return data != rhs.data;
1003 return data < rhs.data;
1009 return data > rhs.data;
1015 return data <= rhs.data;
1021 return data >= rhs.data;
1032 template <cereal_archive archive_t>
1033 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:367
reference front() noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:485
typename difference_type< t >::type difference_type_t
Shortcut for seqan3::difference_type (transformation_trait shortcut).
Definition: pre.hpp:166
iterator insert(const_iterator pos, size_type const count, value_type const value)
Inserts count copies of value before position in the container.
Definition: bitcompressed_vector.hpp:724
reference operator[](size_type const i) noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:459
Provides various shortcuts for common std::ranges functions.
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:403
constexpr bool operator!=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: bitcompressed_vector.hpp:995
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:238
constexpr friend void swap(bitcompressed_vector &lhs, bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:972
constexpr void swap(bitcompressed_vector &&rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:955
const_reference operator[](size_type const i) const noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:466
constexpr void swap(bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:949
Provides various type traits.
void assign(other_range_t &&range)
Assign from a different range.
Definition: bitcompressed_vector.hpp:274
typename reference< t >::type reference_t
Shortcut for seqan3::reference (transformation_trait shortcut).
Definition: pre.hpp:77
constexpr bool operator>(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition: bitcompressed_vector.hpp:1007
void pop_back()
Removes the last element of the container.
Definition: bitcompressed_vector.hpp:890
reference back() noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:511
Provides C++20 additions to the <iterator> header.
Provides seqan3::views::convert.
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:361
typename size_type< t >::type size_type_t
Shortcut for seqan3::size_type (transformation_trait shortcut).
Definition: pre.hpp:195
bitcompressed_vector & operator=(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:254
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:142
const auto to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition: to_rank.hpp:67
iterator insert(const_iterator pos, value_type const value)
Inserts value before position in the container.
Definition: bitcompressed_vector.hpp:700
bitcompressed_vector(std::initializer_list< value_type > ilist)
Construct from std::initializer_list.
Definition: bitcompressed_vector.hpp:239
iterator erase(const_iterator begin_it, const_iterator end_it)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:816
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:397
constexpr bool operator<=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition: bitcompressed_vector.hpp:1013
constexpr const data_type & raw_data() const noexcept
Provides direct, unsafe access to underlying data structures.
Definition: bitcompressed_vector.hpp:539
alphabet_type const_reference
Equals the alphabet_type / value_type.
Definition: bitcompressed_vector.hpp:140
iterator insert(const_iterator pos, std::initializer_list< value_type > const &ilist)
Inserts elements from initializer list before position in the container.
Definition: bitcompressed_vector.hpp:792
void push_back(value_type const value)
Appends the given element value to the end of the container.
Definition: bitcompressed_vector.hpp:869
Provides the seqan3::detail::random_access_iterator class.
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:391
constexpr data_type & raw_data() noexcept
Provides direct, unsafe access to underlying data structures.
Definition: bitcompressed_vector.hpp:533
reference_proxy_type reference
A proxy type that enables assignment, if the underlying data structure also provides a proxy.
Definition: bitcompressed_vector.hpp:138
bitcompressed_vector()=default
Defaulted.
difference_type_t< data_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: bitcompressed_vector.hpp:146
Provides seqan3::alphabet_proxy.
constexpr friend void swap(bitcompressed_vector &&lhs, bitcompressed_vector &&rhs) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: bitcompressed_vector.hpp:978
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Assign from pair of iterators.
Definition: bitcompressed_vector.hpp:317
The concept std::common_reference_with<T, U> specifies that two types T and U share a common referenc...
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
~bitcompressed_vector()=default
Defaulted.
void assign(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:338
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: bitcompressed_vector.hpp:657
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:922
bitcompressed_vector(other_range_t &&range)
Construct from a different range.
Definition: bitcompressed_vector.hpp:183
constexpr bitcompressed_vector & operator=(bitcompressed_vector const &)=default
Defaulted.
bitcompressed_vector(begin_iterator_type begin_it, end_iterator_type end_it)
Construct from pair of iterators.
Definition: bitcompressed_vector.hpp:219
constexpr bool operator>=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition: bitcompressed_vector.hpp:1019
bitcompressed_vector(size_type const count, value_type const value)
Construct with count times value.
Definition: bitcompressed_vector.hpp:199
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: bitcompressed_vector.hpp:758
const_reference at(size_type const i) const
Return the i-th element.
Definition: bitcompressed_vector.hpp:435
Subsumes std::semiregular and std::equality_comparable.
Provides seqan3::views::to_char.
Adaptations of concepts from the Ranges TS.
constexpr bool operator<(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition: bitcompressed_vector.hpp:1001
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: bitcompressed_vector.hpp:614
const_reference back() const noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:518
void reserve(size_type const new_cap)
Increase the capacity to a value that's greater or equal to new_cap.
Definition: bitcompressed_vector.hpp:637
void assign(size_type const count, value_type const value)
Assign with count times value.
Definition: bitcompressed_vector.hpp:295
bool empty() const noexcept
Checks whether the container is empty.
Definition: bitcompressed_vector.hpp:559
SeqAn specific customisations in the standard namespace.
constexpr bool operator==(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: bitcompressed_vector.hpp:989
constexpr auto to_rank() const noexcept
Returns the rank.
Definition: alphabet_proxy.hpp:219
Adaptions of concepts from the Cereal library.
detail::random_access_iterator< bitcompressed_vector > iterator
The iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:142
detail::random_access_iterator< bitcompressed_vector const > const_iterator
The const_iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:144
A space-optimised version of std::vector that compresses multiple letters into a single byte.
Definition: bitcompressed_vector.hpp:66
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: bitcompressed_vector.hpp:575
void resize(size_type const count, value_type const value)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:932
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: bitcompressed_vector.hpp:594
void clear() noexcept
Removes all elements from the container.
Definition: bitcompressed_vector.hpp:677
Refines seqan3::alphabet and adds assignability.
reference at(size_type const i)
Return the i-th element.
Definition: bitcompressed_vector.hpp:425
size_type_t< data_type > size_type
An unsigned integer type (usually std::size_t)
Definition: bitcompressed_vector.hpp:148
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:134
alphabet_type value_type
Equals the alphabet_type.
Definition: bitcompressed_vector.hpp:136
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets.
Definition: alphabet_proxy.hpp:59
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:373
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:849
const_reference front() const noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:492
Provides seqan3::views::to_rank.