Class: shaka.util.ArrayUtils

Array utility functions.

Methods

(static) count(arraynon-null, check) → {number}

Count the number of items in the list that pass the check function.
Parameters:
Name Type Description
array Array.<T>
check function(T):boolean
Source:
Returns:
Type
number

(static) defaultEquals(a, b) → {boolean}

Returns whether the two values contain the same value. This correctly handles comparisons involving NaN.
Parameters:
Name Type Description
a T
b T
Source:
Returns:
Type
boolean

(static) indexOf(arraynon-null, value, compareFn) → {number}

Find an item in an array. For use when comparison of entries via == will not suffice.
Parameters:
Name Type Description
array Array.<T>
value T
compareFn function(T, T): boolean A function which will be used to compare items in the array.
Source:
Returns:
The index, or -1 if not found.
Type
number

(static) remove(arraynon-null, element)

Remove given element from array (assumes no duplicates).
Parameters:
Name Type Description
array Array.<T>
element T
Source:

(static) removeDuplicates(arraynon-null, compareFn) → (non-null) {Array.<T>}

Remove duplicate entries from an array. Order N^2, so use with caution.
Parameters:
Name Type Description
array Array.<T>
compareFn function(T, T): boolean= An optional function which will be used to compare items in the array.
Source:
Returns:
Type
Array.<T>