#include "span.hpp"
#include <algorithm>
#include <numeric>
#include <tuple>
#include <type_traits>
#include <vector>
Go to the source code of this file.
Namespaces | |
eagine | |
Common code is placed in this namespace. | |
Functions | |
template<typename T , typename P , typename S , typename I , typename L > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename L > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename L > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename L > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename L > | |
static constexpr auto | eagine::memory::head (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S > |
Returns the first l elements from the front of a span. More... | |
template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename L > | |
static constexpr auto | eagine::memory::tail (basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S > |
Returns the last l elements from the back of a span. More... | |
template<typename Ts , typename Ps , typename Ss , typename Tl , typename Pl , typename Sl > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::contains (basic_span< T1, P1, S1 > spn, basic_span< T2, P2, S2 > what) noexcept -> S1 |
Indicates if a span contains the contents of what . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename E > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename F > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename Predicate > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename Predicate > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static constexpr auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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. More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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) More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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 . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 > | |
static auto | eagine::memory::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) More... | |
template<typename T , typename P , typename S , typename B > | |
static auto | eagine::memory::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. More... | |
template<typename TF , typename PF , typename SF , typename TT , typename PT , typename ST > | |
static auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename V > | |
static auto | eagine::memory::fill (basic_span< T, P, S > spn, const V &v) -> basic_span< T, P, S > |
Fills a span with copies of the specified value. More... | |
template<typename T , typename P , typename S > | |
static auto | eagine::memory::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. More... | |
template<typename T , typename P , typename S > | |
static auto | eagine::memory::reverse (basic_span< T, P, S > spn) -> basic_span< T, P, S > |
Reverses the elements in a span. More... | |
template<typename T , typename P , typename S , typename Transform > | |
static auto | eagine::memory::transform (basic_span< T, P, S > spn, Transform function) -> basic_span< T, P, S > |
Transforms the elements of a span with a function . More... | |
template<typename T , typename P , typename S , typename Generator > | |
static auto | eagine::memory::generate (basic_span< T, P, S > spn, Generator gen) -> basic_span< T, P, S > |
Fills a span with elements generated by a generator callable. More... | |
template<typename T , typename P , typename S , typename RandGen > | |
static auto | eagine::memory::shuffle (basic_span< T, P, S > spn, RandGen rg) -> basic_span< T, P, S > |
Shuffles the elements of a span. More... | |
template<typename T , typename P , typename S > | |
static auto | eagine::memory::sort (basic_span< T, P, S > spn) -> basic_span< T, P, S > |
Sorts the elements of a span. More... | |
template<typename T , typename P , typename S , typename Compare > | |
static auto | eagine::memory::sort (basic_span< T, P, S > spn, Compare compare) -> basic_span< T, P, S > |
Sorts the elements of a span according to compare . More... | |
template<typename T , typename P , typename S , typename I , typename PI , typename SI , typename Compare > | |
static auto | eagine::memory::make_index (basic_span< T, P, S > spn, basic_span< I, PI, SI > idx, Compare compare) -> bool |
Makes the index of a span according to compare , into another span. More... | |
template<typename T , typename P , typename S , typename I , typename PI , typename SI > | |
static auto | eagine::memory::make_index (basic_span< T, P, S > spn, basic_span< I, PI, SI > idx) -> bool |
Makes the index of a span, into another span. More... | |
template<typename T , typename P , typename S > | |
static auto | eagine::memory::is_sorted (basic_span< T, P, S > spn) -> bool |
Tests if the elements in a span are sorted. More... | |
template<typename T , typename P , typename S , typename Compare > | |
static auto | eagine::memory::is_sorted (basic_span< T, P, S > spn, Compare compare) -> bool |
Tests if the elements in a span are sorted according to compare . More... | |
template<typename T , typename P , typename S , typename Predicate > | |
static auto | eagine::memory::all_of (basic_span< T, P, S > spn, Predicate predicate) -> bool |
Indicates if all elements in a span satisfy predicate . More... | |
template<typename T , typename P , typename S , typename Predicate > | |
static auto | eagine::memory::any_of (basic_span< T, P, S > spn, Predicate predicate) -> bool |
Indicates if any elements in a span satisfy predicate . More... | |
template<typename T , typename P , typename S , typename Predicate > | |
static auto | eagine::memory::none_of (basic_span< T, P, S > spn, Predicate predicate) -> bool |
Indicates if no elements in a span satisfy predicate . More... | |
template<typename T1 , typename P1 , typename S1 , typename T2 , typename P2 , typename S2 , typename UnaryOperation > | |
static void | eagine::memory::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. More... | |
template<typename T , typename P , typename S , typename UnaryOperation > | |
static void | eagine::memory::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. More... | |
template<typename Result , typename T , typename P1 , typename S1 , typename P2 , typename S2 , typename BinaryFunction > | |
static auto | eagine::memory::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. | |
Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt