15 #include <type_traits> 17 #include <sdsl/int_vector.hpp> 35 class debug_stream_type;
65 template <Alphabet alphabet_type>
67 requires std::is_same_v<alphabet_type, std::remove_reference_t<alphabet_type>>
73 static constexpr
size_t bits_per_letter =
std::ceil(std::log2(alphabet_size<alphabet_type>));
75 static_assert(bits_per_letter <= 64,
"Alphabet must be representable in at most 64bit.");
78 using data_type = sdsl::int_vector<bits_per_letter>;
85 class reference_proxy_type :
public alphabet_proxy<reference_proxy_type, alphabet_type>
95 static uint8_t constexpr safe_bits_per_letter = (bits_per_letter == 8 ||
96 bits_per_letter == 16 ||
97 bits_per_letter == 32) ? 64 : bits_per_letter;
100 using internal_proxy_type = sdsl::int_vector_reference<sdsl::int_vector<safe_bits_per_letter>>;
102 ranges::semiregular_t<internal_proxy_type> internal_proxy;
105 constexpr
void on_update() noexcept
107 internal_proxy.get() =
static_cast<base_t &
>(*this).to_rank();
112 using base_t::operator=;
117 constexpr reference_proxy_type() noexcept =
default;
118 constexpr reference_proxy_type(reference_proxy_type
const &) noexcept =
default;
119 constexpr reference_proxy_type(reference_proxy_type &&) noexcept =
default;
120 constexpr reference_proxy_type &
operator=(reference_proxy_type
const &) noexcept =
default;
121 constexpr reference_proxy_type &
operator=(reference_proxy_type &&) noexcept =
default;
122 ~reference_proxy_type() noexcept =
default;
125 reference_proxy_type(internal_proxy_type
const &
internal) noexcept :
126 internal_proxy{
internal}
128 static_cast<base_t &
>(*this).assign_rank(
internal);
136 template <
typename t>
137 requires std::is_same_v<value_type_t<remove_cvref_t<t>>, alphabet_type>
138 static constexpr
bool has_same_value_type_v =
true;
150 reference_proxy_type>;
154 using iterator = detail::random_access_iterator<bitcompressed_vector>;
156 using const_iterator = detail::random_access_iterator<bitcompressed_vector const>;
165 using allocator_type = void;
191 template <std::ranges::InputRange other_range_t>
193 requires has_same_value_type_v<other_range_t>
230 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
284 template <std::ranges::InputRange other_range_t>
327 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
328 void assign(begin_iterator_type begin_it, end_iterator_type end_it)
439 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
449 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
524 return (*
this)[
size()-1];
531 return (*
this)[
size()-1];
585 return data.max_size();
605 return data.capacity();
628 data.reserve(new_cap);
648 data.shrink_to_fit();
691 return insert(pos, 1, value);
717 data.insert(data.begin() + pos_as_num, count,
to_rank(value));
719 return begin() + pos_as_num;
746 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
755 | view::convert<value_type>
759 return begin() + pos_as_num;
806 if (begin_it >= end_it)
812 data.erase(data.cbegin() + begin_it_pos,
813 data.cbegin() + end_it_pos);
815 return begin() + begin_it_pos;
839 return erase(pos, pos + 1);
859 data.push_back(
to_rank(value));
923 data.resize(count,
to_rank(value));
980 return data == rhs.data;
986 return data != rhs.data;
992 return data < rhs.data;
998 return data > rhs.data;
1004 return data <= rhs.data;
1010 return data >= rhs.data;
1021 template <CerealArchive archive_t>
1022 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
void pop_back()
Removes the last element of the container.
Definition: bitcompressed_vector.hpp:878
reference front() noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:495
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:401
::ranges::subrange< it_t, sen_t, k > subrange
Create a view from a pair of iterator and sentinel.
Definition: ranges:339
void assign(other_range_t &&range)
Assign from a different range.
Definition: bitcompressed_vector.hpp:285
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:207
void clear() noexcept
Removes all elements from the container.
Definition: bitcompressed_vector.hpp:666
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets...
Definition: alphabet_proxy.hpp:131
constexpr void swap(bitcompressed_vector &&rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:943
void push_back(value_type const value)
Appends the given element value to the end of the container.
Definition: bitcompressed_vector.hpp:857
Provides C++20 additions to the <iterator> header.
Provides various shortcuts for common std::ranges functions.
constexpr bool operator>(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition: bitcompressed_vector.hpp:996
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:103
const_reference back() const noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:528
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:413
constexpr bool operator!=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: bitcompressed_vector.hpp:984
~bitcompressed_vector()=default
Defaulted.
SeqAn specific customisations in the standard namespace.
constexpr bool operator<(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition: bitcompressed_vector.hpp:990
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:747
Provides seqan3::view::convert.
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:583
Provides the seqan3::detail::random_access_iterator class.
constexpr bool operator<=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition: bitcompressed_vector.hpp:1002
The main SeqAn3 namespace.
size_type_t< data_type > size_type
An unsigned integer type (usually std::size_t)
Definition: bitcompressed_vector.hpp:160
reference at(size_type const i)
Return the i-th element.
Definition: bitcompressed_vector.hpp:435
iterator insert(const_iterator pos, value_type const value)
Inserts value before position in the container.
Definition: bitcompressed_vector.hpp:689
typename difference_type< t >::type difference_type_t
Shortcut for seqan3::difference_type (TransformationTrait shortcut).
Definition: pre.hpp:166
reference back() noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:521
detail::random_access_iterator< bitcompressed_vector > iterator
The iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:154
friend constexpr void swap(bitcompressed_vector &&lhs, bitcompressed_vector &&rhs) noexcept
Definition: bitcompressed_vector.hpp:967
bitcompressed_vector(std::initializer_list< value_type > ilist)
Construct from std::initializer_list.
Definition: bitcompressed_vector.hpp:250
void assign(size_type const count, value_type const value)
Assign with count times value.
Definition: bitcompressed_vector.hpp:306
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:407
constexpr bool operator==(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: bitcompressed_vector.hpp:978
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:780
Provides seqan3::view::to_rank.
reference operator[](size_type const i) noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:469
Provides various type traits.
constexpr bitcompressed_vector & operator=(bitcompressed_vector const &)=default
Defaulted.
const_reference at(size_type const i) const
Return the i-th element.
Definition: bitcompressed_vector.hpp:445
const_reference operator[](size_type const i) const noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:476
Adaptations of concepts from the Ranges TS.
bitcompressed_vector(other_range_t &&range)
Construct from a different range.
Definition: bitcompressed_vector.hpp:195
Free function/type trait wrappers for alphabets with member functions/types.
Refines seqan3::Alphabet and adds assignability.
detail::random_access_iterator< bitcompressed_vector const > const_iterator
The const_iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:156
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:174
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Assign from pair of iterators.
Definition: bitcompressed_vector.hpp:328
alphabet_type value_type
Equals the alphabet_type.
Definition: bitcompressed_vector.hpp:146
Adaptions of concepts from the Cereal library.
The concept std::CommonReference<T, U> specifies that two types T and U share a common reference type...
const_reference front() const noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:502
friend constexpr void swap(bitcompressed_vector &lhs, bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:961
iterator erase(const_iterator begin_it, const_iterator end_it)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:804
bitcompressed_vector(begin_iterator_type begin_it, end_iterator_type end_it)
Construct from pair of iterators.
Definition: bitcompressed_vector.hpp:231
typename size_type< t >::type size_type_t
Shortcut for seqan3::size_type (TransformationTrait shortcut).
Definition: pre.hpp:195
bitcompressed_vector(size_type const count, value_type const value)
Construct with count times value.
Definition: bitcompressed_vector.hpp:211
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:626
bitcompressed_vector & operator=(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:265
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:713
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: bitcompressed_vector.hpp:603
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:383
A space-optimised version of std::vector that compresses multiple letters into a single byte...
Definition: bitcompressed_vector.hpp:69
Provides seqan3::view::to_char.
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: bitcompressed_vector.hpp:646
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: bitcompressed_vector.hpp:564
constexpr bool operator>=(bitcompressed_vector const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition: bitcompressed_vector.hpp:1008
typename reference< t >::type reference_t
Shortcut for seqan3::reference (TransformationTrait shortcut).
Definition: pre.hpp:77
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:910
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:371
bitcompressed_vector()=default
Defaulted.
difference_type_t< data_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: bitcompressed_vector.hpp:158
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:377
bool empty() const noexcept
Checks whether the container is empty.
Definition: bitcompressed_vector.hpp:548
alphabet_type const_reference
Equals the alphabet_type / value_type.
Definition: bitcompressed_vector.hpp:152
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:179
void assign(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:348
void resize(size_type const count, value_type const value)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:920
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition: to_rank.hpp:68
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:837
constexpr void swap(bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:937