Static methods

@:arrayAccessstaticinlinearrayAccess(this:CollectionImpl<T>, index:Int):T

staticrandomElement(this:CollectionImpl<T>):T

Return a random element contained in the collection

@:value({ unsafe : false })staticrandomElementExcept(this:CollectionImpl<T>, except:T, unsafe:Bool = false):T

Return a random element contained in the given array that is not equal to the except arg.

Parameters:

except

The element we don't want

unsafe

If set to true, will prevent allocating a new array (and may be faster) but will loop forever if there is no element except the one we don't want

Returns:

The random element or null if nothing was found

staticrandomElementMatchingValidator(this:CollectionImpl<T>, validator:T ‑> Bool):T

Return a random element contained in the given array that is validated by the provided validator. If no item is valid, returns null.

Parameters:

array

The array in which we extract the element from

validator

A function that returns true if the item is valid, false if not

Returns:

The random element or null if nothing was found