Class OneDimensionalArray
Provides specialized methods to work with one-dimensional array.
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class OneDimensionalArray : object
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, 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. |
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 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. |
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, 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. |
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 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. |
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 zero-based index at which item should be inserted. |
Int64 | index | The object to insert. The value can be null for reference types. |
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[], 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. |
DotNext.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 |
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. |
DotNext.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 |
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 |
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 |
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. |
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[])
Determines whether two arrays contain the same set of elements.
Declaration
public static bool SequenceEqual(this object[] first, object[] second)
Parameters
Type | Name | Description |
---|---|---|
Object[] | first | The first array to compare. |
Object[] | second | The second array to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if both arrays are equal; otherwise, false. |
Remarks
This method calls
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. |