static IMemoryOwner <TResult> ToArray <TSource, TResult>(this ReadOnlySpan <TSource> source, NullableSelectorAt <TSource, TResult> selector, MemoryPool <TResult> pool)
        {
            var result = pool.RentSliced(source.Length);

            ArrayExtensions.Copy(source, result.Memory.Span, selector);
            return(result);
        }
Пример #2
0
        public static IMemoryOwner <TSource> ToArray <TSource>(this ReadOnlySpan <TSource> source, MemoryPool <TSource> pool)
        {
            var result = pool.RentSliced(source.Length);

            Copy(source, result.Memory.Span);
            return(result);
        }
        static IMemoryOwner <TSource> ToArray <TList, TSource>(this TList source, int offset, int count, MemoryPool <TSource> pool)
            where TList : IReadOnlyList <TSource>
        {
            var result = pool.RentSliced(count);

            Copy(source, offset, result.Memory.Span, count);
            return(result);
        }
Пример #4
0
        static IMemoryOwner <TResult> ToArrayAtRef <TSource, TResult, TSelector>(this ReadOnlySpan <TSource> source, TSelector selector, MemoryPool <TResult> pool)
            where TSelector : struct, IFunctionIn <TSource, int, TResult>
        {
            var result = pool.RentSliced(source.Length);

            CopyAtRef(source, result.Memory.Span, selector);
            return(result);
        }
        static IMemoryOwner <TResult> ToArrayAt <TList, TSource, TResult, TSelector>(this TList source, TSelector selector, int offset, int count, MemoryPool <TResult> pool)
            where TList : IReadOnlyList <TSource>
            where TSelector : struct, IFunction <TSource, int, TResult>
        {
            var result = pool.RentSliced(count);

            CopyAt <TList, TSource, TResult, TSelector>(source, offset, result.Memory.Span, count, selector);
            return(result);
        }
Пример #6
0
        public static IMemoryOwner <TSource> ToArray <TEnumerable, TEnumerator, TSource>(this TEnumerable source, MemoryPool <TSource> pool)
            where TEnumerable : IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
            var result = pool.RentSliced(source.Count);

            Copy <TEnumerable, TEnumerator, TSource>(source, result.Memory.Span);
            return(result);
        }
        public readonly IMemoryOwner <T> ToArray(MemoryPool <T> pool)
        {
            Debug.Assert(pool is object);

            var result = pool.RentSliced(Count);

            CopyTo(result.Memory.Span);
            return(result);
        }
Пример #8
0
        static IMemoryOwner <TSource> ToArray <TList, TSource>(this TList source, int offset, int count, MemoryPool <TSource> pool)
            where TList : notnull, IReadOnlyList <TSource>
        {
            Debug.Assert(pool is object);

            var result = pool.RentSliced(count);

            ReadOnlyListExtensions.Copy <TList, TSource>(source, offset, result.Memory.Span, count);
            return(result);
        }
Пример #9
0
        static IMemoryOwner <TResult> ToArrayAt <TEnumerable, TEnumerator, TSource, TResult, TSelector>(this TEnumerable source, TSelector selector, MemoryPool <TResult> pool)
            where TEnumerable : IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
            where TSelector : struct, IFunction <TSource, int, TResult>
        {
            var result = pool.RentSliced(source.Count);

            CopyAt <TEnumerable, TEnumerator, TSource, TResult, TSelector>(source, result.Memory.Span, selector);
            return(result);
        }
        static IMemoryOwner <TResult> ToArray <TEnumerable, TEnumerator, TSource, TResult>(this TEnumerable source, NullableSelectorAt <TSource, TResult> selector, MemoryPool <TResult> pool)
            where TEnumerable : notnull, IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
            Debug.Assert(pool is object);

            var result = pool.RentSliced(source.Count);

            ValueReadOnlyCollectionExtensions.Copy <TEnumerable, TEnumerator, TSource, TResult>(source, result.Memory.Span, selector);
            return(result);
        }
Пример #11
0
        static IMemoryOwner <TResult> ToArrayVector <TSource, TResult, TVectorSelector, TSelector>(this ReadOnlySpan <TSource> source, TVectorSelector vectorSelector, TSelector selector, MemoryPool <TResult> pool)
            where TVectorSelector : struct, IFunction <Vector <TSource>, Vector <TResult> >
            where TSelector : struct, IFunction <TSource, TResult>
            where TSource : struct
            where TResult : struct
        {
            var result = pool.RentSliced(source.Length);

            CopyVector <TSource, TResult, TVectorSelector, TSelector>(source, result.Memory.Span, vectorSelector, selector);
            return(result);
        }
        public static IMemoryOwner <TSource> ToArray <TSource>(this ReadOnlySpan <TSource> source, MemoryPool <TSource> pool)
        {
            if (pool is null)
            {
                Throw.ArgumentNullException(nameof(pool));
            }

            var result = pool.RentSliced(source.Length);

            ArrayExtensions.Copy(source, result.Memory.Span);
            return(result);
        }