Class OneDimensionalArray
Provides specialized methods to work with one-dimensional array.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class OneDimensionalArray
Methods
| Improve this Doc View SourceBitwiseCompare<T>(T[], T[])
Compares content of the two arrays.
Declaration
public static int BitwiseCompare<T>(this T[] first, T[] second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | first | The first array to compare. |
T[] | second | The second array to compare. |
Returns
Type | Description |
---|---|
Int32 | Comparison result. |
Type Parameters
Name | Description |
---|---|
T | The type of array elements. |
BitwiseEquals<T>(T[], T[])
Determines whether two arrays contain the same set of bits.
Declaration
public static bool BitwiseEquals<T>(this T[] first, T[] second)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | first | First array for equality check. |
T[] | second | Second array of equality check. |
Returns
Type | Description |
---|---|
Boolean | true, if both arrays are equal; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. Should be unmanaged value type. |
Remarks
This method performs bitwise equality between each pair of elements.
BitwiseHashCode<T>(T[], Boolean)
Computes bitwise hash code for the array content.
Declaration
public static int BitwiseHashCode<T>(this T[] array, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array content. |
Type Parameters
Name | Description |
---|---|
T | The type of array elements. |
BitwiseHashCode<T>(T[], Int32, ValueFunc<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the array content using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this T[] array, int hash, in ValueFunc<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array elements. |
BitwiseHashCode<T>(T[], Int32, Func<Int32, Int32, Int32>, Boolean)
Computes bitwise hash code for the array content using custom hash function.
Declaration
public static int BitwiseHashCode<T>(this T[] array, int hash, Func<int, int, int> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array elements. |
BitwiseHashCode64<T>(T[], Boolean)
Computes bitwise hash code for the array content.
Declaration
public static long BitwiseHashCode64<T>(this T[] array, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array content. |
Type Parameters
Name | Description |
---|---|
T | The type of array elements. |
BitwiseHashCode64<T>(T[], Int64, ValueFunc<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the array content using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this T[] array, long hash, in ValueFunc<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array elements. |
BitwiseHashCode64<T>(T[], Int64, Func<Int64, Int64, Int64>, Boolean)
Computes bitwise hash code for the array content using custom hash function.
Declaration
public static long BitwiseHashCode64<T>(this T[] array, long hash, Func<long, long, long> hashFunction, bool salted = true)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array 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 array elements. |
Concat<T>(T[], T[], Int64)
Concatenates the array with the specified span of elements.
Declaration
public static T[] Concat<T>(this T[] left, T[] right, long startIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | left | The array to concatenate. |
T[] | right | The tail of concatenation. |
Int64 | startIndex | The starting index in |
Returns
Type | Description |
---|---|
T[] | The array representing all elements from |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the array. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ForEach<T>(T[], RefAction<T, Int64>)
Applies specific action to each array element.
Declaration
public static void ForEach<T>(this T[] array, RefAction<T, long> action)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | An array to iterate. |
RefAction<T, Int64> | action | An action to be applied for each element. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
Remarks
This method support modification of array elements because each array element is passed by reference into action.
ForEach<T>(T[], ValueRefAction<T, Int64>)
Applies specific action to each array element.
Declaration
public static void ForEach<T>(this T[] array, in ValueRefAction<T, long> action)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | An array to iterate. |
ValueRefAction<T, Int64> | action | An action to be applied for each element. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
Remarks
This method support modification of array elements because each array element is passed by reference into action.
Insert<T>(T[], T, Int64)
Insert a new element into array and return modified array.
Declaration
public static T[] Insert<T>(this T[] array, T element, long index)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
T | element | The object to insert. |
Int64 | index | The zero-based index at which item should be inserted. |
Returns
Type | Description |
---|---|
T[] | A modified array with inserted element. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
IsNullOrEmpty<T>(T[])
Indicates that array is null or empty.
Declaration
public static bool IsNullOrEmpty<T>(this T[] array)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to check. |
Returns
Type | Description |
---|---|
Boolean | true, if array is null or empty. |
Type Parameters
Name | Description |
---|---|
T | Type of elements in the array. |
RemoveAll<T>(T[], ValueFunc<T, Boolean>, ValueAction<T>)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static T[] RemoveAll<T>(this T[] array, in ValueFunc<T, bool> match, in ValueAction<T> callback)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
ValueFunc<T, Boolean> | match | The predicate that defines the conditions of the elements to remove. |
ValueAction<T> | callback | The delegate that is used to accept removed items. |
Returns
Type | Description |
---|---|
T[] | A modified array with removed elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in array. |
RemoveAll<T>(T[], ValueFunc<T, Boolean>, out Int64)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static T[] RemoveAll<T>(this T[] array, in ValueFunc<T, bool> match, out long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
ValueFunc<T, Boolean> | match | The predicate that defines the conditions of the elements to remove. |
Int64 | count | The number of elements removed from this list. |
Returns
Type | Description |
---|---|
T[] | A modified array with removed elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in array. |
RemoveAll<T>(T[], Predicate<T>, Action<T>)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static T[] RemoveAll<T>(this T[] array, Predicate<T> match, Action<T> callback)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
Predicate<T> | match | The predicate that defines the conditions of the elements to remove. |
Action<T> | callback | The delegate that is used to accept removed items. |
Returns
Type | Description |
---|---|
T[] | A modified array with removed elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in array. |
RemoveAll<T>(T[], Predicate<T>, out Int64)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static T[] RemoveAll<T>(this T[] array, Predicate<T> match, out long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
Predicate<T> | match | The predicate that defines the conditions of the elements to remove. |
Int64 | count | The number of elements removed from this list. |
Returns
Type | Description |
---|---|
T[] | A modified array with removed elements. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in array. |
RemoveAt<T>(T[], Int64)
Removes the element at the specified in the array and returns modified array.
Declaration
public static T[] RemoveAt<T>(this T[] array, long index)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Source array. Cannot be null. |
Int64 | index | The zero-based index of the element to remove. |
Returns
Type | Description |
---|---|
T[] | A modified array with removed element. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
RemoveFirst<T>(T[], Int64)
Removes the specified number of elements from the beginning of the array.
Declaration
public static T[] RemoveFirst<T>(this T[] input, long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | input | Source array. |
Int64 | count | A number of elements to be removed. |
Returns
Type | Description |
---|---|
T[] | Modified array. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
RemoveLast<T>(T[], Int64)
Removes the specified number of elements from the end of the array.
Declaration
public static T[] RemoveLast<T>(this T[] input, long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | input | Source array. |
Int64 | count | A number of elements to be removed. |
Returns
Type | Description |
---|---|
T[] | Modified array. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
SequenceEqual(Object[], Object[], Boolean)
Determines whether two arrays contain the same set of elements.
Declaration
public static bool SequenceEqual(this object[] first, object[] second, bool parallel = false)
Parameters
Type | Name | Description |
---|---|---|
Object[] | first | The first array to compare. |
Object[] | second | The second array to compare. |
Boolean | parallel | true to perform parallel iteration over array elements; false to perform sequential iteration. |
Returns
Type | Description |
---|---|
Boolean | true, if both arrays are equal; otherwise, false. |
Remarks
This method calls Equals(Object, Object) for each element type.
Slice<T>(T[], Int64, Int64)
Returns sub-array.
Declaration
public static T[] Slice<T>(this T[] input, long startIndex, long length)
Parameters
Type | Name | Description |
---|---|---|
T[] | input | Input array. Cannot be null. |
Int64 | startIndex | The index at which to begin this slice. |
Int64 | length | The desired length for the slice. |
Returns
Type | Description |
---|---|
T[] | A new sliced array. |
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
Slice<T>(T[], Range)
Computes view over the specified array.
Declaration
public static ArraySegment<T> Slice<T>(this T[] input, in Range range)
Parameters
Type | Name | Description |
---|---|---|
T[] | input | The array instance. |
Range | range | The range in the array to return. |
Returns
Type | Description |
---|---|
ArraySegment<T> | The range in |
Type Parameters
Name | Description |
---|---|
T | The type of array elements. |