Exemple #1
0
        /// <summary>
        /// Creates a new span over the portion of the target array beginning
        /// at 'start' index and ending at 'end' index (exclusive).
        /// </summary>
        /// <param name="array">The target array.</param>
        /// <param name="start">The index at which to begin the span.</param>
        /// <param name="length">The number of items in the span.</param>
        public ReadOnlySpan(T[] array, int start, int length)
        {
            if ((uint)start >= (uint)array.Length || (uint)length > (uint)(array.Length - start))
            {
                ThrowHelper.ThrowArgumentOutOfRangeException();
            }

            JitHelpers.SetByRef(out _rawPointer, ref JitHelpers.AddByRef(ref JitHelpers.GetArrayData(array), start));
            _length = length;
        }
Exemple #2
0
 /// <summary>
 /// An internal helper for creating spans. Not for public use.
 /// </summary>
 private ReadOnlySpan(ref T ptr, int length)
 {
     JitHelpers.SetByRef(out _rawPointer, ref ptr);
     _length = length;
 }
Exemple #3
0
 /// <summary>
 /// Creates a new span over the entirety of the target array.
 /// </summary>
 /// <param name="array">The target array.</param>
 public ReadOnlySpan(T[] array)
 {
     JitHelpers.SetByRef(out _rawPointer, ref JitHelpers.GetArrayData(array));
     _length = array.Length;
 }