class ArrayExt
package nb.ext
Static methods
staticat<T>(a:Array<T>, i:Int):Null<T>
Returns a value from an array at some position.
Parameters:
a | An array. |
---|---|
i | A position in the array. If |
Returns:
A value in a
at position i
.
staticgetOne<T>(a:Array<T>, f:T ‑> Bool, asc:Bool = true):Null<T>
Iterates through an array and returns the first value in the array where f(value) == true
.
Parameters:
a | The array to iterate through. |
---|---|
f | A function which will take a value in the array as parameter. |
asc |
|
Returns:
A value where f(value) == true
. You get null
if there is no such value, or
if it is an actual value in the array.
staticinsertWhere<T>(a:Array<T>, v:T, f:T ‑> Bool, asc:Bool = true, force:Bool = true):Bool
Inserts a value in an array at a position where a condition is satisfied.
The value will be inserted at a position where for x
being a value at that position, f(x) == true
.
Parameters:
a | The array to iterate through. |
---|---|
v | A value to insert. |
f | A function which will take a value in the array as parameter. |
asc |
|
force | If |
Returns:
staticremoveIf<T>(a:Array<T>, f:T ‑> Bool, asc:Bool = true):T
Iterates through an array and removes the first value in the array where f(value) == true
.
Parameters:
a | The array to iterate through. |
---|---|
f | A function which will take a value in the array as parameter. |
asc |
|
Returns:
The value that was removed, null
if nothing was removed.
staticinlineremoveValues<T>(a1:Array<T>, a2:Array<T>):Array<T>
Removes multiple values from an array.
Ex: removeValues([a,b,a,b,a],[a,a]))
removes the value a
twice from the first array, resulting to [b,b,a]
.
Parameters:
a1 | The array to remove values from. |
---|---|
a2 | An array containing values to remove from |
Returns:
a1
.