SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
concatenated_sequences.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <type_traits>
16 #include <vector>
17 
18 #include <range/v3/view/const.hpp>
19 #include <range/v3/view/join.hpp>
20 #include <range/v3/view/repeat_n.hpp>
21 #include <range/v3/view/slice.hpp>
22 
28 #include <seqan3/std/iterator>
29 #include <seqan3/std/ranges>
30 
31 #if SEQAN3_WITH_CEREAL
32 #include <cereal/types/vector.hpp>
33 #endif
34 
35 namespace seqan3
36 {
37 
82 template <typename inner_type,
83  typename data_delimiters_type = std::vector<typename inner_type::size_type>>
85  requires ReservableContainer<std::remove_reference_t<inner_type>> &&
86  ReservableContainer<std::remove_reference_t<data_delimiters_type>> &&
87  std::is_same_v<size_type_t<inner_type>, value_type_t<data_delimiters_type>>
90 {
91 protected:
94  std::decay_t<inner_type> data_values;
96  data_delimiters_type data_delimiters{0};
97 
98 public:
100 
106 
109  using reference = decltype(data_values | ranges::view::slice(0, 1));
110 
113  using const_reference = decltype(std::as_const(data_values) | ranges::view::slice(0, 1) | ranges::view::const_);
114 
117  using iterator = detail::random_access_iterator<concatenated_sequences>;
118 
121  using const_iterator = detail::random_access_iterator<concatenated_sequences const>;
122 
126 
131 
133  // this signals to range-v3 that something is a container :|
134  using allocator_type = void;
136 
137 protected:
142  // unfortunately we cannot specialise the variable template so we have to add an auxiliary here
144  template <typename t>
145  requires (dimension_v<t> == dimension_v<value_type> + 1) &&
146  std::is_same_v<remove_cvref_t<innermost_value_type_t<value_type>>,
148  static constexpr bool is_compatible_this_aux = true;
150 
153  // cannot use the concept, because this class is not yet fully defined
154  template <typename t>
155  static constexpr bool is_compatible_this = is_compatible_this_aux<t> ||
156  std::is_same_v<remove_cvref_t<t>, concatenated_sequences> ||
157  std::is_same_v<remove_cvref_t<t>, iterator> ||
158  std::is_same_v<remove_cvref_t<t>, const_iterator>;
159 
162  // we explicitly check same-ness, because these types may not be fully resolved, yet
163  template <typename t>
165  std::is_same_v<remove_cvref_t<t>, value_type> ||
166  std::is_same_v<remove_cvref_t<t>, reference> ||
167  std::is_same_v<remove_cvref_t<t>, const_reference>;
169 public:
173  concatenated_sequences() = default;
176  constexpr concatenated_sequences(concatenated_sequences const &) = default;
178  constexpr concatenated_sequences(concatenated_sequences &&) = default;
180  constexpr concatenated_sequences & operator=(concatenated_sequences const &) = default;
182  constexpr concatenated_sequences & operator=(concatenated_sequences &&) = default;
184  ~concatenated_sequences() = default;
185 
198  template <std::ranges::InputRange rng_of_rng_type>
199  concatenated_sequences(rng_of_rng_type && rng_of_rng)
201  requires is_compatible_this<rng_of_rng_type>
203  {
205  data_delimiters.reserve(seqan3::size(rng_of_rng) + 1);
206 
207  for (auto && val : rng_of_rng)
208  {
209  data_values.insert(data_values.end(), val.begin(), val.end());
210  data_delimiters.push_back(data_delimiters.back() + val.size());
211  }
212  }
213 
227  template <std::ranges::ForwardRange rng_type>
228  concatenated_sequences(size_type const count, rng_type && value)
230  requires is_compatible_value<rng_type>
232  {
233  // TODO SEQAN_UNLIKELY
234  if (count == 0)
235  return;
236 
237  insert(cend(), count, std::forward<rng_type>(value));
238  }
239 
255  template <std::ForwardIterator begin_iterator_type, std::SizedSentinel<begin_iterator_type> end_iterator_type>
256  concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
258  requires is_compatible_this<begin_iterator_type>
260  {
261  insert(cend(), begin_it, end_it);
262  }
263 
276  template <std::ranges::ForwardRange rng_type = value_type>
279  requires is_compatible_value<rng_type>
281  {
282  assign(std::begin(ilist), std::end(ilist));
283  }
284 
297  template <std::ranges::ForwardRange rng_type>
300  requires is_compatible_value<rng_type>
302  {
303  assign(std::begin(ilist), std::end(ilist));
304  return *this;
305  }
306 
319  template <std::ranges::InputRange rng_of_rng_type>
320  void assign(rng_of_rng_type && rng_of_rng)
322  requires is_compatible_this<rng_of_rng_type>
324  {
325  concatenated_sequences rhs{std::forward<rng_of_rng_type>(rng_of_rng)};
326  swap(rhs);
327  }
328 
342  template <typename rng_type>
343  void assign(size_type const count, rng_type && value)
345  requires (std::ranges::ForwardRange<rng_type> && is_compatible_value<rng_type>)
347  {
348  concatenated_sequences rhs{count, value};
349  swap(rhs);
350  }
351 
366  template <std::ForwardIterator begin_iterator_type, typename end_iterator_type>
367  void assign(begin_iterator_type begin_it, end_iterator_type end_it)
369  requires is_compatible_this<begin_iterator_type> &&
372  {
373  concatenated_sequences rhs{begin_it, end_it};
374  swap(rhs);
375  }
376 
389  template <std::ranges::ForwardRange rng_type = value_type>
392  requires is_compatible_value<rng_type>
394  {
395  assign(std::begin(ilist), std::end(ilist));
396  }
397 
399 
416  iterator begin() noexcept
417  {
418  return iterator{*this};
419  }
420 
422  const_iterator begin() const noexcept
423  {
424  return const_iterator{*this};
425  }
426 
428  const_iterator cbegin() const noexcept
429  {
430  return const_iterator{*this};
431  }
432 
446  iterator end() noexcept
447  {
448  return iterator{*this, size()};
449  }
450 
452  const_iterator end() const noexcept
453  {
454  return const_iterator{*this, size()};
455  }
456 
458  const_iterator cend() const noexcept
459  {
460  return const_iterator{*this, size()};
461  }
463 
481  {
482  //TODO add SEQAN_UNLIKELY
483  if (i >= size())
484  throw std::out_of_range{"Trying to access element behind the last in concatenated_sequences."};
485  return (*this)[i];
486  }
487 
489  const_reference at(size_type const i) const
490  {
491  //TODO add SEQAN_UNLIKELY
492  if (i >= size())
493  throw std::out_of_range{"Trying to access element behind the last in concatenated_sequences."};
494  return (*this)[i];
495  }
496 
512  {
513  assert(i < size());
514  return data_values | ranges::view::slice(data_delimiters[i], data_delimiters[i+1]);
515  }
516 
519  {
520  assert(i < size());
521  return data_values | ranges::view::slice(data_delimiters[i], data_delimiters[i+1])
522  | ranges::view::const_;
523  }
524 
538  {
539  assert(size() > 0);
540  return (*this)[0];
541  }
542 
545  {
546  assert(size() > 0);
547  return (*this)[0];
548  }
549 
563  {
564  assert(size() > 0);
565  return (*this)[size()-1];
566  }
567 
570  {
571  assert(size() > 0);
572  return (*this)[size()-1];
573  }
574 
590  {
591  return data_values | ranges::view::slice(static_cast<size_type>(0), concat_size());
592  }
593 
596  {
597  return data_values | ranges::view::slice(static_cast<size_type>(0), concat_size()) | ranges::view::const_;
598  }
599 
606  {
607  return {data_values, data_delimiters};
608  }
609 
612  {
613  return {std::as_const(data_values), std::as_const(data_delimiters)};
614  }
616 
631  bool empty() const noexcept
632  {
633  return size() == 0;
634  }
635 
647  size_type size() const noexcept
648  {
649  return data_delimiters.size() - 1;
650  }
651 
666  size_type max_size() const noexcept
667  {
668  return data_delimiters.max_size() - 1;
669  }
670 
686  size_type capacity() const noexcept
687  {
688  return data_delimiters.capacity();
689  }
690 
713  void reserve(size_type const new_cap)
714  {
715  data_delimiters.reserve(new_cap + 1);
716  }
717 
738  {
739  data_values.shrink_to_fit();
740  data_delimiters.shrink_to_fit();
741  }
743 
758  size_type concat_size() const noexcept
759  {
760  return data_values.size();
761  }
762 
774  size_type concat_capacity() const noexcept
775  {
776  return data_values.capacity();
777  }
778 
797  void concat_reserve(size_type const new_cap)
798  {
799  data_values.reserve(new_cap);
800  }
802 
803 
818  void clear() noexcept
819  {
820  data_values.clear();
821  data_delimiters.clear();
822  data_delimiters.push_back(0);
823  }
824 
849  template <std::ranges::ForwardRange rng_type>
850  iterator insert(const_iterator pos, rng_type && value)
851  requires is_compatible_value<rng_type>
852  {
853  return insert(pos, 1, std::forward<rng_type>(value));
854  }
855  // no specialisation for temporaries, since we have to copy anyway
856 
881  template <std::ranges::ForwardRange rng_type>
882  iterator insert(const_iterator pos, size_type const count, rng_type && value)
883  requires is_compatible_value<rng_type>
884 
885  {
886  auto const pos_as_num = std::distance(cbegin(), pos); // we want to insert BEFORE this position
887  // TODO SEQAN_UNLIKELY
888  if (count == 0)
889  return begin() + pos_as_num;
890 
891  /* TODO implement view::flat_repeat_n that is like
892  * ranges::view::repeat_n(value, count) | std::view::join | ranges::view::bounded;
893  * but preserves random access and size.
894  *
895  * then do
896  * auto concatenated = ranges::view::flat_repeat_n(value, count);
897  * insert(pos, concatenated.cbegin(), concatenated.cend())
898  */
899 
900  size_type value_len = 0;
901  if constexpr (std::ranges::SizedRange<rng_type>)
902  value_len = seqan3::size(value);
903  else
904  value_len = std::distance(seqan3::begin(value), seqan3::end(value));
905 
906  data_values.reserve(data_values.size() + count * value_len);
907  auto placeholder = ranges::view::repeat_n(value_type_t<rng_type>{}, count * value_len)
909  // insert placeholder so the tail is moved once:
910  data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
911  seqan3::begin(placeholder),
912  seqan3::end(placeholder));
913 
914  // assign the actual values to the placeholder:
915  size_t i = data_delimiters[pos_as_num];
916  for (size_t j = 0; j < count; ++j)
917  for (auto && v : value)
918  data_values[i++] = v;
919 
920  data_delimiters.reserve(data_values.size() + count);
921  data_delimiters.insert(data_delimiters.begin() + pos_as_num,
922  count,
923  *(data_delimiters.begin() + pos_as_num));
924 
925  // adapt delimiters of inserted
926  for (size_type i = 0; i < count; ++i)
927  data_delimiters[pos_as_num + i + 1] += value_len * (i + 1);
928 
929  // adapt delimiters after that
930  // TODO parallel execution policy or vectorization?
931  std::for_each(data_delimiters.begin() + pos_as_num + count + 1,
932  data_delimiters.end(),
933  [full_len = value_len * count] (auto & d) { d += full_len; });
934 
935  return begin() + pos_as_num;
936  }
937 
961  template <std::ForwardIterator begin_iterator_type, typename end_iterator_type>
962  iterator insert(const_iterator pos, begin_iterator_type first, end_iterator_type last)
964  requires is_compatible_this<begin_iterator_type> &&
967  {
968  auto const pos_as_num = std::distance(cbegin(), pos);
969  // TODO SEQAN_UNLIKELY
970  if (last - first == 0)
971  return begin() + pos_as_num;
972 
974  last,
975  std::distance(first, last));
976 
977  data_delimiters.reserve(data_values.size() + ilist.size());
978  data_delimiters.insert(data_delimiters.begin() + pos_as_num,
979  ilist.size(),
980  *(data_delimiters.begin() + pos_as_num));
981 
982 
983  // adapt delimiters of inserted region
984  size_type full_len = 0;
985  for (size_type i = 0; i < ilist.size(); ++i, ++first)
986  {
987  // constant for sized ranges and/or random access ranges, linear otherwise
988  if constexpr (std::ranges::SizedRange<std::decay_t<decltype(*first)>>)
989  full_len += seqan3::size(*first);
990  else
991  full_len += std::distance(seqan3::begin(*first), seqan3::end(*first));
992 
993  data_delimiters[pos_as_num + 1 + i] += full_len;
994  }
995 
996  // adapt values of inserted region
997  auto placeholder = ranges::view::repeat_n(value_type_t<value_type>{}, full_len)
999  // insert placeholder so the tail is moved only once:
1000  data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
1001  seqan3::begin(placeholder),
1002  seqan3::end(placeholder));
1003 
1004  // assign the actual values to the placeholder:
1005  size_t i = data_delimiters[pos_as_num];
1006  for (auto && v0 : ilist)
1007  for (auto && v1 : v0)
1008  data_values[i++] = v1;
1009 
1010 
1011  // adapt delimiters behind inserted region
1012  // TODO parallel execution policy or vectorization?
1013  std::for_each(data_delimiters.begin() + pos_as_num + ilist.size() + 1,
1014  data_delimiters.end(),
1015  [full_len] (auto & d) { d += full_len; });
1016 
1017  return begin() + pos_as_num;
1018  }
1019 
1039  template <std::ranges::ForwardRange rng_type>
1041  requires is_compatible_value<rng_type>
1042  {
1043  return insert(pos, ilist.begin(), ilist.end());
1044  }
1045 
1065  {
1066  auto const dist = std::distance(cbegin(), last);
1067  // TODO SEQAN_UNLIKELY
1068  if (last - first == 0)
1069  return begin() + dist;
1070 
1071  auto const distf = std::distance(cbegin(), first);
1072 
1073  // we need to scan once over the input
1074  size_type sum_size{0};
1075  for (; first != last; ++first)
1076  sum_size += seqan3::size(*first);
1077 
1078  data_values.erase(data_values.begin() + data_delimiters[distf],
1079  data_values.begin() + data_delimiters[dist]);
1080 
1081  data_delimiters.erase(data_delimiters.begin() + distf + 1,
1082  data_delimiters.begin() + dist + 1);
1083 
1084  // adapt delimiters after that
1085  // TODO parallel execution policy or vectorization?
1086  std::for_each(data_delimiters.begin() + distf + 1,
1087  data_delimiters.end(),
1088  [sum_size] (auto & d) { d -= sum_size; });
1089  return begin() + dist;
1090  }
1091 
1111  {
1112  return erase(pos, pos + 1);
1113  }
1114 
1131  template <std::ranges::ForwardRange rng_type>
1132  void push_back(rng_type && value)
1133  requires is_compatible_value<rng_type>
1134  {
1135  data_values.insert(data_values.end(), seqan3::begin(value), seqan3::end(value));
1136  data_delimiters.push_back(data_delimiters.back() + seqan3::size(value));
1137  }
1138 
1155  void pop_back()
1156  {
1157  assert(size() > 0);
1158  auto back_length = data_delimiters[size()] - data_delimiters[size() - 1];
1159  data_values.resize(data_values.size() - back_length);
1160  data_delimiters.pop_back();
1161  }
1162 
1189  void resize(size_type const count)
1190  {
1191  assert(count < max_size());
1192  data_delimiters.resize(count + 1, data_delimiters.back());
1193  data_values.resize(data_delimiters.back());
1194  }
1195 
1201  template <std::ranges::ForwardRange rng_type>
1202  void resize(size_type const count, rng_type && value)
1203  requires is_compatible_value<rng_type>
1204  {
1205  assert(count < max_size());
1206  assert(concat_size() + count * seqan3::size(value) < data_values.max_size());
1207 
1208  if (count < size())
1209  resize(count);
1210  else if (count > size())
1211  insert(cend(), count - size(), std::forward<rng_type>(value));
1212  }
1213 
1225  constexpr void swap(concatenated_sequences & rhs) noexcept
1226  {
1227  std::swap(data_values, rhs.data_values);
1228  std::swap(data_delimiters, rhs.data_delimiters);
1229  }
1230 
1232  constexpr void swap(concatenated_sequences && rhs) noexcept
1233  {
1234  std::swap(data_values, rhs.data_values);
1235  std::swap(data_delimiters, rhs.data_delimiters);
1236  }
1238 
1243  constexpr bool operator==(concatenated_sequences const & rhs) const noexcept
1245  {
1246  return data() == rhs.data();
1247  }
1248 
1250  constexpr bool operator!=(concatenated_sequences const & rhs) const noexcept
1251  {
1252  return data() != rhs.data();
1253  }
1254 
1256  constexpr bool operator<(concatenated_sequences const & rhs) const noexcept
1257  {
1258  return data() < rhs.data();
1259  }
1260 
1262  constexpr bool operator>(concatenated_sequences const & rhs) const noexcept
1263  {
1264  return data() > rhs.data();
1265  }
1266 
1268  constexpr bool operator<=(concatenated_sequences const & rhs) const noexcept
1269  {
1270  return data() <= rhs.data();
1271  }
1272 
1274  constexpr bool operator>=(concatenated_sequences const & rhs) const noexcept
1275  {
1276  return data() >= rhs.data();
1277  }
1279 
1287  template <CerealArchive archive_t>
1288  void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
1289  {
1290  archive(data_values, data_delimiters);
1291  }
1293 };
1294 
1295 } // namespace seqan3
concatenated_sequences()=default
Default constructors.
constexpr concatenated_sequences & operator=(concatenated_sequences const &)=default
Default constructors.
detail::random_access_iterator< concatenated_sequences > iterator
The iterator type of this container (a random access iterator).
Definition: concatenated_sequences.hpp:117
typename value_type< t >::type value_type_t
Shortcut for seqan3::value_type (TransformationTrait shortcut).
Definition: pre.hpp:48
::ranges::subrange< it_t, sen_t, k > subrange
Create a view from a pair of iterator and sentinel.
Definition: ranges:339
T distance(T... args)
void concat_reserve(size_type const new_cap)
Increase the concat_capacity() to a value that&#39;s greater or equal to new_cap.
Definition: concatenated_sequences.hpp:797
const_reference at(size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:489
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:666
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: concatenated_sequences.hpp:1110
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:446
T swap(T... args)
void reserve(size_type const new_cap)
Increase the capacity to a value that&#39;s greater or equal to new_cap.
Definition: concatenated_sequences.hpp:713
Provides C++20 additions to the <iterator> header.
constexpr void swap(concatenated_sequences &rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1225
Provides various shortcuts for common std::ranges functions.
iterator erase(const_iterator first, const_iterator last)
Removes specified elements from the container.
Definition: concatenated_sequences.hpp:1064
concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:256
constexpr bool operator>=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than or equal to rhs.
Definition: concatenated_sequences.hpp:1274
T as_const(T... args)
Two types are "compatible" if their seqan3::dimension_v and their seqan3::innermost_value_type_t are ...
static constexpr bool is_compatible_value
Whether a type satisfies seqan3::Compatible with this class&#39;s value_type or reference type...
Definition: concatenated_sequences.hpp:164
void pop_back()
Removes the last element of the container.
Definition: concatenated_sequences.hpp:1155
T end(T... args)
Provides the seqan3::detail::random_access_iterator class.
void assign(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:320
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:458
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
std::pair< decltype(data_values) const &, decltype(data_delimiters) const & > data() const
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:611
decltype(data_values|ranges::view::slice(0, 1)) reference
A proxy of type ranges::view::slice that represents the range on the concatenated vector...
Definition: concatenated_sequences.hpp:109
constexpr bool operator>(concatenated_sequences const &rhs) const noexcept
Checks whether *this is greater than rhs.
Definition: concatenated_sequences.hpp:1262
typename difference_type< t >::type difference_type_t
Shortcut for seqan3::difference_type (TransformationTrait shortcut).
Definition: pre.hpp:166
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:144
size_type concat_size() const noexcept
Returns the cumulative size of all elements in the container.
Definition: concatenated_sequences.hpp:758
constexpr void swap(concatenated_sequences &&rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1232
const_reference concat() const
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:595
difference_type_t< data_delimiters_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: concatenated_sequences.hpp:125
void clear() noexcept
Removes all elements from the container.
Definition: concatenated_sequences.hpp:818
size_type_t< data_delimiters_type > size_type
An unsigned integer type (usually std::size_t)
Definition: concatenated_sequences.hpp:129
Container that stores sequences concatenated internally.
Definition: concatenated_sequences.hpp:89
constexpr auto common
A range adaptor that makes any range model std::ranges::CommonRange (at the expense of some performan...
Definition: ranges:447
bool empty() const noexcept
Checks whether the container is empty.
Definition: concatenated_sequences.hpp:631
Specifies the requirements of a Range type that knows its size in constant time with the size functio...
size_type concat_capacity() const noexcept
Returns the concatenated size the container has currently allocated space for.
Definition: concatenated_sequences.hpp:774
concatenated_sequences(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:277
Provides various type traits.
const_reference operator[](size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:518
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: concatenated_sequences.hpp:647
std::pair< decltype(data_values) &, decltype(data_delimiters) & > data()
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:605
iterator insert(const_iterator pos, rng_type &&value) requires is_compatible_value< rng_type >
Inserts value before position in the container.
Definition: concatenated_sequences.hpp:850
reference front()
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:537
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: concatenated_sequences.hpp:1189
decltype(std::as_const(data_values)|ranges::view::slice(0, 1)|ranges::view::const_) const_reference
An immutable proxy of type ranges::view::slice that represents the range on the concatenated vector...
Definition: concatenated_sequences.hpp:113
constexpr bool operator!=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: concatenated_sequences.hpp:1250
~concatenated_sequences()=default
Default constructors.
The SizedSentinel concept specifies that an object of the iterator type I and an object of the sentin...
Adaptations of concepts from the Ranges TS.
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:416
const_reference front() const
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:544
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:422
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:174
Adaptions of concepts from the Cereal library.
static constexpr bool is_compatible_this
Whether a type satisfies seqan3::Compatible with this class.
Definition: concatenated_sequences.hpp:155
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:367
void resize(size_type const count, rng_type &&value) requires is_compatible_value< rng_type >
Resizes the container to contain count elements.
Definition: concatenated_sequences.hpp:1202
typename size_type< t >::type size_type_t
Shortcut for seqan3::size_type (TransformationTrait shortcut).
Definition: pre.hpp:195
iterator insert(const_iterator pos, std::initializer_list< rng_type > const &ilist) requires is_compatible_value< rng_type >
Inserts elements from initializer list before position in the container.
Definition: concatenated_sequences.hpp:1040
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: concatenated_sequences.hpp:686
T begin(T... args)
reference operator[](size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:511
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:452
concatenated_sequences(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:199
constexpr bool operator<=(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than or equal to rhs.
Definition: concatenated_sequences.hpp:1268
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: concatenated_sequences.hpp:737
constexpr bool operator<(concatenated_sequences const &rhs) const noexcept
Checks whether *this is less than rhs.
Definition: concatenated_sequences.hpp:1256
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:97
iterator insert(const_iterator pos, size_type const count, rng_type &&value) requires is_compatible_value< rng_type >
Inserts count copies of value before position in the container.
Definition: concatenated_sequences.hpp:882
reference concat()
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:589
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:428
detail::random_access_iterator< concatenated_sequences const > const_iterator
The const iterator type of this container (a random access iterator).
Definition: concatenated_sequences.hpp:121
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
reference back()
Return the last element as a view.
Definition: concatenated_sequences.hpp:562
void assign(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:390
Adaptations of concepts from the standard library.
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:962
T for_each(T... args)
const_reference back() const
Return the last element as a view.
Definition: concatenated_sequences.hpp:569
reference at(size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:480
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:179
constexpr bool operator==(concatenated_sequences const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: concatenated_sequences.hpp:1244
void assign(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:343
concatenated_sequences(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:228
void push_back(rng_type &&value) requires is_compatible_value< rng_type >
Appends the given element value to the end of the container.
Definition: concatenated_sequences.hpp:1132
concatenated_sequences & operator=(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:298