Value | Meaning |
---|---|
linear | Searches in a linear fashion. |
trot | Searches with a step that is grows linearly (1, 2, 3,...) leading to a quadratic search schedule (indexes tried are 0, 1, 3, 6, 10, 15, 21, 28,...) Once the search overshoots its target, the remaining interval is searched using binary search. The search is completed in O(sqrt(n)) time. Use it when you are reasonably confident that the value is around the beginning of the range. |
gallop | Performs a galloping search algorithm, i.e. searches with a step that doubles every time, (1, 2, 4, 8, ...) leading to an exponential search schedule (indexes tried are 0, 1, 3, 7, 15, 31, 63,...) Once the search overshoots its target, the remaining interval is searched using binary search. A value is found in O(log(n)) time. |
binarySearch | Searches using a classic interval halving policy. The search starts in the middle of the range, and each search step cuts the range in half. This policy finds a value in O(log(n)) time but is less cache friendly than gallop for large ranges. The binarySearch policy is used as the last step of trot, gallop, trotBackwards, and gallopBackwards strategies. |
trotBackwards | Similar to trot but starts backwards. Use it when confident that the value is around the end of the range. |
gallopBackwards | Similar to gallop but starts backwards. Use it when confident that the value is around the end of the range. |
Policy used with the searching primitives lowerBound, upperBound, and equalRange of SortedRange below.