Less than 1 minute
Home > @hz-9/algorithm > sequentialSearch
sequentialSearch() function
Sequential search algorithm. Input parameters must be sorted in ascending order.
线性搜索算法。 传入参数必须已经进行从小到大排序。
Signature:
sequentialSearch: <T>(list: T[], value: T, equalsFn?: EqualsFn<T>) => numberParameters
Parameter | Type | Description |
|---|---|---|
list | T[] | The list to search. |
value | T | The value to search for. |
equalsFn | EqualsFn<T> | (Optional) |
Returns:
number
- The index of the value in the list. If the value is not found, return -1.