The array of interest.
The predicate function to apply to the values.
The index of the first element in the range to be
searched, inclusive. The default value is 0
. Negative values
are taken as an offset from the end of the array.
The index of the last element in the range to be
searched, inclusive. The default value is -1
. Negative values
are taken as an offset from the end of the array.
The number of elements removed from the array.
If stop < start
the search will conceptually wrap at the end of
the array, however the array will be traversed front-to-back.
Linear.
import { ArrayExt } from '@lumino/algorithm';
function isEven(value: number): boolean {
return value % 2 === 0;
}
function isNegative(value: number): boolean {
return value < 0;
}
let data = [0, 12, -13, -9, 23, 39, 14, -15, 12, 75];
ArrayExt.removeAllWhere(data, isEven); // 4
ArrayExt.removeAllWhere(data, isNegative, 0, 3); // 2
Remove all occurrences of values which match a predicate.