Class Span
Provides extension methods for type Span<T> and ReadOnlySpan<T>.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Span
Methods
| Improve this Doc View SourceAsBytes<T>(T*)
Converts contiguous memory identified by the specified pointer into Span<T>.
Declaration
[CLSCompliant(false)]
public static Span<byte> AsBytes<T>(T*pointer)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T* | pointer | The typed pointer. |
Returns
Type | Description |
---|---|
Span<Byte> | The span of contiguous memory. |
Type Parameters
Name | Description |
---|---|
T | The type of the pointer. |
AsBytes<T>(ref T)
Converts contiguous memory identified by the specified pointer into Span<T>.
Declaration
public static Span<byte> AsBytes<T>(ref T value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T | value | The managed pointer. |
Returns
Type | Description |
---|---|
Span<Byte> | The span of contiguous memory. |
Type Parameters
Name | Description |
---|---|
T | The type of the pointer. |
AsReadOnlyBytes<T>(T)
Converts contiguous memory identified by the specified pointer into ReadOnlySpan<T>.
Declaration
public static ReadOnlySpan<byte> AsReadOnlyBytes<T>(in T value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T | value | The managed pointer. |
Returns
Type | Description |
---|---|
ReadOnlySpan<Byte> | The span of contiguous memory. |
Type Parameters
Name | Description |
---|---|
T | The type of the pointer. |
AsReadOnlySpan<T>(ValueTuple)
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in ValueTuple tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T, T, T, T, T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T, T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T, T, T, T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T, T, T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T, T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T, T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsReadOnlySpan<T>((T))
Obtains read-only span over tuple items.
Declaration
public static ReadOnlySpan<T> AsReadOnlySpan<T>(this in (T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref ValueTuple)
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref ValueTuple tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T, T, T, T, T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T, T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T, T, T, T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T, T, T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T, T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T, T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T, T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T, T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
AsSpan<T>(ref (T))
Obtains a span over tuple items.
Declaration
public static Span<T> AsSpan<T>(this ref (T) tuple)
Parameters
Type | Name | Description |
---|---|---|
ValueTuple<T> | tuple | The tuple. |
Returns
Type | Description |
---|---|
Span<T> | The span over items in the tuple. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the tuple. |
BitwiseCompare<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Compares content of the two memory blocks identified by the given spans.
Declaration
public static int BitwiseCompare<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | first | The first memory span to compare. |
ReadOnlySpan<T> | second | The second array to compare. |
Returns
Type | Description |
---|---|
Int32 | Comparison result. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseCompare<T>(Span<T>, Span<T>)
Compares content of the two memory blocks identified by the given spans.
Declaration
public static int BitwiseCompare<T>(this Span<T> first, Span<T> second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | first | The first memory span to compare. |
Span<T> | second | The second array to compare. |
Returns
Type | Description |
---|---|
Int32 | Comparison result. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseEquals<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Determines whether two memory blocks identified by the given spans contain the same set of elements.
Declaration
public static bool BitwiseEquals<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | first | The first memory span to compare. |
ReadOnlySpan<T> | second | The second memory span to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if both memory blocks are equal; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
Remarks
This method performs bitwise equality between each pair of elements.
BitwiseEquals<T>(Span<T>, Span<T>)
Determines whether two memory blocks identified by the given spans contain the same set of elements.
Declaration
public static bool BitwiseEquals<T>(this Span<T> first, Span<T> second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | first | The first memory span to compare. |
Span<T> | second | The second memory span to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if both memory blocks are equal; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
Remarks
This method performs bitwise equality between each pair of elements.
BitwiseHashCode<T>(ReadOnlySpan<T>, Boolean)
Computes bitwise hash code for the memory identified by the given span.
Declaration
public static int BitwiseHashCode<T>(this ReadOnlySpan<T> span, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the span content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode<T>(ReadOnlySpan<T>, Int32, ValueFunc<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this ReadOnlySpan<T> span, int hash, in ValueFunc<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Int32 | hash | Initial value of the hash. |
ValueFunc<Int32, Int32, Int32> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode<T>(ReadOnlySpan<T>, Int32, Func<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this ReadOnlySpan<T> span, int hash, Func<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Int32 | hash | Initial value of the hash. |
Func<Int32, Int32, Int32> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode<T>(Span<T>, Boolean)
Computes bitwise hash code for the memory identified by the given span.
Declaration
public static int BitwiseHashCode<T>(this Span<T> span, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the span content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode<T>(Span<T>, Int32, ValueFunc<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this Span<T> span, int hash, in ValueFunc<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Int32 | hash | Initial value of the hash. |
ValueFunc<Int32, Int32, Int32> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode<T>(Span<T>, Int32, Func<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this Span<T> span, int hash, Func<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Int32 | hash | Initial value of the hash. |
Func<Int32, Int32, Int32> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | 32-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(ReadOnlySpan<T>, Boolean)
Computes bitwise hash code for the memory identified by the given span.
Declaration
public static long BitwiseHashCode64<T>(this ReadOnlySpan<T> span, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the span content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(ReadOnlySpan<T>, Int64, ValueFunc<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this ReadOnlySpan<T> span, long hash, in ValueFunc<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Int64 | hash | Initial value of the hash. |
ValueFunc<Int64, Int64, Int64> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(ReadOnlySpan<T>, Int64, Func<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this ReadOnlySpan<T> span, long hash, Func<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span whose content to be hashed. |
Int64 | hash | Initial value of the hash. |
Func<Int64, Int64, Int64> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(Span<T>, Boolean)
Computes bitwise hash code for the memory identified by the given span.
Declaration
public static long BitwiseHashCode64<T>(this Span<T> span, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the span content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(Span<T>, Int64, ValueFunc<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this Span<T> span, long hash, in ValueFunc<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Int64 | hash | Initial value of the hash. |
ValueFunc<Int64, Int64, Int64> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
BitwiseHashCode64<T>(Span<T>, Int64, Func<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the memory identified by the given span using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this Span<T> span, long hash, Func<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span whose content to be hashed. |
Int64 | hash | Initial value of the hash. |
Func<Int64, Int64, Int64> | hashFunction | Custom hashing algorithm. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | 64-bit hash code of the array content. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the span. |
Concat<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, MemoryAllocator<T>)
Concatenates memory blocks.
Declaration
public static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second, MemoryAllocator<T> allocator = null)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | first | The first memory block. |
ReadOnlySpan<T> | second | The second memory block. |
MemoryAllocator<T> | allocator | The memory allocator used to allocate buffer for the result. |
Returns
Type | Description |
---|---|
MemoryOwner<T> | The memory block containing elements from the specified two memory blocks. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the memory. |
Concat<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, MemoryAllocator<T>)
Concatenates memory blocks.
Declaration
public static MemoryOwner<T> Concat<T>(this ReadOnlySpan<T> first, ReadOnlySpan<T> second, ReadOnlySpan<T> third, MemoryAllocator<T> allocator = null)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | first | The first memory block. |
ReadOnlySpan<T> | second | The second memory block. |
ReadOnlySpan<T> | third | The third memory block. |
MemoryAllocator<T> | allocator | The memory allocator used to allocate buffer for the result. |
Returns
Type | Description |
---|---|
MemoryOwner<T> | The memory block containing elements from the specified two memory blocks. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the memory. |
CopyTo<T>(ReadOnlySpan<T>, Span<T>, out Int32)
Copies the contents from the source span into a destination span.
Declaration
public static void CopyTo<T>(this ReadOnlySpan<T> source, Span<T> destination, out int writtenCount)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | source | Source memory. |
Span<T> | destination | Destination memory. |
Int32 | writtenCount | The number of copied elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the span. |
CopyTo<T>(Span<T>, Span<T>, out Int32)
Copies the contents from the source span into a destination span.
Declaration
public static void CopyTo<T>(this Span<T> source, Span<T> destination, out int writtenCount)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | source | Source memory. |
Span<T> | destination | Destination memory. |
Int32 | writtenCount | The number of copied elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the span. |
ForEach<T>(Span<T>, RefAction<T, Int32>)
Iterates over elements of the span.
Declaration
public static void ForEach<T>(this Span<T> span, RefAction<T, int> action)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span to iterate. |
RefAction<T, Int32> | action | The action to be applied for each element of the span. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
ForEach<T>(Span<T>, ValueRefAction<T, Int32>)
Iterates over elements of the span.
Declaration
public static void ForEach<T>(this Span<T> span, in ValueRefAction<T, int> action)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span to iterate. |
ValueRefAction<T, Int32> | action | The action to be applied for each element of the span. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
FromHex(ReadOnlySpan<Char>)
Decodes hexadecimal representation of bytes.
Declaration
public static byte[] FromHex(this ReadOnlySpan<char> chars)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Char> | chars | The characters containing hexadecimal representation of bytes. |
Returns
Type | Description |
---|---|
Byte[] | The decoded array of bytes. |
FromHex(ReadOnlySpan<Char>, Span<Byte>)
Decodes hexadecimal representation of bytes.
Declaration
public static int FromHex(this ReadOnlySpan<char> chars, Span<byte> output)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Char> | chars | The hexadecimal representation of bytes. |
Span<Byte> | output | The output buffer used to write decoded bytes. |
Returns
Type | Description |
---|---|
Int32 | The actual number of bytes in |
IndexOf<T>(ReadOnlySpan<T>, T, Int32, ValueFunc<T, T, Boolean>)
Returns the zero-based index of the first occurrence of the specified value in the Span<T>. The search starts at a specified position.
Declaration
public static int IndexOf<T>(this ReadOnlySpan<T> span, T value, int startIndex, in ValueFunc<T, T, bool> comparer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span to search. |
T | value | The value to search for. |
Int32 | startIndex | The search starting position. |
ValueFunc<T, T, Boolean> | comparer | The comparer used to compare the expected value and the actual value from the span. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index position of |
Type Parameters
Name | Description |
---|---|
T | The of the elements in the span. |
IndexOf<T>(ReadOnlySpan<T>, T, Int32, Func<T, T, Boolean>)
Returns the zero-based index of the first occurrence of the specified value in the Span<T>. The search starts at a specified position.
Declaration
public static int IndexOf<T>(this ReadOnlySpan<T> span, T value, int startIndex, Func<T, T, bool> comparer)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | The span to search. |
T | value | The value to search for. |
Int32 | startIndex | The search starting position. |
Func<T, T, Boolean> | comparer | The comparer used to compare the expected value and the actual value from the span. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index position of |
Type Parameters
Name | Description |
---|---|
T | The of the elements in the span. |
Read<T>(ref ReadOnlySpan<Byte>)
Reads the value of blittable type from the block of memory and advances the original span.
Declaration
[Obsolete("Use SpanReader<T> type instead")]
public static T Read<T>(ref ReadOnlySpan<byte> bytes)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Byte> | bytes | The block of memory. |
Returns
Type | Description |
---|---|
T | The deserialized value. |
Type Parameters
Name | Description |
---|---|
T | The blittable type. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Sort<T>(Span<T>, ValueFunc<T, T, Int32>)
Sorts the elements.
Declaration
public static void Sort<T>(this Span<T> span, in ValueFunc<T, T, int> comparison)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The contiguous region of arbitrary memory to sort. |
ValueFunc<T, T, Int32> | comparison | The comparer used for sorting. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Sort<T>(Span<T>, IComparer<T>)
Sorts the elements.
Declaration
public static void Sort<T>(this Span<T> span, IComparer<T> comparison = null)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The contiguous region of arbitrary memory to sort. |
IComparer<T> | comparison | The comparer used for sorting. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Sort<T>(Span<T>, Comparison<T>)
Sorts the elements.
Declaration
public static void Sort<T>(this Span<T> span, Comparison<T> comparison)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The contiguous region of arbitrary memory to sort. |
Comparison<T> | comparison | The comparer used for sorting. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
ToHex(ReadOnlySpan<Byte>, Boolean)
Converts set of bytes into hexadecimal representation.
Declaration
public static string ToHex(this ReadOnlySpan<byte> bytes, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Byte> | bytes | The bytes to convert. |
Boolean | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
String | The hexadecimal representation of bytes. |
ToHex(ReadOnlySpan<Byte>, Span<Char>, Boolean)
Converts set of bytes into hexadecimal representation.
Declaration
public static int ToHex(this ReadOnlySpan<byte> bytes, Span<char> output, bool lowercased = false)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Byte> | bytes | The bytes to convert. |
Span<Char> | output | The buffer used to write hexadecimal representation of bytes. |
Boolean | lowercased | true to return lowercased hex string; false to return uppercased hex string. |
Returns
Type | Description |
---|---|
Int32 | The actual number of characters in |
TrimLength<T>(ReadOnlySpan<T>, Int32)
Trims the span to specified length if it exceeds it.
If length is less that maxLength
then the original span returned.
Declaration
public static ReadOnlySpan<T> TrimLength<T>(this ReadOnlySpan<T> span, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<T> | span | A contiguous region of arbitrary memory. |
Int32 | maxLength | Maximum length. |
Returns
Type | Description |
---|---|
ReadOnlySpan<T> | Trimmed span. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the span. |
TrimLength<T>(Span<T>, Int32)
Trims the span to specified length if it exceeds it.
If length is less that maxLength
then the original span returned.
Declaration
public static Span<T> TrimLength<T>(this Span<T> span, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | A contiguous region of arbitrary memory. |
Int32 | maxLength | Maximum length. |
Returns
Type | Description |
---|---|
Span<T> | Trimmed span. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the span. |
Write<T>(T, ref Span<Byte>)
Copies the value of blittable type to the specified block of memory.
Declaration
[Obsolete("Use SpanWriter<T> type instead")]
public static void Write<T>(in T value, ref Span<byte> output)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to copy to the destination memory block. |
Span<Byte> | output | The block of memory. |
Type Parameters
Name | Description |
---|---|
T | The blittable type. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|