public Span(T[]?array) { if (array == null) { this = default; return; // returns default } if (default(T) ! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) { ThrowHelper.ThrowArrayTypeMismatchException(); } _pointer = new ByReference <T>(ref MemoryMarshal.GetArrayDataReference(array)); _length = array.Length; }
public Span(T[]?array) { if (array == null) { this = default; return; // returns default } if (default(T) ! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757 { ThrowHelper.ThrowArrayTypeMismatchException(); } _pointer = new ByReference <T>(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData())); _length = array.Length; }
public Span(T[] array) { if (array == null) { this = default; return; // returns default } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } _pointer = new ByReference <T>(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData())); _length = array.Length; }
public Span(T[]?array) { if (array == null) { this = default; return; // returns default } if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } _pointer = new ByReference <T>(ref MemoryMarshal.GetArrayDataReference(array)); _length = array.Length; }
public Memory(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } _arrayOrOwnedMemory = array; _index = 0; _length = array.Length; }
public Span(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } _length = array.Length; _pinnable = Unsafe.As <Pinnable <T> >(array); _byteOffset = SpanHelpers.PerTypeValues <T> .ArrayAdjustment; }
public Memory(T[] array) { if (array == null) { this = default; return; // returns default } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } _object = array; _index = 0; _length = array.Length; }
public Memory(T[]?array) { if (array == null) { this = default; return; // returns default } if (default(T) ! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757 { ThrowHelper.ThrowArrayTypeMismatchException(); } _object = array; _index = 0; _length = array.Length; }
/// <summary> /// Creates a new span over the entirety of the target array. /// </summary> /// <param name="array">The target array.</param> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null /// reference (Nothing in Visual Basic).</exception> /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception> public Span(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null) // Arrays of valuetypes are never covariant { if (array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } } _pointer = new ByReference <T>(ref JitHelpers.GetArrayData(array)); _length = array.Length; }
public Span(T[] array, int start, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetInternalTypeID() != RuntimeHelpers.GetInternalTypeID <T[]>()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _pointer = new ByReference <T>(ref Unsafe.Add(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData()), start)); _length = length; }
public Span(T[] array, int start) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _pointer = new ByReference <T>(ref Unsafe.Add(ref JitHelpers.GetArrayData(array), start)); _length = array.Length - start; }
/// <summary> /// Creates a new span over the entirety of the target array. /// </summary> /// <param name="array">The target array.</param> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null /// reference (Nothing in Visual Basic).</exception> /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant.</exception> public Span(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null) // Arrays of valuetypes are never covariant { if (array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } } // TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead _rawPointer = (IntPtr)Unsafe.AsPointer(ref JitHelpers.GetArrayData(array)); _length = array.Length; }
public Span(T[] array, int start, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start); } _length = length; _pinnable = Unsafe.As <Pinnable <T> >(array); _byteOffset = SpanHelpers.PerTypeValues <T> .ArrayAdjustment.Add <T>(start); }
public Memory(T[] array, int start, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = length; }
/// <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> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null /// reference (Nothing in Visual Basic).</exception> /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length). /// </exception> public Span(T[] array, int start, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null) // Arrays of valuetypes are never covariant { if (array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _pointer = new ByReference <T>(ref Unsafe.Add(ref JitHelpers.GetArrayData(array), start)); _length = length; }
/// <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> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="array"/> is a null /// reference (Nothing in Visual Basic).</exception> /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant.</exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// Thrown when the specified <paramref name="start"/> or end index is not in range (<0 or >&eq;Length). /// </exception> public Span(T[] array, int start, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (default(T) == null) // Arrays of valuetypes are never covariant { if (array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(); } // TODO-SPAN: This has GC hole. It needs to be JIT intrinsic instead _rawPointer = (IntPtr)Unsafe.AsPointer(ref Unsafe.Add(ref JitHelpers.GetArrayData(array), start)); _length = length; }
public Span(T[] array, int start, int length) { if (array == null) { if (start != 0 || length != 0) { ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default; return; // returns default } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _pointer = new ByReference <T>(ref Unsafe.Add(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData()), start)); _length = length; }
internal Memory(T[] array, int start) { if (array == null) { if (start != 0) { ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default; return; // returns default } if (default(T) == null && array.GetType() != typeof(T[])) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = array.Length - start; }
internal Memory(T[]?array, int start) { if (array == null) { if (start != 0) { ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default; return; // returns default } if (default(T) ! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757 { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = array.Length - start; }