findEquivalent Method

Find an element that compares as equivalent based on some criterion. If multiple elements are equivalent, the specific one returned is unspecified. As an example, consider a SortedArray<ModelState> which uses ModelState.id as its ordering criterion. To find a model by its Id, use sortedArray.findEquivalent((element) => compareStrings(element.id, modelId)) where modelId is an Id64String.

findEquivalent(criterion: (element: T) => number): undefined | T

@returns The first element found that meets the criterion, or undefined if no elements meet the criterion.

@see ReadonlySortedArray.indexOfEquivalent.

Parameter Type Description
criterion (element: T) => number A function accepting an element and returning 0 if it compares as equivalent, a negative number if it compares as "less-than", or a positive value if it compares as "greater-than".

Returns - undefined | T

The first element found that meets the criterion, or undefined if no elements meet the criterion.

Defined in

Last Updated: 28 March, 2024