 | binarySearchBinarySearchT, V Method (FuncT, V, T, T, V, T) |
Performs a binary search on a range from min to max (exclusive). Returns the number for which searcher is below tolerance (in absolute value).
Namespace:
WhetStone.Looping
Assembly:
WhetStone (in WhetStone.dll) Version: 1.0.4.0 (1.0.0.0)
Syntaxpublic static T BinarySearch<T, V>(
Func<T, V> searcher,
T min,
T max,
V tolerance,
T failvalue
)
Parameters
- searcher
- Type: SystemFuncT, V
The searcher function, a positive number means the input is too high, a negative number means the input is too low, below tolerance means the input has been found. - min
- Type: T
The minimum of the range to search in. - max
- Type: T
The maximum of the range to search in. - tolerance
- Type: V
The maximum value that will be accepted as the correct value. - failvalue
- Type: T
The value to return if no correct index is found.
Type Parameters
- T
- The type of the range to search.
- V
- The type of the value to search for.
Return Value
Type:
TThe index on which
searcher returned below
tolerance, or
failvalue if such is not found.
RemarksThis function uses Fielding for both type T and V.
See Also