triangularProbeFromIndex

Search for a key in haystack matching predicate pred starting at index in steps of triangular numbers, 0,1,3,6,10,15,21, ... .

If assumeNonFullHaystack is true it is assumed that at least one element in haystack matches pred, thereby enabling sentinel-based probing. Such probing doesn't require in-loop range checking via `indexIncrement != haystack.length` and can be made faster.

size_t
triangularProbeFromIndex
(
alias pred
bool assumeNonFullHaystack = false
T
)
(
const scope T[] haystack
,
size_t index
)
if (
is(typeof(unaryFun!pred(T.init))) ||
is(typeof(binaryFun!pred(size_t.init, T.init)))
)

Return Value

Type: size_t

index into haystack upon hit, haystack.length upon miss.

Note: haystack.length must be a power of two (or 1 or zero).

See Also

Meta