Class Span
Provides extension methods for type
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class Span : object
Methods
| Improve this Doc View SourceBitwiseCompare<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 |
---|---|---|
DotNext.Span<T> | first | The first memory span to compare. |
DotNext.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. |
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. |
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 |
---|---|---|
DotNext.Span<T> | first | The first memory span to compare. |
DotNext.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.
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.
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 |
---|---|---|
DotNext.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, 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 |
---|---|---|
DotNext.Span<T> | span | The span whose content to be hashed. |
Int32 | hash | Initial value of the hash. |
DotNext.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>, 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 |
---|---|---|
DotNext.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>(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, 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. |
DotNext.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>(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. |
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 |
---|---|---|
DotNext.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, 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 |
---|---|---|
DotNext.Span<T> | span | The span whose content to be hashed. |
Int64 | hash | Initial value of the hash. |
DotNext.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>, 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 |
---|---|---|
DotNext.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>(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, 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. |
DotNext.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>(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. |
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 |
---|---|---|
DotNext.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 |
---|---|---|
DotNext.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. |
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
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 | |
T | value | |
Int32 | startIndex | The search starting position. |
DotNext.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. |
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
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 | |
T | value | |
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. |
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 |
---|---|---|
DotNext.Span<T> | span | The contiguous region of arbitrary memory to sort. |
DotNext.Comparison<T> | comparison | The comparer used for sorting. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
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 |
---|---|---|
DotNext.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 |
---|---|---|
DotNext.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. |
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 |
---|---|---|
DotNext.Span<T> | span | A contiguous region of arbitrary memory. |
Int32 | maxLength | Maximum length. |
Returns
Type | Description |
---|---|
DotNext.Span<T> | Trimmed span. |
Type Parameters
Name | Description |
---|---|
T |
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 |