OGLplus  (0.59.0) a C++ wrapper for rendering APIs

span_algo.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_MEMORY_SPAN_ALGO_HPP
9 #define EAGINE_MEMORY_SPAN_ALGO_HPP
10 
11 #include "span.hpp"
12 #include <algorithm>
13 #include <numeric>
14 #include <tuple>
15 #include <type_traits>
16 #include <vector>
17 
18 namespace eagine::memory {
19 //------------------------------------------------------------------------------
20 template <typename T, typename P, typename S>
21 static constexpr auto clamp_span_iterator(basic_span<T, P, S> s, P p) noexcept
22  -> P {
23  return (p < s.begin()) ? s.begin() : (p > s.end()) ? s.end() : p;
24 }
25 //------------------------------------------------------------------------------
26 template <typename T, typename P, typename S, typename I>
27 static constexpr auto clamp_span_position(basic_span<T, P, S> s, I p) noexcept
28  -> std::enable_if_t<std::is_integral_v<I>, P> {
29  return clamp_span_iterator(s, s.begin() + p);
30 }
31 //------------------------------------------------------------------------------
32 template <typename T, typename P, typename S, typename B, typename E>
33 static constexpr auto subspan(basic_span<T, P, S> s, B b, E e) noexcept
34  -> std::enable_if_t<
35  std::is_integral_v<B> && std::is_integral_v<E>,
36  basic_span<T, P, S>> {
37  return {clamp_span_position(s, b), clamp_span_position(s, e)};
38 }
39 //------------------------------------------------------------------------------
46 template <typename T, typename P, typename S, typename I, typename L>
47 static constexpr auto slice(basic_span<T, P, S> s, I i, L l) noexcept
49  return {clamp_span_position(s, i), clamp_span_position(s, i + l)};
50 }
51 //------------------------------------------------------------------------------
59 template <typename T, typename P, typename S, typename L>
60 static constexpr auto skip(basic_span<T, P, S> s, L l) noexcept
62  return slice(s, l, s.size() - l);
63 }
64 //------------------------------------------------------------------------------
72 template <typename T, typename P, typename S, typename L>
73 static constexpr auto snip(basic_span<T, P, S> s, L l) noexcept
75  return head(s, s.size() - l);
76 }
77 //------------------------------------------------------------------------------
85 template <typename T, typename P, typename S, typename L>
86 static constexpr auto shrink(basic_span<T, P, S> s, L l) noexcept
88  return snip(skip(s, l), l);
89 }
90 //------------------------------------------------------------------------------
98 template <typename T, typename P, typename S, typename L>
99 static constexpr auto head(basic_span<T, P, S> s, L l) noexcept
101  return slice(s, S(0), l);
102 }
103 //------------------------------------------------------------------------------
111 template <
112  typename Ts,
113  typename Ps,
114  typename Ss,
115  typename Tl,
116  typename Pl,
117  typename Sl>
118 static constexpr auto
121  return head(s, l.size());
122 }
123 //------------------------------------------------------------------------------
131 template <typename T, typename P, typename S, typename L>
132 static constexpr auto tail(basic_span<T, P, S> s, L l) noexcept
134  return skip(s, s.size() - l);
135 }
136 //------------------------------------------------------------------------------
144 template <
145  typename Ts,
146  typename Ps,
147  typename Ss,
148  typename Tl,
149  typename Pl,
150  typename Sl>
151 static constexpr auto
154  return tail(s, l.size());
155 }
156 //------------------------------------------------------------------------------
162 template <
163  typename T1,
164  typename P1,
165  typename S1,
166  typename T2,
167  typename P2,
168  typename S2>
169 static constexpr auto
171  return are_equal(head(spn, with.size()), with);
172 }
173 //------------------------------------------------------------------------------
179 template <
180  typename T1,
181  typename P1,
182  typename S1,
183  typename T2,
184  typename P2,
185  typename S2>
186 static constexpr auto
188  return are_equal(tail(spn, with.size()), with);
189 }
190 //------------------------------------------------------------------------------
195 template <
196  typename T1,
197  typename P1,
198  typename S1,
199  typename T2,
200  typename P2,
201  typename S2>
202 static constexpr auto
205  return starts_with(spn, prefix) ? skip(spn, prefix.size()) : spn;
206 }
207 //------------------------------------------------------------------------------
212 template <
213  typename T1,
214  typename P1,
215  typename S1,
216  typename T2,
217  typename P2,
218  typename S2>
219 static constexpr auto
222  return ends_with(spn, suffix) ? snip(spn, suffix.size()) : spn;
223 }
224 //------------------------------------------------------------------------------
229 template <
230  typename T1,
231  typename P1,
232  typename S1,
233  typename T2,
234  typename P2,
235  typename S2>
236 static constexpr auto
238  -> S1 {
239  for(S1 i = 0; i < spn.size(); ++i) {
240  if(starts_with(skip(spn, i), what)) {
241  return true;
242  }
243  }
244  return false;
245 }
246 //------------------------------------------------------------------------------
252 template <
253  typename T1,
254  typename P1,
255  typename S1,
256  typename T2,
257  typename P2,
258  typename S2>
259 static constexpr auto
262  auto pos = S1(0);
263  while(pos < spn.size()) {
264  if(starts_with(skip(spn, pos), what)) {
265  return {pos, true};
266  }
267  ++pos;
268  }
269  return {};
270 }
271 //------------------------------------------------------------------------------
278 template <typename T, typename P, typename S, typename E>
279 static constexpr auto find_element(basic_span<T, P, S> spn, E what) noexcept
281  auto pos = S(0);
282  while(pos < spn.size()) {
283  if(are_equal(spn[pos], what)) {
284  return {pos, true};
285  }
286  ++pos;
287  }
288  return {};
289 }
290 //------------------------------------------------------------------------------
297 template <typename T, typename P, typename S, typename F>
298 static constexpr auto
299 find_element_if(basic_span<T, P, S> spn, F predicate) noexcept
301  auto pos = S(0);
302  while(pos < spn.size()) {
303  if(predicate(spn[pos])) {
304  return {pos, true};
305  }
306  ++pos;
307  }
308  return {};
309 }
310 //------------------------------------------------------------------------------
314 template <typename T, typename P, typename S, typename Predicate>
315 static constexpr auto
316 skip_until(basic_span<T, P, S> spn, Predicate predicate) noexcept
318  if(auto found{find_element_if(spn, predicate)}) {
319  return skip(spn, extract(found));
320  }
321  return spn;
322 }
323 //------------------------------------------------------------------------------
327 template <typename T, typename P, typename S, typename Predicate>
328 static constexpr auto
329 take_until(basic_span<T, P, S> spn, Predicate predicate) noexcept
331  if(auto found{find_element_if(spn, predicate)}) {
332  return head(spn, extract(found));
333  }
334  return spn;
335 }
336 //------------------------------------------------------------------------------
341 template <
342  typename T1,
343  typename P1,
344  typename S1,
345  typename T2,
346  typename P2,
347  typename S2>
348 static constexpr auto reverse_find_position(
350  basic_span<T2, P2, S2> what) noexcept -> optionally_valid<S1> {
351  auto pos = spn.size();
352  while(pos > S1(0)) {
353  --pos;
354  if(starts_with(skip(spn, pos), what)) {
355  return {pos, true};
356  }
357  }
358  return {};
359 }
360 //------------------------------------------------------------------------------
366 template <
367  typename T1,
368  typename P1,
369  typename S1,
370  typename T2,
371  typename P2,
372  typename S2>
373 static inline auto
376  if(auto pos = find_position(where, what)) {
377  return skip(where, extract(pos));
378  }
379  return {};
380 }
381 //------------------------------------------------------------------------------
386 template <
387  typename T1,
388  typename P1,
389  typename S1,
390  typename T2,
391  typename P2,
392  typename S2>
393 static inline auto
396  return head(spn, extract_or(find_position(spn, what), spn.size()));
397 }
398 //------------------------------------------------------------------------------
403 template <
404  typename T1,
405  typename P1,
406  typename S1,
407  typename T2,
408  typename P2,
409  typename S2>
410 static inline auto
413  return skip(
414  spn, extract_or(find_position(spn, what), spn.size()) + what.size());
415 }
416 //------------------------------------------------------------------------------
420 template <
421  typename T1,
422  typename P1,
423  typename S1,
424  typename T2,
425  typename P2,
426  typename S2>
427 static inline auto
429  -> std::tuple<basic_span<T1, P1, S1>, basic_span<T1, P1, S1>> {
430  const auto pos{extract_or(find_position(spn, what), spn.size())};
431  return {head(spn, pos), skip(spn, pos + what.size())};
432 }
433 //------------------------------------------------------------------------------
437 template <
438  typename T1,
439  typename P1,
440  typename S1,
441  typename T2,
442  typename P2,
443  typename S2>
444 static inline auto
447  return head(spn, extract_or(reverse_find_position(spn, what), spn.size()));
448 }
449 //------------------------------------------------------------------------------
453 template <
454  typename T1,
455  typename P1,
456  typename S1,
457  typename T2,
458  typename P2,
459  typename S2>
460 static inline auto
463  return skip(
464  spn,
465  extract_or(reverse_find_position(spn, what), spn.size()) + what.size());
466 }
467 //------------------------------------------------------------------------------
471 template <
472  typename T1,
473  typename P1,
474  typename S1,
475  typename T2,
476  typename P2,
477  typename S2>
478 static inline auto
480  -> std::tuple<basic_span<T1, P1, S1>, basic_span<T1, P1, S1>> {
481  const auto pos{extract_or(reverse_find_position(spn, what), spn.size())};
482  return {head(spn, pos), skip(spn, pos + what.size())};
483 }
484 //------------------------------------------------------------------------------
488 template <typename T, typename P, typename S, typename B>
489 static inline auto
490 slice_inside_brackets(basic_span<T, P, S> spn, B left, B right) noexcept
492 
493  if(auto found = find_element(spn, left)) {
494  spn = skip(spn, extract(found));
495  int depth = 1;
496  auto pos = S(1);
497  while((pos < spn.size()) && (depth > 0)) {
498  if(are_equal(spn[pos], left)) {
499  ++depth;
500  } else if(are_equal(spn[pos], right)) {
501  --depth;
502  }
503  ++pos;
504  }
505  return shrink(head(spn, pos), 1);
506  }
507 
508  return {};
509 }
510 //------------------------------------------------------------------------------
516 template <
517  typename TF,
518  typename PF,
519  typename SF,
520  typename TT,
521  typename PT,
522  typename ST>
525  EAGINE_ASSERT(from.size() <= to.size());
526  std::copy(from.begin(), from.end(), to.begin());
527  return head(to, from.size());
528 }
529 //------------------------------------------------------------------------------
535 template <typename T, typename P, typename S, typename V>
536 static inline auto fill(basic_span<T, P, S> spn, const V& v)
538  std::fill(spn.begin(), spn.end(), v);
539  return spn;
540 }
541 //------------------------------------------------------------------------------
547 template <typename T, typename P, typename S>
548 static inline auto zero(basic_span<T, P, S> spn) -> std::enable_if_t<
549  std::is_integral_v<T> || std::is_floating_point_v<T>,
551  std::fill(spn.begin(), spn.end(), T(0));
552  return spn;
553 }
554 //------------------------------------------------------------------------------
560 template <typename T, typename P, typename S>
561 static inline auto reverse(basic_span<T, P, S> spn) -> basic_span<T, P, S> {
562  std::reverse(spn.begin(), spn.end());
563  return spn;
564 }
565 //------------------------------------------------------------------------------
571 template <typename T, typename P, typename S, typename Transform>
572 static inline auto transform(basic_span<T, P, S> spn, Transform function)
574  std::transform(spn.begin(), spn.end(), spn.begin(), std::move(function));
575  return spn;
576 }
577 //------------------------------------------------------------------------------
583 template <typename T, typename P, typename S, typename Generator>
584 static inline auto generate(basic_span<T, P, S> spn, Generator gen)
586  std::generate(spn.begin(), spn.end(), std::move(gen));
587  return spn;
588 }
589 //------------------------------------------------------------------------------
595 template <typename T, typename P, typename S, typename RandGen>
596 static inline auto shuffle(basic_span<T, P, S> spn, RandGen rg)
598  std::shuffle(spn.begin(), spn.end(), std::move(rg));
599  return spn;
600 }
601 //------------------------------------------------------------------------------
608 template <typename T, typename P, typename S>
609 static inline auto sort(basic_span<T, P, S> spn) -> basic_span<T, P, S> {
610  std::sort(spn.begin(), spn.end());
611  return spn;
612 }
613 //------------------------------------------------------------------------------
620 template <typename T, typename P, typename S, typename Compare>
621 static inline auto sort(basic_span<T, P, S> spn, Compare compare)
623  std::sort(spn.begin(), spn.end(), std::move(compare));
624  return spn;
625 }
626 //------------------------------------------------------------------------------
632 template <
633  typename T,
634  typename P,
635  typename S,
636  typename I,
637  typename PI,
638  typename SI,
639  typename Compare>
640 static inline auto
642  -> bool {
643  if(spn.size() == idx.size()) {
644  std::sort(idx.begin(), idx.end(), [spn, &compare](auto& l, auto& r) {
645  return compare(spn[l], spn[r]);
646  });
647  }
648  return false;
649 }
650 //------------------------------------------------------------------------------
656 template <typename T, typename P, typename S, typename I, typename PI, typename SI>
657 static inline auto
659  return make_index(spn, idx, std::less<T>());
660 }
661 //------------------------------------------------------------------------------
667 template <typename T, typename P, typename S>
668 static inline auto is_sorted(basic_span<T, P, S> spn) -> bool {
669  return std::is_sorted(spn.begin(), spn.end());
670 }
671 //------------------------------------------------------------------------------
677 template <typename T, typename P, typename S, typename Compare>
678 static inline auto is_sorted(basic_span<T, P, S> spn, Compare compare) -> bool {
679  return std::is_sorted(spn.begin(), spn.end(), std::move(compare));
680 }
681 //------------------------------------------------------------------------------
686 template <typename T, typename P, typename S, typename Predicate>
687 static inline auto all_of(basic_span<T, P, S> spn, Predicate predicate)
688  -> bool {
689  return std::all_of(spn.begin(), spn.end(), std::move(predicate));
690 }
691 //------------------------------------------------------------------------------
696 template <typename T, typename P, typename S, typename Predicate>
697 static inline auto any_of(basic_span<T, P, S> spn, Predicate predicate)
698  -> bool {
699  return std::any_of(spn.begin(), spn.end(), std::move(predicate));
700 }
701 //------------------------------------------------------------------------------
706 template <typename T, typename P, typename S, typename Predicate>
707 static inline auto none_of(basic_span<T, P, S> spn, Predicate predicate)
708  -> bool {
709  return std::none_of(spn.begin(), spn.end(), std::move(predicate));
710 }
711 //------------------------------------------------------------------------------
715 template <
716  typename T1,
717  typename P1,
718  typename S1,
719  typename T2,
720  typename P2,
721  typename S2,
722  typename UnaryOperation>
723 static inline void for_each_delimited(
726  UnaryOperation unary_op) {
727  basic_span<T1, P1, S1> tmp = spn;
728  while(auto pos = find_position(tmp, delim)) {
729  unary_op(head(tmp, extract(pos)));
730  tmp = skip(tmp, extract(pos) + delim.size());
731  }
732  unary_op(tmp);
733 }
734 //------------------------------------------------------------------------------
738 template <typename T, typename P, typename S, typename UnaryOperation>
739 static inline void for_each_chunk(
741  const span_size_t len,
742  UnaryOperation unary_op) {
743  span_size_t pos{0};
744  while(pos < spn.size()) {
745  unary_op(slice(spn, pos, len));
746  pos += len;
747  }
748 }
749 //------------------------------------------------------------------------------
752 template <
753  typename Result,
754  typename T,
755  typename P1,
756  typename S1,
757  typename P2,
758  typename S2,
759  typename BinaryFunction>
763  BinaryFunction get_distance) -> Result {
764  const auto l1 = s1.size();
765  const auto l2 = s2.size();
766 
767  std::vector<Result> column(std_size(l1 + 1));
768  std::iota(column.begin(), column.end(), Result(0));
769 
770  for(span_size_t x = 1; x <= l2; x++) {
771  column[0] = Result(x);
772  auto prev_diagonal = Result(x) - 1;
773 
774  for(span_size_t y = 1; y <= l1; y++) {
775  const auto curr_diagonal = column[y];
776  const auto prev_min = std::min(column[y] + 1, column[y - 1] + 1);
777  const auto new_dist =
778  prev_diagonal + Result(get_distance(s1[y - 1], s2[x - 1]));
779  column[y] = std::min(prev_min, new_dist);
780  prev_diagonal = curr_diagonal;
781  }
782  }
783  return column[l1];
784 }
785 //------------------------------------------------------------------------------
786 template <typename T, typename P1, typename S1, typename P2, typename S2>
787 static auto default_edit_distance(
790  return basic_edit_distance<span_size_t>(
791  s1, s2, [](auto e1, auto e2) { return e1 == e2 ? 0 : 1; });
792 }
793 //------------------------------------------------------------------------------
794 } // namespace eagine::memory
795 #endif // EAGINE_MEMORY_SPAN_ALGO_HPP
static constexpr auto find_position(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> optionally_valid< S1 >
Finds the position of the first occurrence of what in a span.
Definition: span_algo.hpp:260
static constexpr auto slice(basic_span< T, P, S > s, I i, L l) noexcept -> basic_span< T, P, S >
Returns a slice of span starting at specified index with specified length.
Definition: span_algo.hpp:47
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
static constexpr auto ends_with(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
Indicates if span spn ends with the content of with.
Definition: span_algo.hpp:187
static auto slice_after(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Returns a slice of span after the first occurrence of what.
Definition: span_algo.hpp:411
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
static constexpr auto find_element(basic_span< T, P, S > spn, E what) noexcept -> optionally_valid< S >
Finds the position of the first occurrence of what in a span.
Definition: span_algo.hpp:279
Primary template for conditionally valid values.
Definition: decl.hpp:49
static constexpr auto strip_prefix(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > prefix) -> basic_span< T1, P1, S1 >
Strips the specified prefix from a span.
Definition: span_algo.hpp:203
static constexpr auto reverse_find_position(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> optionally_valid< S1 >
Finds the position of the last occurrence of what in a span.
Definition: span_algo.hpp:348
static constexpr auto find_element_if(basic_span< T, P, S > spn, F predicate) noexcept -> optionally_valid< S >
Finds the position of the first element satisfying predicate in a span.
Definition: span_algo.hpp:299
static auto find(basic_span< T1, P1, S1 > where, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Finds the position of the last occurrence of what in a span.
Definition: span_algo.hpp:374
static auto shuffle(basic_span< T, P, S > spn, RandGen rg) -> basic_span< T, P, S >
Shuffles the elements of a span.
Definition: span_algo.hpp:596
static constexpr auto take_until(basic_span< T, P, S > spn, Predicate predicate) noexcept -> basic_span< T, P, S >
Takes the elements from the front of a span until predicate is satisfied.
Definition: span_algo.hpp:329
static auto none_of(basic_span< T, P, S > spn, Predicate predicate) -> bool
Indicates if no elements in a span satisfy predicate.
Definition: span_algo.hpp:707
static auto basic_edit_distance(basic_span< const T, P1, S1 > s1, basic_span< const T, P2, S2 > s2, BinaryFunction get_distance) -> Result
Calculates the edit distance of s1 and s2 according to get_distance.
Definition: span_algo.hpp:760
static auto all_of(basic_span< T, P, S > spn, Predicate predicate) -> bool
Indicates if all elements in a span satisfy predicate.
Definition: span_algo.hpp:687
static auto split_by_last(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> std::tuple< basic_span< T1, P1, S1 >, basic_span< T1, P1, S1 >>
Splits a span by the last occurrence of what (before and after, what)
Definition: span_algo.hpp:479
static auto reverse(basic_span< T, P, S > spn) -> basic_span< T, P, S >
Reverses the elements in a span.
Definition: span_algo.hpp:561
static constexpr auto snip(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Snips a specified count of elements from the back of a span.
Definition: span_algo.hpp:73
static auto slice_before_last(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Returns a slice of span before the last occurrence of what.
Definition: span_algo.hpp:445
static auto slice_inside_brackets(basic_span< T, P, S > spn, B left, B right) noexcept -> basic_span< T, P, S >
Returns a slice of span within a pair of brackets.
Definition: span_algo.hpp:490
static auto any_of(basic_span< T, P, S > spn, Predicate predicate) -> bool
Indicates if any elements in a span satisfy predicate.
Definition: span_algo.hpp:697
static constexpr auto std_size(T v) noexcept
Converts argument to std size type.
Definition: types.hpp:52
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
static constexpr auto skip(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Skips a specified count of elements from the front of a span.
Definition: span_algo.hpp:60
static auto fill(basic_span< T, P, S > spn, const V &v) -> basic_span< T, P, S >
Fills a span with copies of the specified value.
Definition: span_algo.hpp:536
static auto generate(basic_span< T, P, S > spn, Generator gen) -> basic_span< T, P, S >
Fills a span with elements generated by a generator callable.
Definition: span_algo.hpp:584
static auto transform(basic_span< T, P, S > spn, Transform function) -> basic_span< T, P, S >
Transforms the elements of a span with a function.
Definition: span_algo.hpp:572
static auto copy(basic_span< TF, PF, SF > from, basic_span< TT, PT, ST > to) -> basic_span< TT, PT, ST >
Copies the elements from one span to another compatible span.
Definition: span_algo.hpp:523
static void for_each_delimited(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > delim, UnaryOperation unary_op)
Scans span for parts split by delimiter, calls a function for each part.
Definition: span_algo.hpp:723
static constexpr auto head(basic_span< Ts, Ps, Ss > s, basic_span< Tl, Pl, Sl > l) noexcept -> basic_span< Ts, Ps, Ss >
Returns the head of s l.size() elements long.
Definition: span_algo.hpp:119
static auto split_by_first(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> std::tuple< basic_span< T1, P1, S1 >, basic_span< T1, P1, S1 >>
Splits a span by the first occurrence of what (before and after, what)
Definition: span_algo.hpp:428
static auto is_sorted(basic_span< T, P, S > spn, Compare compare) -> bool
Tests if the elements in a span are sorted according to compare.
Definition: span_algo.hpp:678
static auto zero(basic_span< T, P, S > spn) -> std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >, basic_span< T, P, S >>
Fills a span with zero value of type T.
Definition: span_algo.hpp:548
static auto slice_after_last(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Returns a slice of span after the last occurrence of what.
Definition: span_algo.hpp:461
constexpr auto size() const noexcept -> size_type
Returns the number of elements in the span.
Definition: span.hpp:246
static constexpr auto column(const matrix< T, C, R, false, V > &m) noexcept -> vector< T, R, V >
Returns the I-th column vector of a matrix. Column-major implementation.
Definition: matrix.hpp:428
static constexpr auto contains(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> S1
Indicates if a span contains the contents of what.
Definition: span_algo.hpp:237
static auto sort(basic_span< T, P, S > spn, Compare compare) -> basic_span< T, P, S >
Sorts the elements of a span according to compare.
Definition: span_algo.hpp:621
static constexpr auto tail(basic_span< Ts, Ps, Ss > s, basic_span< Tl, Pl, Sl > l) noexcept -> basic_span< Ts, Ps, Ss >
Returns the tail of s l.size() elements long.
Definition: span_algo.hpp:152
static constexpr auto shrink(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Shrinks a span by removing a specified count of elements from both sides.
Definition: span_algo.hpp:86
static void for_each_chunk(basic_span< T, P, S > spn, const span_size_t len, UnaryOperation unary_op)
Splits span into parts of equal length, calls a function for each part.
Definition: span_algo.hpp:739
static constexpr auto starts_with(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > with) -> bool
Indicates if span spn starts with the content of with.
Definition: span_algo.hpp:170
static constexpr auto strip_suffix(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > suffix) -> basic_span< T1, P1, S1 >
Strips the specified suffix from a span.
Definition: span_algo.hpp:220
static auto make_index(basic_span< T, P, S > spn, basic_span< I, PI, SI > idx) -> bool
Makes the index of a span, into another span.
Definition: span_algo.hpp:658
static constexpr auto skip_until(basic_span< T, P, S > spn, Predicate predicate) noexcept -> basic_span< T, P, S >
Skips the elements from the front of a span until predicate is satisfied.
Definition: span_algo.hpp:316
static auto slice_before(basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) -> basic_span< T1, P1, S1 >
Returns a slice of span before the first occurrence of what.
Definition: span_algo.hpp:394

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).