26#include <cereal/types/vector.hpp>
29namespace seqan3::detail
38 t operator()(t
const && arg)
const
40 return std::move(arg);
45 t
const & operator()(t
const & arg)
const
102template <
typename value_type,
bool const_>
103struct concatenated_sequences_reference_proxy :
105 decltype(std::declval<value_type const &>() | detail::as_const | views::slice(0,1)),
106 decltype(std::declval<value_type &>() | views::slice(0,1))>
111 decltype(std::declval<value_type const &>() | detail::as_const |
views::slice(0,1)),
112 decltype(std::declval<value_type &>() |
views::slice(0,1))>;
115 using base_t::base_t;
118 concatenated_sequences_reference_proxy(base_t && rhs) : base_t{
std::move(rhs)} {}
121 operator value_type()
const
125 std::ranges::copy(*
this, std::ranges::begin(ret));
181template <
typename inner_type,
186 std::is_same_v<std::ranges::range_size_t<inner_type>, std::ranges::range_value_t<data_delimiters_type>>
195 data_delimiters_type data_delimiters{0};
215 using reference = detail::concatenated_sequences_reference_proxy<value_type, false>;
222 using const_reference = detail::concatenated_sequences_reference_proxy<value_type, true>;
229 using iterator = detail::random_access_iterator<concatenated_sequences>;
236 using const_iterator = detail::random_access_iterator<concatenated_sequences const>;
250 using size_type = std::ranges::range_size_t<data_delimiters_type>;
255 using allocator_type = void;
266 template <std::ranges::range t>
269 return range_dimension_v<t> == range_dimension_v<value_type> &&
270 std::convertible_to<std::ranges::range_reference_t<t>, std::ranges::range_value_t<value_type>>;
273 static constexpr bool is_compatible_with_value_type_aux(...)
285 template <std::ranges::range t>
294 template <
typename t>
296 requires is_compatible_with_value_type<std::iter_reference_t<t>>
306 template <std::ranges::range t>
308 requires is_compatible_with_value_type<std::ranges::range_reference_t<t>>
345 template <std::ranges::input_range rng_of_rng_type>
348 requires range_value_t_is_compatible_with_value_type<rng_of_rng_type>
351 if constexpr (std::ranges::sized_range<rng_of_rng_type>)
354 for (
auto && val : rng_of_rng)
356 data_values.insert(data_values.end(), val.begin(), val.end());
357 data_delimiters.push_back(data_delimiters.back() + val.size());
376 template <std::ranges::forward_range rng_type>
379 requires is_compatible_with_value_type<rng_type>
406 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
409 requires std::sized_sentinel_for<end_iterator_type, begin_iterator_type> &&
410 iter_value_t_is_compatible_with_value_type<begin_iterator_type>
430 template <std::ranges::forward_range value_type_t = value_type>
432 requires is_compatible_with_value_type<value_type_t>
453 template <std::ranges::forward_range value_type_t>
456 requires is_compatible_with_value_type<value_type_t>
478 template <std::ranges::input_range rng_of_rng_type>
479 void assign(rng_of_rng_type && rng_of_rng)
481 requires range_value_t_is_compatible_with_value_type<rng_of_rng_type>
503 template <std::ranges::forward_range rng_type>
506 requires (is_compatible_with_value_type<rng_type>)
530 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
531 void assign(begin_iterator_type begin_it, end_iterator_type end_it)
533 requires iter_value_t_is_compatible_with_value_type<begin_iterator_type> &&
534 std::sized_sentinel_for<end_iterator_type, begin_iterator_type>
555 template <std::ranges::forward_range rng_type = value_type>
558 requires is_compatible_with_value_type<rng_type>
656 throw std::out_of_range{
"Trying to access element behind the last in concatenated_sequences."};
665 throw std::out_of_range{
"Trying to access element behind the last in concatenated_sequences."};
688 return data_values |
views::slice(data_delimiters[i], data_delimiters[i+1]);
695 return data_values | detail::as_const |
views::slice(data_delimiters[i], data_delimiters[i+1]);
742 return (*
this)[
size()-1];
749 return (*
this)[
size()-1];
788 return {data_values, data_delimiters};
835 return data_delimiters.size() - 1;
856 return data_delimiters.max_size() - 1;
878 return data_delimiters.capacity();
905 data_delimiters.reserve(new_cap + 1);
929 data_values.shrink_to_fit();
930 data_delimiters.shrink_to_fit();
952 return data_values.size();
970 return data_values.capacity();
995 data_values.reserve(new_cap);
1018 data_values.clear();
1019 data_delimiters.clear();
1020 data_delimiters.push_back(0);
1049 template <std::ranges::forward_range rng_type>
1052 requires is_compatible_with_value_type<rng_type>
1055 return insert(pos, 1, std::forward<rng_type>(value));
1085 template <std::ranges::forward_range rng_type>
1088 requires is_compatible_with_value_type<rng_type>
1094 return begin() + pos_as_num;
1106 if constexpr (std::ranges::sized_range<rng_type>)
1109 value_len =
std::distance(std::ranges::begin(value), std::ranges::end(value));
1111 data_values.reserve(data_values.size() +
count * value_len);
1113 | std::views::common;
1115 data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
1116 std::ranges::begin(placeholder),
1117 std::ranges::end(placeholder));
1120 size_t i = data_delimiters[pos_as_num];
1121 for (
size_t j = 0; j <
count; ++j)
1122 for (
auto && v : value)
1123 data_values[i++] = v;
1125 data_delimiters.reserve(data_values.size() +
count);
1126 data_delimiters.insert(data_delimiters.begin() + pos_as_num,
1128 *(data_delimiters.begin() + pos_as_num));
1132 data_delimiters[pos_as_num + i + 1] += value_len * (i + 1);
1137 data_delimiters.end(),
1138 [full_len = value_len *
count] (
auto & d) { d += full_len; });
1140 return begin() + pos_as_num;
1169 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
1172 requires iter_value_t_is_compatible_with_value_type<begin_iterator_type> &&
1173 std::sized_sentinel_for<end_iterator_type, begin_iterator_type>
1178 if (last - first == 0)
1179 return begin() + pos_as_num;
1182 std::ranges::subrange<begin_iterator_type, end_iterator_type>(first,
1184 std::ranges::distance(first, last));
1186 data_delimiters.reserve(data_values.size() + ilist.size());
1187 data_delimiters.insert(data_delimiters.begin() + pos_as_num,
1189 *(data_delimiters.begin() + pos_as_num));
1194 for (
size_type i = 0; i < ilist.size(); ++i, ++first)
1196 full_len += std::ranges::distance(*first);
1197 data_delimiters[pos_as_num + 1 + i] += full_len;
1201 auto placeholder =
views::repeat_n(std::ranges::range_value_t<value_type>{}, full_len)
1202 | std::views::common;
1204 data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
1205 std::ranges::begin(placeholder),
1206 std::ranges::end(placeholder));
1209 size_t i = data_delimiters[pos_as_num];
1210 for (
auto && v0 : ilist)
1211 for (
auto && v1 : v0)
1212 data_values[i++] = v1;
1217 std::for_each(data_delimiters.begin() + pos_as_num + ilist.size() + 1,
1218 data_delimiters.end(),
1219 [full_len] (
auto & d) { d += full_len; });
1221 return begin() + pos_as_num;
1245 template <std::ranges::forward_range rng_type>
1248 requires is_compatible_with_value_type<rng_type>
1251 return insert(pos, ilist.begin(), ilist.end());
1278 if (last - first == 0)
1279 return begin() + dist;
1285 for (; first != last; ++first)
1288 data_values.erase(data_values.begin() + data_delimiters[distf],
1289 data_values.begin() + data_delimiters[dist]);
1291 data_delimiters.erase(data_delimiters.begin() + distf + 1,
1292 data_delimiters.begin() + dist + 1);
1297 data_delimiters.end(),
1298 [sum_size] (
auto & d) { d -= sum_size; });
1299 return begin() + dist;
1324 return erase(pos, pos + 1);
1345 template <std::ranges::forward_range rng_type>
1348 requires is_compatible_with_value_type<rng_type>
1351 data_values.insert(data_values.end(), std::ranges::begin(value), std::ranges::end(value));
1376 auto back_length = data_delimiters[
size()] - data_delimiters[
size() - 1];
1377 data_values.resize(data_values.size() - back_length);
1378 data_delimiters.pop_back();
1412 data_delimiters.resize(
count + 1, data_delimiters.back());
1413 data_values.resize(data_delimiters.back());
1421 template <std::ranges::forward_range rng_type>
1424 requires is_compatible_with_value_type<rng_type>
1451 std::swap(data_values, rhs.data_values);
1452 std::swap(data_delimiters, rhs.data_delimiters);
1458 std::swap(data_values, rhs.data_values);
1459 std::swap(data_delimiters, rhs.data_delimiters);
1473 return raw_data() == rhs.raw_data();
1482 return raw_data() != rhs.raw_data();
1491 return raw_data() < rhs.raw_data();
1500 return raw_data() > rhs.raw_data();
1509 return raw_data() <= rhs.raw_data();
1518 return raw_data() >= rhs.raw_data();
1529 template <cereal_archive archive_t>
1530 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
1532 archive(data_values, data_delimiters);
Adaptions of concepts from the Cereal library.
Container that stores sequences concatenated internally.
Definition: concatenated_sequences.hpp:189
iterator erase(const_iterator first, const_iterator last)
Removes specified elements from the container.
Definition: concatenated_sequences.hpp:1274
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: concatenated_sequences.hpp:854
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: concatenated_sequences.hpp:927
size_type concat_size() const noexcept
Returns the cumulative size of all elements in the container.
Definition: concatenated_sequences.hpp:950
concatenated_sequences(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:377
void assign(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:479
constexpr concatenated_sequences & operator=(concatenated_sequences &&)=default
Default constructors.
constexpr bool operator<(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition: concatenated_sequences.hpp:1489
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: concatenated_sequences.hpp:833
size_type concat_capacity() const noexcept
Returns the concatenated size the container has currently allocated space for.
Definition: concatenated_sequences.hpp:968
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:531
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:616
constexpr concatenated_sequences(concatenated_sequences &&)=default
Default constructors.
iterator insert(const_iterator pos, rng_type &&value)
Inserts value before position in the container.
Definition: concatenated_sequences.hpp:1050
concatenated_sequences(std::initializer_list< value_type_t > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:434
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: concatenated_sequences.hpp:1322
const_reference concat() const
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:774
reference front()
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:712
constexpr bool operator>=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition: concatenated_sequences.hpp:1516
constexpr concatenated_sequences(concatenated_sequences const &)=default
Default constructors.
constexpr bool operator==(concatenated_sequences const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: concatenated_sequences.hpp:1471
static constexpr bool iter_value_t_is_compatible_with_value_type
Whether a type is compatible with this class.
Definition: concatenated_sequences.hpp:298
reference at(size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:652
const_reference front() const
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:719
constexpr void swap(concatenated_sequences &rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1449
constexpr void swap(concatenated_sequences &&rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1456
concatenated_sequences()=default
Default constructors.
const_reference operator[](size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:692
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: concatenated_sequences.hpp:1409
static constexpr bool range_value_t_is_compatible_with_value_type
Whether a type is compatible with this class.
Definition: concatenated_sequences.hpp:310
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:622
void push_back(rng_type &&value)
Appends the given element value to the end of the container.
Definition: concatenated_sequences.hpp:1346
bool empty() const noexcept
Checks whether the container is empty.
Definition: concatenated_sequences.hpp:815
constexpr bool operator!=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: concatenated_sequences.hpp:1480
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:590
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:584
detail::concatenated_sequences_reference_proxy< value_type, false > reference
A proxy of type views::slice that represents the range on the concatenated vector.
Definition: concatenated_sequences.hpp:215
std::ranges::range_size_t< data_delimiters_type > size_type
An unsigned integer type (usually std::size_t)
Definition: concatenated_sequences.hpp:250
const_reference back() const
Return the last element as a view.
Definition: concatenated_sequences.hpp:746
concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:407
std::pair< decltype(data_values) &, decltype(data_delimiters) & > raw_data()
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:786
~concatenated_sequences()=default
Default constructors.
reference back()
Return the last element as a view.
Definition: concatenated_sequences.hpp:739
void assign(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:504
detail::concatenated_sequences_reference_proxy< value_type, true > const_reference
An immutable proxy of type views::slice that represents the range on the concatenated vector.
Definition: concatenated_sequences.hpp:222
constexpr bool operator>(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition: concatenated_sequences.hpp:1498
void clear() noexcept
Removes all elements from the container.
Definition: concatenated_sequences.hpp:1016
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:628
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: concatenated_sequences.hpp:876
detail::random_access_iterator< concatenated_sequences const > const_iterator
The const iterator type of this container (a random access iterator).
Definition: concatenated_sequences.hpp:236
iterator insert(const_iterator pos, std::initializer_list< rng_type > const &ilist)
Inserts elements from initializer list before position in the container.
Definition: concatenated_sequences.hpp:1246
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:596
concatenated_sequences & operator=(std::initializer_list< value_type_t > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:454
std::ranges::range_difference_t< data_delimiters_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: concatenated_sequences.hpp:243
iterator insert(const_iterator pos, begin_iterator_type first, end_iterator_type last)
Inserts elements from range [first, last) before position in the container.
Definition: concatenated_sequences.hpp:1170
detail::random_access_iterator< concatenated_sequences > iterator
The iterator type of this container (a random access iterator).
Definition: concatenated_sequences.hpp:229
const_reference at(size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:661
void resize(size_type const count, rng_type &&value)
Resizes the container to contain count elements.
Definition: concatenated_sequences.hpp:1422
std::pair< decltype(data_values) const &, decltype(data_delimiters) const & > raw_data() const
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:792
iterator insert(const_iterator pos, size_type const count, rng_type &&value)
Inserts count copies of value before position in the container.
Definition: concatenated_sequences.hpp:1086
void concat_reserve(size_type const new_cap)
Increase the concat_capacity() to a value that's greater or equal to new_cap.
Definition: concatenated_sequences.hpp:993
static constexpr bool is_compatible_with_value_type
Whether a type is compatible with this class's value_type or reference type.
Definition: concatenated_sequences.hpp:286
void pop_back()
Removes the last element of the container.
Definition: concatenated_sequences.hpp:1373
reference concat()
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:768
concatenated_sequences(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:346
void reserve(size_type const new_cap)
Increase the capacity to a value that's greater or equal to new_cap.
Definition: concatenated_sequences.hpp:903
void assign(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:556
constexpr concatenated_sequences & operator=(concatenated_sequences const &)=default
Default constructors.
reference operator[](size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:685
constexpr bool operator<=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition: concatenated_sequences.hpp:1507
decltype(detail::transform< trait_t >(list_t{})) transform
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
Definition: traits.hpp:471
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:169
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:183
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:91
A more refined container concept than seqan3::random_access_container.
The <iterator> header from C++20's standard library.
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
SeqAn specific customisations in the standard namespace.
The <ranges> header from C++20's standard library.
Provides seqan3::views::repeat_n.
Provides seqan3::views::slice.
Adaptations of concepts from the standard library.