SpanHelpers
Computes "start + index * sizeof(T)", using the unsigned IntPtr-sized multiplication for 32 and 64 bits.
Assumptions:
Start and index are non-negative, and already pre-validated to be within the valid range of their containing Span.
If the byte length (Span.Length * sizeof(T)) does an unsigned overflow (i.e. the buffer wraps or is too big to fit within the address space),
the behavior is undefined.
public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T>
public static int BinarySearch<T, TComparable>(ref T spanStart, int length, TComparable comparable) where TComparable : IComparable<T>
Implements the copy functionality used by Span and ReadOnlySpan.
NOTE: Fast span implements TryCopyTo in corelib and therefore this implementation
is only used by portable span. The code must live in code that only compiles
for portable span which means either each individual span implementation
of this shared code file. Other shared SpanHelper.X.cs files are compiled
for both portable and fast span implementations.
public static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
public static int IndexOf<T>(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable<T>
public static int IndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
public static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
public static int IndexOfAny<T>(ref T searchSpace, T value0, T value1, int length) where T : IEquatable<T>
public static int IndexOfAny<T>(ref T searchSpace, T value0, T value1, T value2, int length) where T : IEquatable<T>
public static int IndexOfAny<T>(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable<T>
Determine if a type is eligible for storage in unmanaged memory.
Portable equivalent of RuntimeHelpers.IsReferenceOrContainsReferences{T}()
public static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
public static int LastIndexOf<T>(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable<T>
public static int LastIndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength)
public static int LastIndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
public static int LastIndexOfAny<T>(ref T searchSpace, T value0, T value1, int length) where T : IEquatable<T>
public static int LastIndexOfAny<T>(ref T searchSpace, T value0, T value1, T value2, int length) where T : IEquatable<T>
public static int LastIndexOfAny<T>(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable<T>
public static int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
public static int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength)
public static int SequenceCompareTo<T>(ref T first, int firstLength, ref T second, int secondLength) where T : IComparable<T>