ArrayUtil

Description

static class Tinman.Core.ArrayUtil

Helper class for dealing with arrays.

This class provides some helper methods, dealing with the following:

  • Create arrays from specified values, see From*.

  • Clear ranges of arrays to the default value, see Clear*.

  • Copy ranges between arrays, see Copy*.

  • Equality checks for arrays, see Equals*.

  • Dynamically growing arrays, see Grow*.

  • Wrapping of array data without copying, see Wrap.

Public / Constructors

From​Arrays


[Pure]
public static method FromArrays → (2)<T>

first in : T [ ]

[not-null]
The first array elements.

second in : T [ ]

[not-null]
The second array elements.

returns → T [ ]

The resulting array.

Concatenates the given array elements.

From​Elements

2 overloads


[Pure]
public static method FromElements1 → (1)<T>

first in : T

The first array element.

returns → T [ ]

The resulting array.

Creates an array of the given element.


[Pure]
public static method FromElements2 → (2)<T>

first in : T

The first array element.

second in : T

The second array element.

returns → T [ ]

The resulting array.

Creates an array of the given elements.

From​Enumeration


public static method FromEnumeration → (1)<T>

elements in : IEnumerable<T>

The elements.

returns → T [ ]

The array or null iff elements in is null.

Creates an array of the given elements.

From​Prefix


[Pure]
public static method FromPrefix → (2)<T>

first in : T

The first array element.

second in : T [ ]

[not-null]
The trailing array elements.

returns → T [ ]

The resulting array.

Concatenates the given array elements.

From​Suffix


[Pure]
public static method FromSuffix → (2)<T>

first in : T [ ]

[not-null]
The leading array elements.

second in : T

The last array element.

returns → T [ ]

The resulting array.

Concatenates the given array elements.

Public / Methods

Clear

9 overloads


public static method Clear1 → (3)<T>

array in : T [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear2 → (3)

array in : bool [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear3 → (3)

array in : int8 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear4 → (3)

array in : char [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear5 → (3)

array in : int16 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear6 → (3)

array in : int32 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear7 → (3)

array in : float32 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear8 → (3)

array in : int64 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.


public static method Clear9 → (3)

array in : float64 [ ]

[not-null]
The array to clear.

offset opt : int32 = 0

[>=0]
Offset to first element in array in to clear.

count opt : int32 = -1

[>=-1]
Number of elements in array in to clear. If -1, all remaining elements will be cleared.

Clears the elements of the given array to the default value.

Copy

9 overloads


public static method Copy1 → (5)<T>

source in : T [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : T [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy2 → (5)

source in : bool [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : bool [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy3 → (5)

source in : int8 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int8 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy4 → (5)

source in : char [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : char [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy5 → (5)

source in : int16 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int16 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy6 → (5)

source in : int32 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int32 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy7 → (5)

source in : float32 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : float32 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy8 → (5)

source in : int64 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : int64 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.


public static method Copy9 → (5)

source in : float64 [ ]

[not-null]
The source array.

sourceIdx in : int32

[>=0]
Index of first element in source in to copy.

target in : float64 [ ]

[not-null]
The target array.

targetIdx in : int32

[>=0]
Index of first element in target in to write.

count in : int32

[>=0]
Total number of array elements to copy.

Copies elements from one array to another.

Equals

8 overloads


[Pure]
public static method Equals1 → (2)

in : bool [ ]

The first array to compare.

in : bool [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals2 → (2)

in : int8 [ ]

The first array to compare.

in : int8 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals3 → (2)

in : char [ ]

The first array to compare.

in : char [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals4 → (2)

in : int16 [ ]

The first array to compare.

in : int16 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals5 → (2)

in : int32 [ ]

The first array to compare.

in : int32 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals6 → (2)

in : float32 [ ]

The first array to compare.

in : float32 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals7 → (2)

in : int64 [ ]

The first array to compare.

in : int64 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.


[Pure]
public static method Equals8 → (2)

in : float64 [ ]

The first array to compare.

in : float64 [ ]

The second array to compare.

returns → bool

true if the arrays are equal,
false if they are different.

Compares the given array for equality.

Equals​Default


[Pure]
public static method EqualsDefault → (2)<T>

first in : T [ ]

The first array or null.

second in : T [ ]

The second array or null.

returns → bool

true if both arrays contain the same elements, false if not.

Checks if the given arrays are equal.

The given array references are equal if one of the following conditions is true:

  • They refer to the same array instance.

  • They are both null.

  • The two arrays contain the same sequence of elements, where element equality is defined by SystemUtil.EqualsDefault.

Equals​Object


public static method EqualsObject → (2)
<T ref : IEquatable<T>>

first in : T [ ]

The first array or null.

second in : T [ ]

The second array or null.

returns → bool

true if both arrays contain the same elements, false if not.

Checks if the given arrays are equal.

The given array references are equal if one of the following conditions is true:

  • They refer to the same array instance.

  • They are both null.

  • The two arrays contain the same sequence of elements, where element equality is determined via IEquatable.

Equals​Value


public static method EqualsValue → (2)
<T val : IEquatable<T>>

first in : T [ ]

The first array or null.

second in : T [ ]

The second array or null.

returns → bool

true if both arrays contain the same elements, false if not.

Checks if the given arrays are equal.

The given array references are equal if one of the following conditions is true:

  • They refer to the same array instance.

  • They are both null.

  • The two arrays contain the same sequence of elements, where element equality is determined via IEquatable.

Grow​Capacity


[Pure]
public static method GrowCapacity → (4)

current in : int32

The current capacity.

required opt : int64 = 0

The required capacity.

numerator opt : int32 = 5

Numerator of fraction to use for growing current in.

denominator opt : int32 = 4

Denominator of fraction to use for growing current in.

returns → int32

The grown capacity.

Grows the given capacity, making sure it stays within [0..2147483647] and is larger than or equal to required opt.

Grow​To


[Pure]
public static method GrowTo → (3)<T>

array in : T [ ]

The array to grow or null if none.

count in : int32

[>=0]
Number of valid elements in array in. This parameter will be ignored if array in is null and otherwise clamped to the length of array in.

length in : int64

[>=0]
New array length.

returns → T [ ]

The grown array.

Grows the given array to the specified length.

Grow​Until


[Pure]
public static method GrowUntil → (3)<T>

array in : T [ ]

The array to grow or null if none.

count in : int32

[>=0]
Number of valid elements in array in. This parameter will be ignored if array in is null and otherwise clamped to the length of array in.

length in : int64

[>=0]
New array length (minimum).

returns → T [ ]

The grown array.

Proportionally grows the given array until its length is equal to or greater than the specified length.

The new array length is computed as follows:

newLength := max(length, currentLength * 5 / 4)

where newLength is the length of the returned array, length is the value of the length in parameter and currentLength is the length of the given array in.

If count in is greater than zero, all array elements in the range [0..count-1] are copied from the given array in to the newly allocated one.

Wrap


[Pure]
public static method Wrap → (3)<T>

array in : T [ ]

The array to wrap.

count opt : int32 = -1

The number of array elements to wrap. If negative, the whole array will be wrapped.

equals opt : EqualsDelegate<T> = null

The equality delegate.

returns → IArrayVector<T>

The list object or null if array in is null.

Returns a IVectorConst object that wraps the given array.

The list will use the given array, no elements will be copied.