Exemplo 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();
Exemplo 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());
Exemplo 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);
Exemplo 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();
Exemplo 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());
Exemplo 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();
Exemplo 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();
Exemplo n.º 8
0
 public Enumerator(SpanEnumerable <TOut> e)
 {
     _enum   = e;
     Current = default;
 }
Exemplo 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();
Exemplo 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();
Exemplo 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();
Exemplo 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();
Exemplo 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();
Exemplo 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();