SeqAn3
concatenated_sequences.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
42 #include <type_traits>
43 #include <vector>
44 
45 #include <range/v3/view/const.hpp>
46 #include <range/v3/view/join.hpp>
47 #include <range/v3/view/repeat_n.hpp>
48 #include <range/v3/view/slice.hpp>
49 
55 #include <seqan3/std/iterator>
56 #include <seqan3/std/ranges>
58 
59 #if SEQAN3_WITH_CEREAL
60 #include <cereal/types/vector.hpp>
61 #endif
62 
63 namespace seqan3
64 {
65 
110 template <typename inner_type,
111  typename data_delimiters_type = std::vector<typename inner_type::size_type>>
113  requires reservable_container_concept<std::remove_reference_t<inner_type>> &&
114  reservable_container_concept<std::remove_reference_t<data_delimiters_type>> &&
115  std::is_same_v<size_type_t<inner_type>, value_type_t<data_delimiters_type>>
118 {
119 protected:
122  std::decay_t<inner_type> data_values;
124  data_delimiters_type data_delimiters{0};
125 
126 public:
128 
131  using value_type = std::decay_t<inner_type>;
134 
137  using reference = decltype(data_values | ranges::view::slice(0, 1));
138 
141  using const_reference = decltype(std::as_const(data_values) | ranges::view::slice(0, 1) | ranges::view::const_);
142 
145  using iterator = detail::random_access_iterator<concatenated_sequences>;
146 
149  using const_iterator = detail::random_access_iterator<concatenated_sequences const>;
150 
154 
159 
161  // this signals to range-v3 that something is a container :|
162  using allocator_type = void;
164 
165 protected:
170  // unfortunately we cannot specialise the variable template so we have to add an auxiliary here
172  template <typename t>
173  requires (dimension_v<t> == dimension_v<value_type> + 1) &&
174  std::is_same_v<remove_cvref_t<innermost_value_type_t<value_type>>,
176  static constexpr bool is_compatible_this_aux = true;
178 
181  // cannot use the concept, because this class is not yet fully defined
182  template <typename t>
183  static constexpr bool is_compatible_this = is_compatible_this_aux<t> ||
184  std::is_same_v<remove_cvref_t<t>, concatenated_sequences> ||
185  std::is_same_v<remove_cvref_t<t>, iterator> ||
186  std::is_same_v<remove_cvref_t<t>, const_iterator>;
187 
190  // we explicitly check same-ness, because these types may not be fully resolved, yet
191  template <typename t>
193  std::is_same_v<remove_cvref_t<t>, value_type> ||
194  std::is_same_v<remove_cvref_t<t>, reference> ||
195  std::is_same_v<remove_cvref_t<t>, const_reference>;
197 public:
201  concatenated_sequences() = default;
204  constexpr concatenated_sequences(concatenated_sequences const &) = default;
206  constexpr concatenated_sequences(concatenated_sequences &&) = default;
208  constexpr concatenated_sequences & operator=(concatenated_sequences const &) = default;
210  constexpr concatenated_sequences & operator=(concatenated_sequences &&) = default;
212  ~concatenated_sequences() = default;
213 
226  template <std::ranges::InputRange rng_of_rng_type>
227  concatenated_sequences(rng_of_rng_type && rng_of_rng)
229  requires is_compatible_this<rng_of_rng_type>
231  {
233  data_delimiters.reserve(seqan3::size(rng_of_rng) + 1);
234 
235  for (auto && val : rng_of_rng)
236  {
237  data_values.insert(data_values.end(), val.begin(), val.end());
238  data_delimiters.push_back(data_delimiters.back() + val.size());
239  }
240  }
241 
255  template <std::ranges::ForwardRange rng_type>
256  concatenated_sequences(size_type const count, rng_type && value)
258  requires is_compatible_value<rng_type>
260  {
261  // TODO SEQAN_UNLIKELY
262  if (count == 0)
263  return;
264 
265  insert(cend(), count, std::forward<rng_type>(value));
266  }
267 
283  template <std::ForwardIterator begin_iterator_type, std::SizedSentinel<begin_iterator_type> end_iterator_type>
284  concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
286  requires is_compatible_this<begin_iterator_type>
288  {
289  insert(cend(), begin_it, end_it);
290  }
291 
304  template <std::ranges::ForwardRange rng_type = value_type>
305  concatenated_sequences(std::initializer_list<rng_type> ilist)
307  requires is_compatible_value<rng_type>
309  {
310  assign(std::begin(ilist), std::end(ilist));
311  }
312 
325  template <std::ranges::ForwardRange rng_type>
326  concatenated_sequences & operator=(std::initializer_list<rng_type> ilist)
328  requires is_compatible_value<rng_type>
330  {
331  assign(std::begin(ilist), std::end(ilist));
332  return *this;
333  }
334 
347  template <std::ranges::InputRange rng_of_rng_type>
348  void assign(rng_of_rng_type && rng_of_rng)
350  requires is_compatible_this<rng_of_rng_type>
352  {
353  concatenated_sequences rhs{std::forward<rng_of_rng_type>(rng_of_rng)};
354  swap(rhs);
355  }
356 
370  template <typename rng_type>
371  void assign(size_type const count, rng_type && value)
373  requires (std::ranges::ForwardRange<rng_type> && is_compatible_value<rng_type>)
375  {
376  concatenated_sequences rhs{count, value};
377  swap(rhs);
378  }
379 
394  template <std::ForwardIterator begin_iterator_type, typename end_iterator_type>
395  void assign(begin_iterator_type begin_it, end_iterator_type end_it)
397  requires is_compatible_this<begin_iterator_type> &&
400  {
401  concatenated_sequences rhs{begin_it, end_it};
402  swap(rhs);
403  }
404 
417  template <std::ranges::ForwardRange rng_type = value_type>
418  void assign(std::initializer_list<rng_type> ilist)
420  requires is_compatible_value<rng_type>
422  {
423  assign(std::begin(ilist), std::end(ilist));
424  }
425 
427 
444  iterator begin() noexcept
445  {
446  return iterator{*this};
447  }
448 
450  const_iterator begin() const noexcept
451  {
452  return const_iterator{*this};
453  }
454 
456  const_iterator cbegin() const noexcept
457  {
458  return const_iterator{*this};
459  }
460 
474  iterator end() noexcept
475  {
476  return iterator{*this, size()};
477  }
478 
480  const_iterator end() const noexcept
481  {
482  return const_iterator{*this, size()};
483  }
484 
486  const_iterator cend() const noexcept
487  {
488  return const_iterator{*this, size()};
489  }
491 
509  {
510  //TODO add SEQAN_UNLIKELY
511  if (i >= size())
512  throw std::out_of_range{"Trying to access element behind the last in concatenated_sequences."};
513  return (*this)[i];
514  }
515 
517  const_reference at(size_type const i) const
518  {
519  //TODO add SEQAN_UNLIKELY
520  if (i >= size())
521  throw std::out_of_range{"Trying to access element behind the last in concatenated_sequences."};
522  return (*this)[i];
523  }
524 
540  {
541  assert(i < size());
542  return data_values | ranges::view::slice(data_delimiters[i], data_delimiters[i+1]);
543  }
544 
546  const_reference operator[](size_type const i) const
547  {
548  assert(i < size());
549  return data_values | ranges::view::slice(data_delimiters[i], data_delimiters[i+1])
550  | ranges::view::const_;
551  }
552 
566  {
567  assert(size() > 0);
568  return (*this)[0];
569  }
570 
572  const_reference front() const
573  {
574  assert(size() > 0);
575  return (*this)[0];
576  }
577 
591  {
592  assert(size() > 0);
593  return (*this)[size()-1];
594  }
595 
597  const_reference back() const
598  {
599  assert(size() > 0);
600  return (*this)[size()-1];
601  }
602 
618  {
619  return data_values | ranges::view::slice(static_cast<size_type>(0), concat_size());
620  }
621 
623  const_reference concat() const
624  {
625  return data_values | ranges::view::slice(static_cast<size_type>(0), concat_size()) | ranges::view::const_;
626  }
627 
633  std::pair<decltype(data_values) &, decltype(data_delimiters) &> data()
634  {
635  return {data_values, data_delimiters};
636  }
637 
639  std::pair<decltype(data_values) const &, decltype(data_delimiters) const &> data() const
640  {
641  return {std::as_const(data_values), std::as_const(data_delimiters)};
642  }
644 
659  bool empty() const noexcept
660  {
661  return size() == 0;
662  }
663 
675  size_type size() const noexcept
676  {
677  return data_delimiters.size() - 1;
678  }
679 
694  size_type max_size() const noexcept
695  {
696  return data_delimiters.max_size() - 1;
697  }
698 
714  size_type capacity() const noexcept
715  {
716  return data_delimiters.capacity();
717  }
718 
741  void reserve(size_type const new_cap)
742  {
743  data_delimiters.reserve(new_cap + 1);
744  }
745 
766  {
767  data_values.shrink_to_fit();
768  data_delimiters.shrink_to_fit();
769  }
771 
786  size_type concat_size() const noexcept
787  {
788  return data_values.size();
789  }
790 
802  size_type concat_capacity() const noexcept
803  {
804  return data_values.capacity();
805  }
806 
825  void concat_reserve(size_type const new_cap)
826  {
827  data_values.reserve(new_cap);
828  }
830 
831 
846  void clear() noexcept
847  {
848  data_values.clear();
849  data_delimiters.clear();
850  data_delimiters.push_back(0);
851  }
852 
877  template <std::ranges::ForwardRange rng_type>
878  iterator insert(const_iterator pos, rng_type && value)
879  requires is_compatible_value<rng_type>
880  {
881  return insert(pos, 1, std::forward<rng_type>(value));
882  }
883  // no specialisation for temporaries, since we have to copy anyway
884 
909  template <std::ranges::ForwardRange rng_type>
910  iterator insert(const_iterator pos, size_type const count, rng_type && value)
911  requires is_compatible_value<rng_type>
912 
913  {
914  auto const pos_as_num = std::distance(cbegin(), pos); // we want to insert BEFORE this position
915  // TODO SEQAN_UNLIKELY
916  if (count == 0)
917  return begin() + pos_as_num;
918 
919  /* TODO implement view::flat_repeat_n that is like
920  * ranges::view::repeat_n(value, count) | ranges::view::join | ranges::view::bounded;
921  * but preserves random access and size.
922  *
923  * then do
924  * auto concatenated = ranges::view::flat_repeat_n(value, count);
925  * insert(pos, concatenated.cbegin(), concatenated.cend())
926  */
927 
928  size_type value_len = 0;
929  if constexpr (std::ranges::SizedRange<rng_type>)
930  value_len = seqan3::size(value);
931  else
932  value_len = std::distance(seqan3::begin(value), seqan3::end(value));
933 
934  data_values.reserve(data_values.size() + count * value_len);
935  auto placeholder = ranges::view::repeat_n(value_type_t<rng_type>{}, count * value_len)
936  | view::common;
937  // insert placeholder so the tail is moved once:
938  data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
939  seqan3::begin(placeholder),
940  seqan3::end(placeholder));
941 
942  // assign the actual values to the placeholder:
943  size_t i = data_delimiters[pos_as_num];
944  for (size_t j = 0; j < count; ++j)
945  for (auto && v : value)
946  data_values[i++] = v;
947 
948  data_delimiters.reserve(data_values.size() + count);
949  data_delimiters.insert(data_delimiters.begin() + pos_as_num,
950  count,
951  *(data_delimiters.begin() + pos_as_num));
952 
953  // adapt delimiters of inserted
954  for (size_type i = 0; i < count; ++i)
955  data_delimiters[pos_as_num + i + 1] += value_len * (i + 1);
956 
957  // adapt delimiters after that
958  // TODO parallel execution policy or vectorization?
959  std::for_each(data_delimiters.begin() + pos_as_num + count + 1,
960  data_delimiters.end(),
961  [full_len = value_len * count] (auto & d) { d += full_len; });
962 
963  return begin() + pos_as_num;
964  }
965 
989  template <std::ForwardIterator begin_iterator_type, typename end_iterator_type>
990  iterator insert(const_iterator pos, begin_iterator_type first, end_iterator_type last)
992  requires is_compatible_this<begin_iterator_type> &&
995  {
996  auto const pos_as_num = std::distance(cbegin(), pos);
997  // TODO SEQAN_UNLIKELY
998  if (last - first == 0)
999  return begin() + pos_as_num;
1000 
1001  auto const ilist = std::ranges::make_iterator_range(first, last, std::distance(first, last));
1002 
1003  data_delimiters.reserve(data_values.size() + ilist.size());
1004  data_delimiters.insert(data_delimiters.begin() + pos_as_num,
1005  ilist.size(),
1006  *(data_delimiters.begin() + pos_as_num));
1007 
1008 
1009  // adapt delimiters of inserted region
1010  size_type full_len = 0;
1011  for (size_type i = 0; i < ilist.size(); ++i, ++first)
1012  {
1013  // constant for sized ranges and/or random access ranges, linear otherwise
1014  if constexpr (std::ranges::SizedRange<std::decay_t<decltype(*first)>>)
1015  full_len += seqan3::size(*first);
1016  else
1017  full_len += std::distance(seqan3::begin(*first), seqan3::end(*first));
1018 
1019  data_delimiters[pos_as_num + 1 + i] += full_len;
1020  }
1021 
1022  // adapt values of inserted region
1023  auto placeholder = ranges::view::repeat_n(value_type_t<value_type>{}, full_len)
1024  | view::common;
1025  // insert placeholder so the tail is moved only once:
1026  data_values.insert(data_values.begin() + data_delimiters[pos_as_num],
1027  seqan3::begin(placeholder),
1028  seqan3::end(placeholder));
1029 
1030  // assign the actual values to the placeholder:
1031  size_t i = data_delimiters[pos_as_num];
1032  for (auto && v0 : ilist)
1033  for (auto && v1 : v0)
1034  data_values[i++] = v1;
1035 
1036 
1037  // adapt delimiters behind inserted region
1038  // TODO parallel execution policy or vectorization?
1039  std::for_each(data_delimiters.begin() + pos_as_num + ilist.size() + 1,
1040  data_delimiters.end(),
1041  [full_len] (auto & d) { d += full_len; });
1042 
1043  return begin() + pos_as_num;
1044  }
1045 
1065  template <std::ranges::ForwardRange rng_type>
1066  iterator insert(const_iterator pos, std::initializer_list<rng_type> const & ilist)
1067  requires is_compatible_value<rng_type>
1068  {
1069  return insert(pos, ilist.begin(), ilist.end());
1070  }
1071 
1090  iterator erase(const_iterator first, const_iterator last)
1091  {
1092  auto const dist = std::distance(cbegin(), last);
1093  // TODO SEQAN_UNLIKELY
1094  if (last - first == 0)
1095  return begin() + dist;
1096 
1097  auto const distf = std::distance(cbegin(), first);
1098 
1099  // we need to scan once over the input
1100  size_type sum_size{0};
1101  for (; first != last; ++first)
1102  sum_size += seqan3::size(*first);
1103 
1104  data_values.erase(data_values.begin() + data_delimiters[distf],
1105  data_values.begin() + data_delimiters[dist]);
1106 
1107  data_delimiters.erase(data_delimiters.begin() + distf + 1,
1108  data_delimiters.begin() + dist + 1);
1109 
1110  // adapt delimiters after that
1111  // TODO parallel execution policy or vectorization?
1112  std::for_each(data_delimiters.begin() + distf + 1,
1113  data_delimiters.end(),
1114  [sum_size] (auto & d) { d -= sum_size; });
1115  return begin() + dist;
1116  }
1117 
1136  iterator erase(const_iterator pos)
1137  {
1138  return erase(pos, pos + 1);
1139  }
1140 
1157  template <std::ranges::ForwardRange rng_type>
1158  void push_back(rng_type && value)
1159  requires is_compatible_value<rng_type>
1160  {
1161  data_values.insert(data_values.end(), seqan3::begin(value), seqan3::end(value));
1162  data_delimiters.push_back(data_delimiters.back() + seqan3::size(value));
1163  }
1164 
1181  void pop_back()
1182  {
1183  assert(size() > 0);
1184  auto back_length = data_delimiters[size()] - data_delimiters[size() - 1];
1185  data_values.resize(data_values.size() - back_length);
1186  data_delimiters.pop_back();
1187  }
1188 
1215  void resize(size_type const count)
1216  {
1217  assert(count < max_size());
1218  data_delimiters.resize(count + 1, data_delimiters.back());
1219  data_values.resize(data_delimiters.back());
1220  }
1221 
1227  template <std::ranges::ForwardRange rng_type>
1228  void resize(size_type const count, rng_type && value)
1229  requires is_compatible_value<rng_type>
1230  {
1231  assert(count < max_size());
1232  assert(concat_size() + count * seqan3::size(value) < data_values.max_size());
1233 
1234  if (count < size())
1235  resize(count);
1236  else if (count > size())
1237  insert(cend(), count - size(), std::forward<rng_type>(value));
1238  }
1239 
1251  constexpr void swap(concatenated_sequences & rhs) noexcept
1252  {
1253  std::swap(data_values, rhs.data_values);
1254  std::swap(data_delimiters, rhs.data_delimiters);
1255  }
1256 
1258  constexpr void swap(concatenated_sequences && rhs) noexcept
1259  {
1260  std::swap(data_values, rhs.data_values);
1261  std::swap(data_delimiters, rhs.data_delimiters);
1262  }
1264 
1267  constexpr bool operator==(concatenated_sequences const & rhs) const noexcept
1268  {
1269  return data() == rhs.data();
1270  }
1271 
1272  constexpr bool operator!=(concatenated_sequences const & rhs) const noexcept
1273  {
1274  return data() != rhs.data();
1275  }
1276 
1277  constexpr bool operator<(concatenated_sequences const & rhs) const noexcept
1278  {
1279  return data() < rhs.data();
1280  }
1281 
1282  constexpr bool operator>(concatenated_sequences const & rhs) const noexcept
1283  {
1284  return data() > rhs.data();
1285  }
1286 
1287  constexpr bool operator<=(concatenated_sequences const & rhs) const noexcept
1288  {
1289  return data() <= rhs.data();
1290  }
1291 
1292  constexpr bool operator>=(concatenated_sequences const & rhs) const noexcept
1293  {
1294  return data() >= rhs.data();
1295  }
1297 
1305  template <cereal_archive_concept archive_t>
1306  void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
1307  {
1308  archive(data_values, data_delimiters);
1309  }
1311 };
1312 
1313 } // 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:145
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:825
const_reference at(size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:517
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:694
iterator erase(const_iterator pos)
Removes specified elements from the container.
Definition: concatenated_sequences.hpp:1136
iterator end() noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:474
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:741
Provides C++20 additions to the <iterator> header.
constexpr void swap(concatenated_sequences &rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1251
Contains 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:1090
concatenated_sequences(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:284
std::decay_t< inner_type > value_type
== inner_type.
Definition: concatenated_sequences.hpp:133
static constexpr bool is_compatible_value
Whether a type satisfies seqan3::compatible_concept with this class&#39;s value_type or reference type...
Definition: concatenated_sequences.hpp:192
void pop_back()
Removes the last element of the container.
Definition: concatenated_sequences.hpp:1181
Provides the seqan3::detail::random_access_iterator class.
Provides various metafunctions.
void assign(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:348
const_iterator cend() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:486
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:195
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
Two types are "compatible" if their seqan3::dimension_v and their seqan3::innermost_value_type_t are ...
std::pair< decltype(data_values) const &, decltype(data_delimiters) const & > data() const
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:639
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:137
size_type concat_size() const noexcept
Returns the cumulative size of all elements in the container.
Definition: concatenated_sequences.hpp:786
constexpr void swap(concatenated_sequences &&rhs) noexcept
Swap contents with another instance.
Definition: concatenated_sequences.hpp:1258
const_reference concat() const
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:623
difference_type_t< data_delimiters_type > difference_type
A signed integer type (usually std::ptrdiff_t)
Definition: concatenated_sequences.hpp:153
void clear() noexcept
Removes all elements from the container.
Definition: concatenated_sequences.hpp:846
Provides seqan3::view::common.
size_type_t< data_delimiters_type > size_type
An unsigned integer type (usually std::size_t)
Definition: concatenated_sequences.hpp:157
Container that stores sequences concatenated internally.
Definition: concatenated_sequences.hpp:117
::ranges::make_iterator_range make_iterator_range
Alias for ranges::make_iterator_range. Makes the iterator adaptor.
Definition: ranges:240
bool empty() const noexcept
Checks whether the container is empty.
Definition: concatenated_sequences.hpp:659
typename size_type< t >::type size_type_t
Type metafunction shortcut for seqan3::size_type.
Definition: pre.hpp:204
size_type concat_capacity() const noexcept
Returns the concatenated size the container has currently allocated space for.
Definition: concatenated_sequences.hpp:802
concatenated_sequences(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:305
const_reference operator[](size_type const i) const
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:546
size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition: concatenated_sequences.hpp:675
constexpr auto common
A range adaptor that makes any range satisfy std::ranges::CommonRange (at the expense of some perform...
Definition: common.hpp:99
std::pair< decltype(data_values) &, decltype(data_delimiters) & > data()
Provides direct, unsafe access to underlying data structures.
Definition: concatenated_sequences.hpp:633
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:878
reference front()
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:565
void resize(size_type const count)
Resizes the container to contain count elements.
Definition: concatenated_sequences.hpp:1215
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:141
~concatenated_sequences()=default
Default constructors.
std::remove_cv_t< std::remove_reference_t< t > > remove_cvref_t
Return the input type with const, volatile and references removed [Type metafunction].
Definition: basic.hpp:64
Adaptations of concepts from the Ranges TS.
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:444
const_reference front() const
Return the first element as a view. Calling front on an empty container is undefined.
Definition: concatenated_sequences.hpp:572
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:450
Adaptions of concepts from the Cereal library.
static constexpr bool is_compatible_this
Whether a type satisfies seqan3::compatible_concept with this class.
Definition: concatenated_sequences.hpp:183
void assign(begin_iterator_type begin_it, end_iterator_type end_it)
Construct/assign from pair of iterators.
Definition: concatenated_sequences.hpp:395
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:1228
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
typename difference_type< t >::type difference_type_t
Type metafunction shortcut for seqan3::difference_type.
Definition: pre.hpp:178
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:1066
size_type capacity() const noexcept
Returns the number of elements that the container has currently allocated space for.
Definition: concatenated_sequences.hpp:714
Provides C++20 additions to the type_traits header.
reference operator[](size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:539
const_iterator end() const noexcept
Returns an iterator to the element following the last element of the container.
Definition: concatenated_sequences.hpp:480
concatenated_sequences(rng_of_rng_type &&rng_of_rng)
Construct/assign from a different range.
Definition: concatenated_sequences.hpp:227
void shrink_to_fit()
Requests the removal of unused capacity.
Definition: concatenated_sequences.hpp:765
The SizedSentinel concept specifies that an object of the iterator type I and an object of the sentin...
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:910
typename value_type< t >::type value_type_t
Type metafunction shortcut for seqan3::value_type.
Definition: pre.hpp:72
reference concat()
Return the concatenation of all members.
Definition: concatenated_sequences.hpp:617
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: concatenated_sequences.hpp:456
detail::random_access_iterator< concatenated_sequences const > const_iterator
The const iterator type of this container (a random access iterator).
Definition: concatenated_sequences.hpp:149
reference back()
Return the last element as a view.
Definition: concatenated_sequences.hpp:590
void assign(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:418
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:990
Specifies the requirements of a Range type that knows its size in constant time with the size functio...
const_reference back() const
Return the last element as a view.
Definition: concatenated_sequences.hpp:597
reference at(size_type const i)
Return the i-th element as a view.
Definition: concatenated_sequences.hpp:508
void assign(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:371
concatenated_sequences(size_type const count, rng_type &&value)
Construct/assign with count times value.
Definition: concatenated_sequences.hpp:256
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:1158
concatenated_sequences & operator=(std::initializer_list< rng_type > ilist)
Construct/assign from std::initializer_list.
Definition: concatenated_sequences.hpp:326