44 #include <range/v3/iterator_range.hpp> 46 #include <sdsl/int_vector.hpp> 65 class debug_stream_type;
95 template <alphabet_concept alphabet_type>
97 requires std::is_same_v<alphabet_type, std::remove_reference_t<alphabet_type>>
103 static constexpr
size_t bits_per_letter = std::ceil(std::log2(alphabet_size_v<alphabet_type>));
105 static_assert(bits_per_letter <= 64,
"Alphabet must be representable in at most 64bit.");
108 using data_type = sdsl::int_vector<bits_per_letter>;
115 class reference_proxy_type :
public alphabet_proxy<reference_proxy_type, alphabet_type>
125 static uint8_t constexpr safe_bits_per_letter = (bits_per_letter == 8 ||
126 bits_per_letter == 16 ||
127 bits_per_letter == 32) ? 64 : bits_per_letter;
130 using internal_proxy_type = sdsl::int_vector_reference<sdsl::int_vector<safe_bits_per_letter>>;
132 ranges::semiregular_t<internal_proxy_type> internal_proxy;
135 constexpr
void on_update() noexcept
137 internal_proxy.get() =
static_cast<base_t &
>(*this).to_rank();
142 using base_t::operator=;
148 constexpr reference_proxy_type() noexcept : base_t{} {}
149 constexpr reference_proxy_type(reference_proxy_type
const &) =
default;
150 constexpr reference_proxy_type(reference_proxy_type &&) =
default;
151 constexpr reference_proxy_type & operator=(reference_proxy_type
const &) =
default;
152 constexpr reference_proxy_type & operator=(reference_proxy_type &&) =
default;
153 ~reference_proxy_type() =
default;
156 reference_proxy_type(internal_proxy_type
const &
internal) noexcept :
157 internal_proxy{
internal}
159 static_cast<base_t &
>(*this).assign_rank(
internal);
167 template <
typename t>
168 requires std::is_same_v<value_type_t<remove_cvref_t<t>>, alphabet_type>
169 static constexpr
bool has_same_value_type_v =
true;
179 using reference = std::conditional_t<std::is_lvalue_reference_v<reference_t<data_type>>,
181 reference_proxy_type>;
185 using iterator = detail::random_access_iterator<bitcompressed_vector>;
187 using const_iterator = detail::random_access_iterator<bitcompressed_vector const>;
196 using allocator_type = void;
222 template <std::ranges::InputRange other_range_t>
224 requires has_same_value_type_v<other_range_t>
261 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
298 assign(std::begin(ilist), std::end(ilist));
315 template <std::ranges::InputRange other_range_t>
358 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
359 void assign(begin_iterator_type begin_it, end_iterator_type end_it)
361 requires std::CommonReference<value_type_t<begin_iterator_type>,
value_type>
379 void assign(std::initializer_list<value_type> ilist)
381 assign(std::begin(ilist), std::end(ilist));
470 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
480 throw std::out_of_range{
"Trying to access element behind the last in bitcompressed_vector."};
555 return (*
this)[
size()-1];
562 return (*
this)[
size()-1];
616 return data.max_size();
636 return data.capacity();
659 data.reserve(new_cap);
679 data.shrink_to_fit();
722 return insert(pos, 1, value);
746 auto const pos_as_num = std::distance(
cbegin(), pos);
748 data.insert(data.begin() + pos_as_num, count,
to_rank(value));
750 return begin() + pos_as_num;
777 template <std::ForwardIterator begin_iterator_type, std::Sentinel<begin_iterator_type> end_iterator_type>
780 requires std::CommonReference<value_type_t<begin_iterator_type>,
value_type>
783 auto const pos_as_num = std::distance(
cbegin(), pos);
786 data.insert(data.begin() + pos_as_num, seqan3::begin(v), seqan3::end(v));
788 return begin() + pos_as_num;
811 return insert(pos, ilist.begin(), ilist.end());
835 if (begin_it >= end_it)
838 auto const begin_it_pos = std::distance(
cbegin(), begin_it);
839 auto const end_it_pos = std::distance(
cbegin(), end_it);
841 data.erase(data.cbegin() + begin_it_pos,
842 data.cbegin() + end_it_pos);
844 return begin() + begin_it_pos;
868 return erase(pos, pos + 1);
888 data.push_back(
to_rank(value));
952 data.resize(count,
to_rank(value));
968 std::swap(data, rhs.data);
974 std::swap(data, rhs.data);
1006 return data == rhs.data;
1011 return data != rhs.data;
1016 return data < rhs.data;
1021 return data > rhs.data;
1026 return data <= rhs.data;
1031 return data >= rhs.data;
1042 template <cereal_archive_concept archive_t>
1043 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
void pop_back()
Removes the last element of the container.
Definition: bitcompressed_vector.hpp:907
reference front() noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:526
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:432
Free function/metafunction wrappers for alphabets with member functions/types.
void assign(other_range_t &&range)
Assign from a different range.
Definition: bitcompressed_vector.hpp:316
::ranges::iterator_range iterator_range
Alias for ranges::iterator_range. Iterator adaptor for a Range type.
Definition: ranges:235
void clear() noexcept
Removes all elements from the container.
Definition: bitcompressed_vector.hpp:697
A CRTP-base that eases the definition of proxy types returned in place of regular alphabets...
Definition: alphabet_proxy.hpp:152
constexpr void swap(bitcompressed_vector &&rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:972
void push_back(value_type const value)
Appends the given element value to the end of the container.
Definition: bitcompressed_vector.hpp:886
Provides C++20 additions to the <iterator> header.
Contains various shortcuts for common std::ranges functions.
const_reference back() const noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:559
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:444
SeqAn specific customisations in the standard namespace.
Definition: align_result.hpp:221
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:778
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:614
Provides the seqan3::detail::random_access_iterator class.
The generic alphabet concept that covers most data types used in ranges.This is the core alphabet con...
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
size_type_t< data_type > size_type
An unsigned integer type (usually std::size_t)
Definition: bitcompressed_vector.hpp:191
reference at(size_type const i)
Return the i-th element.
Definition: bitcompressed_vector.hpp:466
iterator insert(const_iterator pos, value_type const value)
Inserts value before position in the container.
Definition: bitcompressed_vector.hpp:720
reference back() noexcept
Return the last element.
Definition: bitcompressed_vector.hpp:552
detail::random_access_iterator< bitcompressed_vector > iterator
The iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:185
friend constexpr void swap(bitcompressed_vector &&lhs, bitcompressed_vector &&rhs) noexcept
Definition: bitcompressed_vector.hpp:996
bitcompressed_vector(std::initializer_list< value_type > ilist)
Construct from std::initializer_list.
Definition: bitcompressed_vector.hpp:281
void assign(size_type const count, value_type const value)
Assign with count times value.
Definition: bitcompressed_vector.hpp:337
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: bitcompressed_vector.hpp:438
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:809
Provides seqan3::view::to_rank.
reference operator[](size_type const i) noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:500
constexpr alphabet_type & assign_rank(alphabet_type &alph, underlying_rank_t< alphabet_type > const rank) requires requires(alphabet_type alph)
Implementation of seqan3::semi_alphabet_concept::assign_rank() that delegates to a member function...
Definition: member_exposure.hpp:110
const_reference at(size_type const i) const
Return the i-th element.
Definition: bitcompressed_vector.hpp:476
const_reference operator[](size_type const i) const noexcept
Return the i-th element.
Definition: bitcompressed_vector.hpp:507
Adaptations of concepts from the Ranges TS.
The concept std::CommonReference<T, U> specifies that two types T and U share a common reference type...
bitcompressed_vector(other_range_t &&range)
Construct from a different range.
Definition: bitcompressed_vector.hpp:226
Free function/metafunction wrappers for alphabets with member functions/types.
detail::random_access_iterator< bitcompressed_vector const > const_iterator
The const_iterator type of this container (a random access iterator).
Definition: bitcompressed_vector.hpp:187
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Assign from pair of iterators.
Definition: bitcompressed_vector.hpp:359
alphabet_type value_type
Equals the alphabet_type.
Definition: bitcompressed_vector.hpp:177
Adaptions of concepts from the Cereal library.
const_reference front() const noexcept
Return the first element. Calling front on an empty container is undefined.
Definition: bitcompressed_vector.hpp:533
friend constexpr void swap(bitcompressed_vector &lhs, bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:990
iterator erase(const_iterator begin_it, const_iterator end_it)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:833
bitcompressed_vector(begin_iterator_type begin_it, end_iterator_type end_it)
Construct from pair of iterators.
Definition: bitcompressed_vector.hpp:262
bitcompressed_vector(size_type const count, value_type const value)
Construct with count times value.
Definition: bitcompressed_vector.hpp:242
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:657
bitcompressed_vector & operator=(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:296
Provides C++20 additions to the type_traits header.
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:744
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: bitcompressed_vector.hpp:634
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:414
A space-optimised version of std::vector that compresses multiple letters into a single byte...
Definition: bitcompressed_vector.hpp:99
Provides seqan3::view::to_char.
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: bitcompressed_vector.hpp:677
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: bitcompressed_vector.hpp:595
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:939
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:402
difference_type_t< data_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: bitcompressed_vector.hpp:189
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: bitcompressed_vector.hpp:408
bool empty() const noexcept
Checks whether the container is empty.
Definition: bitcompressed_vector.hpp:579
alphabet_type const_reference
Equals the alphabet_type / value_type.
Definition: bitcompressed_vector.hpp:183
constexpr underlying_rank_t< alphabet_type > to_rank(alphabet_type const alph) requires requires(alphabet_type alph)
Implementation of seqan3::semi_alphabet_concept::to_rank() that delegates to a member function...
Definition: member_exposure.hpp:97
void assign(std::initializer_list< value_type > ilist)
Assign from std::initializer_list.
Definition: bitcompressed_vector.hpp:379
void resize(size_type const count, value_type const value)
Resizes the container to contain count elements.
Definition: bitcompressed_vector.hpp:949
std::conditional_t< std::is_lvalue_reference_v< reference_t< data_type > >, reference_t< data_type >, reference_proxy_type > reference
A proxy type that enables assignment, if the underlying data structure also provides a proxy...
Definition: bitcompressed_vector.hpp:181
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition: to_rank.hpp:90
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: bitcompressed_vector.hpp:866
constexpr void swap(bitcompressed_vector &rhs) noexcept
Swap contents with another instance.
Definition: bitcompressed_vector.hpp:966