public ReadOnlySpan(T[] array, int start, int length)
 {
     Contract.Requires(array != null);
     Contract.RequiresInInclusiveRange(start, length, (uint)array.Length);
     if (start < array.Length)
     {
         Object = array;
         Offset = UnsafeUtilities.GetElementAddress <T>((UIntPtr)SpanHelpers <T> .OffsetToArrayData, (UIntPtr)start);
         Length = length;
     }
     else
     {
         Object = null;
         Offset = UIntPtr.Zero;
         Length = 0;
     }
 }
Exemple #2
0
 internal Span(T[] array, int start)
 {
     Contract.Requires(array != null);
     Contract.Requires(default(T) != null || array.GetType() == typeof(T[]));
     Contract.RequiresInInclusiveRange(start, (uint)array.Length);
     if (start < array.Length)
     {
         Object = array;
         Offset = UnsafeUtilities.GetElementAddress <T>((UIntPtr)SpanHelpers <T> .OffsetToArrayData, (UIntPtr)start);
         Length = array.Length - start;
     }
     else
     {
         Object = null;
         Offset = UIntPtr.Zero;
         Length = 0;
     }
 }
Exemple #3
0
 public Span <T> Slice(uint start, uint length)
 {
     Contract.RequiresInInclusiveRange(start, length, (uint)Length);
     return(new Span <T>(
                Object, UnsafeUtilities.GetElementAddress <T>(Offset, (UIntPtr)start), (int)length));
 }
 public ReadOnlySpan <T> Slice(uint start)
 {
     Contract.RequiresInInclusiveRange(start, (uint)Length);
     return(new ReadOnlySpan <T>(Object, UnsafeUtilities.GetElementAddress <T>(Offset, (UIntPtr)start), Length - (int)start));
 }