Less than 1 minute
Home > @hz-9/algorithm > hashSearch
hashSearch() function
Hash search algorithm. Input parameters do not need to be sorted.
哈希搜索算法。 传入参数无需排序。
Signature:
hashSearch: <T>(list: T[], value: T, toKeyStr?: ToKeyStr<T>, toHashCode?: ToHashCode) => numberParameters
Parameter | Type | Description |
|---|---|---|
list | T[] | The list to search. |
value | T | The value to search for. |
toKeyStr | ToKeyStr<T> | (Optional) The function to convert the value to a key string. |
toHashCode | (Optional) The function to convert the key string to a hash code. |
Returns:
number
- The index of the value in the list. If the value is not found, return -1.