Exemplo n.º 1
0
        /// <summary>
        /// Creates a repeated sequencer that is defined by the given element type and the
        /// type of the sequencer.
        /// </summary>
        /// <typeparam name="T">The element type.</typeparam>
        /// <typeparam name="TStride">The 1D stride of the target view.</typeparam>
        /// <typeparam name="TSequencer">The type of the sequencer to use.</typeparam>
        /// <param name="accelerator">The accelerator.</param>
        /// <returns>The loaded sequencer.</returns>
        public static RepeatedSequencer <T, TStride, TSequencer> CreateRepeatedSequencer <
            T,
            TStride,
            TSequencer>(
            this Accelerator accelerator)
            where T : unmanaged
            where TStride : struct, IStride1D
            where TSequencer : struct, ISequencer <T>
        {
            var rawSequencer = accelerator.CreateRawSequencer <T, TStride, TSequencer>();

            return((stream, view, sequenceLength, sequencer) =>
            {
                if (!view.IsValid)
                {
                    throw new ArgumentNullException(nameof(view));
                }
                if (view.Length < 1)
                {
                    throw new ArgumentOutOfRangeException(nameof(view));
                }
                if (sequenceLength < 1)
                {
                    throw new ArgumentOutOfRangeException(nameof(sequenceLength));
                }
                rawSequencer(
                    stream,
                    view.Length,
                    new SequenceImplementation <T, TStride, TSequencer>(
                        sequenceLength,
                        1L,
                        view,
                        sequencer));
            });
        }