23# include <cereal/types/vector.hpp>
79template <
typename underlying_container_type,
83 && std::is_same_v<std::ranges::range_size_t<underlying_container_type>,
84 std::ranges::range_value_t<data_delimiters_type>>
120 decltype(std::declval<std::decay_t<underlying_container_type>
const &>() |
views::slice(0, 1));
127 using iterator = detail::random_access_iterator<concatenated_sequences>;
134 using const_iterator = detail::random_access_iterator<concatenated_sequences const>;
148 using size_type = std::ranges::range_size_t<data_delimiters_type>;
159 template <std::ranges::range t>
163 && std::convertible_to<std::ranges::range_reference_t<t>, std::ranges::range_value_t<value_type>>;
178 template <std::ranges::range t>
187 template <
typename t>
197 template <std::ranges::range t>
234 template <std::ranges::input_range rng_of_rng_type>
238 if constexpr (std::ranges::sized_range<rng_of_rng_type>)
239 data_delimiters.reserve(std::ranges::size(
rng_of_rng) + 1);
243 data_values.insert(data_values.end(),
val.begin(),
val.end());
244 data_delimiters.push_back(data_delimiters.back() +
val.size());
263 template <std::ranges::forward_range rng_type>
271 insert(
cend(), count, std::forward<rng_type>(value));
291 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
293 requires std::sized_sentinel_for<end_iterator_type, begin_iterator_type>
313 template <std::ranges::forward_range value_type_t = value_type>
334 template <std::ranges::forward_range value_type_t>
357 template <std::ranges::input_range rng_of_rng_type>
380 template <std::ranges::forward_range rng_type>
405 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
408 && std::sized_sentinel_for<end_iterator_type, begin_iterator_type>
428 template <std::ranges::forward_range rng_type = value_type>
527 throw std::out_of_range{
"Trying to access element behind the last in concatenated_sequences."};
536 throw std::out_of_range{
"Trying to access element behind the last in concatenated_sequences."};
560 return data_values |
views::slice(data_delimiters[
i], data_delimiters[
i + 1]);
568 return data_values |
views::slice(data_delimiters[
i], data_delimiters[
i + 1]);
615 return (*
this)[
size() - 1];
622 return (*
this)[
size() - 1];
661 return {data_values, data_delimiters};
667 return {data_values, data_delimiters};
708 return data_delimiters.size() - 1;
729 return data_delimiters.max_size() - 1;
751 return data_delimiters.capacity();
778 data_delimiters.reserve(
new_cap + 1);
802 data_values.shrink_to_fit();
803 data_delimiters.shrink_to_fit();
825 return data_values.size();
843 return data_values.capacity();
890 data_delimiters.clear();
891 data_delimiters.push_back(0);
920 template <std::ranges::forward_range rng_type>
924 return insert(pos, 1, std::forward<rng_type>(value));
954 template <std::ranges::forward_range rng_type>
973 if constexpr (std::ranges::sized_range<rng_type>)
978 data_values.reserve(data_values.size() + count *
value_len);
983 data_values.insert(data_values.begin() + data_delimiters[
pos_as_num],
990 for (
size_t j = 0;
j < count; ++
j)
991 for (
auto &&
v : value)
992 data_values[
i++] =
v;
994 data_delimiters.reserve(data_values.size() + count);
995 data_delimiters.insert(data_delimiters.begin() +
pos_as_num, count, *(data_delimiters.begin() +
pos_as_num));
1004 data_delimiters.end(),
1039 template <std::forward_iterator begin_iterator_type,
typename end_iterator_type>
1042 && std::sized_sentinel_for<end_iterator_type, begin_iterator_type>
1046 if (last - first == 0)
1050 std::ranges::subrange<begin_iterator_type, end_iterator_type>(first,
1052 std::ranges::distance(first, last));
1054 data_delimiters.reserve(data_values.size() +
ilist.size());
1055 data_delimiters.insert(data_delimiters.begin() +
pos_as_num,
1063 full_len += std::ranges::distance(*first);
1070 data_values.insert(data_values.begin() + data_delimiters[
pos_as_num],
1077 for (
auto &&
v1 :
v0)
1078 data_values[
i++] =
v1;
1083 data_delimiters.end(),
1113 template <std::ranges::forward_range rng_type>
1144 if (last - first == 0)
1151 for (; first != last; ++first)
1152 sum_size += std::ranges::size(*first);
1154 data_values.erase(data_values.begin() + data_delimiters[
distf], data_values.begin() + data_delimiters[
dist]);
1156 data_delimiters.erase(data_delimiters.begin() +
distf + 1, data_delimiters.begin() +
dist + 1);
1161 data_delimiters.end(),
1191 return erase(pos, pos + 1);
1215 template <std::ranges::forward_range rng_type>
1219 data_values.insert(data_values.end(),
std::ranges::begin(value), std::ranges::end(value));
1220 data_delimiters.push_back(data_delimiters.back() + std::ranges::size(value));
1243 data_delimiters.push_back(data_delimiters.back());
1266 void last_push_back(std::ranges::range_value_t<underlying_container_type>
const value)
1268 data_values.push_back(value);
1269 ++data_delimiters.back();
1266 void last_push_back(std::ranges::range_value_t<underlying_container_type>
const value) {
…}
1293 template <std::ranges::forward_range rng_type>
1297 data_values.insert(data_values.end(),
std::ranges::begin(value), std::ranges::end(value));
1298 data_delimiters.back() += std::ranges::size(value);
1323 data_values.resize(data_values.size() -
back_length);
1324 data_delimiters.pop_back();
1358 data_delimiters.resize(count + 1, data_delimiters.back());
1359 data_values.resize(data_delimiters.back());
1367 template <std::ranges::forward_range rng_type>
1372 assert(
concat_size() + count * std::ranges::size(value) < data_values.max_size());
1376 else if (count >
size())
1473 template <cereal_archive archive_t>
1476 archive(data_values, data_delimiters);
Adaptions of concepts from the Cereal library.
Container that stores sequences concatenated internally.
Definition concatenated_sequences.hpp:86
detail::random_access_iterator< concatenated_sequences const > const_iterator
The const iterator type of this container (a random access iterator).
Definition concatenated_sequences.hpp:134
constexpr concatenated_sequences & operator=(concatenated_sequences const &)=default
Default constructors.
concatenated_sequences(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition concatenated_sequences.hpp:235
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition concatenated_sequences.hpp:749
concatenated_sequences()=default
Default constructors.
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:776
void last_push_back(std::ranges::range_value_t< underlying_container_type > const value)
Appends the given element-of-element value to the end of the underlying container.
Definition concatenated_sequences.hpp:1266
void last_append(rng_type &&value)
Appends the given elements to the end of the underlying container (increases size of last element by ...
Definition concatenated_sequences.hpp:1294
const_reference front() const
Return the first element as a view. Calling front on an empty container is undefined.
Definition concatenated_sequences.hpp:592
constexpr concatenated_sequences(concatenated_sequences &&)=default
Default constructors.
const_reference back() const
Return the last element as a view.
Definition concatenated_sequences.hpp:619
reference at(size_type const i)
Return the i-th element as a view.
Definition concatenated_sequences.hpp:523
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition concatenated_sequences.hpp:467
reference concat()
Return the concatenation of all members.
Definition concatenated_sequences.hpp:641
constexpr bool operator>(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition concatenated_sequences.hpp:1442
bool empty() const noexcept
Checks whether the container is empty.
Definition concatenated_sequences.hpp:688
reference operator[](size_type const i)
Return the i-th element as a view.
Definition concatenated_sequences.hpp:556
concatenated_sequences & operator=(std::initializer_list< value_type_t > ilist)
Construct/assign from std::initializer_list.
Definition concatenated_sequences.hpp:335
constexpr void swap(concatenated_sequences &rhs) noexcept
Swap contents with another instance.
Definition concatenated_sequences.hpp:1393
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition concatenated_sequences.hpp:487
void clear() noexcept
Removes all elements from the container.
Definition concatenated_sequences.hpp:887
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition concatenated_sequences.hpp:455
~concatenated_sequences()=default
Default constructors.
void pop_back()
Removes the last element of the container.
Definition concatenated_sequences.hpp:1319
reference front()
Return the first element as a view. Calling front on an empty container is undefined.
Definition concatenated_sequences.hpp:585
reference back()
Return the last element as a view.
Definition concatenated_sequences.hpp:612
size_type concat_capacity() const noexcept
Returns the concatenated size the container has currently allocated space for.
Definition concatenated_sequences.hpp:841
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition concatenated_sequences.hpp:461
decltype(std::declval< std::decay_t< underlying_container_type > const & >()|views::slice(0, 1)) const_reference
An immutable views::slice that represents "one element", typically a std::span or std::string_view.
Definition concatenated_sequences.hpp:120
std::pair< decltype(data_values) &, decltype(data_delimiters) & > raw_data()
Provides direct, unsafe access to underlying data structures.
Definition concatenated_sequences.hpp:659
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition concatenated_sequences.hpp:493
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:1040
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:955
void shrink_to_fit()
Requests the removal of unused capacity.
Definition concatenated_sequences.hpp:800
constexpr concatenated_sequences(concatenated_sequences const &)=default
Default constructors.
iterator insert(const_iterator pos, rng_type &&value)
Inserts value before position in the container.
Definition concatenated_sequences.hpp:921
concatenated_sequences(std::initializer_list< value_type_t > ilist)
Construct/assign from std::initializer_list.
Definition concatenated_sequences.hpp:315
constexpr bool operator==(concatenated_sequences const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition concatenated_sequences.hpp:1415
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition concatenated_sequences.hpp:499
void resize(size_type const count, rng_type &&value)
Resizes the container to contain count elements.
Definition concatenated_sequences.hpp:1368
void assign(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition concatenated_sequences.hpp:381
detail::random_access_iterator< concatenated_sequences > iterator
The iterator type of this container (a random access iterator).
Definition concatenated_sequences.hpp:127
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:727
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:179
void assign(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition concatenated_sequences.hpp:429
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition concatenated_sequences.hpp:706
void push_back(rng_type &&value)
Appends the given element value to the end of the container.
Definition concatenated_sequences.hpp:1216
constexpr bool operator!=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition concatenated_sequences.hpp:1424
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:866
void assign(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition concatenated_sequences.hpp:358
static constexpr bool range_value_t_is_compatible_with_value_type
Whether a type is compatible with this class.
Definition concatenated_sequences.hpp:199
void push_back()
Appends an empty element to the end of the container.
Definition concatenated_sequences.hpp:1241
static constexpr bool iter_value_t_is_compatible_with_value_type
Whether a type is compatible with this class.
Definition concatenated_sequences.hpp:189
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition concatenated_sequences.hpp:1189
void resize(size_type const count)
Resizes the container to contain count elements.
Definition concatenated_sequences.hpp:1355
const_reference concat() const
Return the concatenation of all members.
Definition concatenated_sequences.hpp:647
value_type reference
A views::slice that represents "one element", typically a std::span.
Definition concatenated_sequences.hpp:112
constexpr bool operator>=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition concatenated_sequences.hpp:1460
const_reference operator[](size_type const i) const
Return the i-th element as a view.
Definition concatenated_sequences.hpp:565
size_type concat_size() const noexcept
Returns the cumulative size of all elements in the container.
Definition concatenated_sequences.hpp:823
constexpr void swap(concatenated_sequences &&rhs) noexcept
Swap contents with another instance.
Definition concatenated_sequences.hpp:1400
concatenated_sequences(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition concatenated_sequences.hpp:264
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition concatenated_sequences.hpp:406
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:665
decltype(std::declval< std::decay_t< underlying_container_type > & >()|views::slice(0, 1)) value_type
A views::slice that represents "one element", typically a std::span.
Definition concatenated_sequences.hpp:105
constexpr bool operator<(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition concatenated_sequences.hpp:1433
std::ranges::range_size_t< data_delimiters_type > size_type
An unsigned integer type (usually std::size_t)
Definition concatenated_sequences.hpp:148
concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition concatenated_sequences.hpp:292
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:1114
constexpr concatenated_sequences & operator=(concatenated_sequences &&)=default
Default constructors.
const_reference at(size_type const i) const
Return the i-th element as a view.
Definition concatenated_sequences.hpp:532
iterator erase(const_iterator first, const_iterator last)
Removes specified elements from the container.
Definition concatenated_sequences.hpp:1140
std::ranges::range_difference_t< data_delimiters_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition concatenated_sequences.hpp:141
constexpr bool operator<=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition concatenated_sequences.hpp:1451
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition slice.hpp:137
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition repeat_n.hpp:88
A more refined container concept than seqan3::random_access_container.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides seqan3::views::repeat_n.
Provides seqan3::views::slice.
Adaptations of concepts from the standard library.