/// <summary> /// The first element of a sequence that satisfies a predicate. /// </summary> public static TOut Last <TOut, TProducer>( this SpanEnumerable <TOut, TProducer> spanEnum, Predicate <TOut> predicate) where TProducer : struct, IProducer <TOut> => spanEnum.Where(predicate).Last();
/// <summary> /// Takes values from the sequence to fill the /// provided array, throws if the array is not large enough to /// contain all elements from the sequence. /// </summary> /// <returns> /// Returns the span, maybe resized if /// there were not enough values in the enumerable. /// </returns> public static Span <TOut> CopyInto <TOut>( this SpanEnumerable <TOut> spanEnum, TOut[] output) => spanEnum.CopyInto(output.AsSpan());
/// <summary> /// Takes enough values from the sequence to fill the provided span. /// </summary> /// <remarks> /// A copy of the enumerable is taken, which means that (beyond any /// side-effects of consuming values from it) the original /// enumerable is unchanged. /// </remarks> /// <returns> /// Returns the span, maybe resized if there were not enough values /// in the enumerable. /// </returns> public static Span <TOut> TakeInto <TOut>( this SpanEnumerable <TOut> self, Span <TOut> output) => self.ConsumeInto(output);
/// <summary> Copy a sequence into a span, in reverse. </summary> public static Span<TOut> ReverseInto<TIn, TOut, TProducer>( this SpanEnumerable<TIn, TOut, TProducer> spanEnum, Span<TOut> output) where TProducer : struct, IProducer<TIn, TOut> => spanEnum.CopyInto(output).ReverseInPlace();
/// <summary> /// Takes values from the sequence to fill the /// provided array, throws if the array is not large enough to /// contain all elements from the sequence. /// </summary> /// <returns> /// Returns the span, maybe resized if /// there were not enough values in the enumerable. /// </returns> public static Span <TOut> CopyInto <TOut, TProducer>( this SpanEnumerable <TOut, TProducer> spanEnum, TOut[] output) where TProducer : IProducer <TOut> => spanEnum.CopyInto(output.AsSpan());
/// <summary> /// The last element of a sequence that satisfies a predicate. /// </summary> public static TOut LastOrDefault <TOut>( this SpanEnumerable <TOut> spanEnum, Predicate <TOut> predicate) => spanEnum.Where(predicate).LastOrDefault();
/// <summary> /// The first element of a sequence that satisfies a predicate. /// </summary> public static TOut FirstOrDefault <TOut, TProducer>( this SpanEnumerable <TOut, TProducer> spanEnum, Predicate <TOut> predicate) where TProducer : struct, IProducer <TOut> => spanEnum.Where(predicate).FirstOrDefault();
public Enumerator(SpanEnumerable <TOut> e) { _enum = e; Current = default; }
/// <summary> /// The single element of a sequence that satisfies a predicate. /// </summary> public static TOut Single <TIn, TOut, TProducer>( this SpanEnumerable <TIn, TOut, TProducer> spanEnum, Predicate <TOut> predicate) where TProducer : struct, IProducer <TIn, TOut> => spanEnum.Where(predicate).Single();
/// <summary> /// The first element of a sequence that satisfies a predicate. /// </summary> public static TOut First <TOut>( this SpanEnumerable <TOut> spanEnum, Predicate <TOut> predicate) => spanEnum.Where(predicate).First();
/// <summary> Copy a sequence into a span, in reverse. </summary> public static Span <TOut> ReverseInto <TOut>( this SpanEnumerable <TOut> spanEnum, Span <TOut> output) => spanEnum.CopyInto(output).ReverseInPlace();
/// <summary> /// The sum of a sequence, with a delegate returning an integer /// for each element of the sequence. /// </summary> public static int Sum <TIn, TOut, TProducer>( this SpanEnumerable <TIn, TOut, TProducer> spanEnum, Func <TOut, int> getValue) where TProducer : struct, IProducer <TIn, TOut> => spanEnum.Select(getValue).Sum();
/// <summary> /// The sum of a sequence, with a delegate returning an integer /// for each element of the sequence. /// </summary> public static int Sum <TOut>( this SpanEnumerable <TOut> spanEnum, Func <TOut, int> getValue) => spanEnum.Select(getValue).Sum();
/// <summary> /// The single element of a sequence that satisfies a predicate. /// </summary> public static TOut Single <TOut>( this SpanEnumerable <TOut> spanEnum, Predicate <TOut> predicate) => spanEnum.Where(predicate).Single();