Exemple #1
0
        /// <summary>
        ///     Create a hash set containing all elements from the input
        ///     sequence.
        /// </summary>
        public static HashSet <TOut> ToHashSet <TOut>(
            this SpanEnumerable <TOut> spanEnum)
        {
            var set = new HashSet <TOut>();

            spanEnum.CopyInto(set);
            return(set);
        }
Exemple #2
0
        /// <summary>
        ///     Create a hash set containing all elements from the input
        ///     sequence.
        /// </summary>
        public static HashSet <TOut> ToHashSet <TIn, TOut, TProducer>(
            this SpanEnumerable <TIn, TOut, TProducer> spanEnum)
            where TProducer : IProducer <TIn, TOut>
        {
            var set = new HashSet <TOut>();

            spanEnum.CopyInto(set);
            return(set);
        }
Exemple #3
0
        /// <summary>
        ///     Create a list containing all elements from the input
        ///     sequence.
        /// </summary>
        public static List <TOut> ToList <TOut>(this SpanEnumerable <TOut> spanEnum)
        {
            var list = spanEnum.KnownLength
                ? new List <TOut>(spanEnum.Length)
                : new List <TOut>();

            spanEnum.CopyInto(list);

            return(list);
        }
Exemple #4
0
        /// <summary>
        ///     Create a list containing all elements from the input
        ///     sequence.
        /// </summary>
        public static List <TOut> ToList <TIn, TOut, TProducer>(
            this SpanEnumerable <TIn, TOut, TProducer> spanEnum)
            where TProducer : IProducer <TIn, TOut>
        {
            var list = spanEnum.KnownLength
                ? new List <TOut>(spanEnum.Length)
                : new List <TOut>();

            spanEnum.CopyInto(list);

            return(list);
        }
Exemple #5
0
        /// <summary>
        ///     Create a dictionary containing all elements from the input
        ///     sequence.
        /// </summary>
        public static Dictionary <TK, TV> ToDictionary <TOut, TK, TV>(
            this SpanEnumerable <TOut> spanEnum,
            Func <TOut, TK> key,
            Func <TOut, TV> value)
        {
            var dict = spanEnum.KnownLength
                ? new Dictionary <TK, TV>(spanEnum.Length)
                : new Dictionary <TK, TV>();

            spanEnum.CopyInto(dict, key, value);

            return(dict);
        }
Exemple #6
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());
Exemple #7
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());
 /// <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();
Exemple #9
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();