Ejemplo n.º 1
0
 /// <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();
Ejemplo n.º 2
0
 /// <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());
Ejemplo n.º 3
0
 /// <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);
Ejemplo n.º 4
0
 /// <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();
Ejemplo n.º 5
0
 /// <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());
Ejemplo n.º 6
0
 /// <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();
Ejemplo n.º 7
0
 /// <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();
Ejemplo n.º 8
0
 public Enumerator(SpanEnumerable <TOut> e)
 {
     _enum   = e;
     Current = default;
 }
Ejemplo n.º 9
0
 /// <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();
Ejemplo n.º 10
0
 /// <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();
Ejemplo n.º 11
0
 /// <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();
Ejemplo n.º 12
0
 /// <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();
Ejemplo n.º 13
0
 /// <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();
Ejemplo n.º 14
0
 /// <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();