FindFirstFunctions.GuesserType
Guesser(v::AbstractVector; looks_linear_threshold = 1e-2)

Wrapper of the searched vector v which makes an informed guess for searchsorted*correlated by either

  • Exploiting that v is sufficiently evenly spaced
  • Using the previous outcome of searchsorted*correlated
FindFirstFunctions.bracketstrictlymontonicMethod
bracketstrictlymontonic(v, x, guess; lt=<comparison>, by=<transform>, rev=false)

Starting from an initial guess index, find indices (lo, hi) such that v[lo] ≤ x ≤ v[hi] according to the specified order, assuming that x is actually within the range of values found in v. If x is outside that range, either lo will be firstindex(v) or hi will be lastindex(v).

Note that the results will not typically satisfy lo ≤ guess ≤ hi. If x is precisely equal to a value that is not unique in the input v, there is no guarantee that (lo, hi) will encompass all indices corresponding to that value.

This algorithm is essentially an expanding binary search, which can be used as a precursor to searchsorted and related functions, which can take lo and hi as arguments. The purpose of using this function first would be to accelerate convergence in those functions by using correlated guesses for repeated calls. The best guess for the next call of this function would be the index returned by the previous call to searchsorted.

See Base.sort! for an explanation of the keyword arguments by, lt and rev.

FindFirstFunctions.findfirstsortedequalMethod

findfirstsortedequal(vars::DenseVector{Int64}, var::Int64)::Union{Int64,Nothing}

Note that this differs from searchsortedfirst by returning nothing when absent.

FindFirstFunctions.looks_linearMethod
looks_linear(v; threshold = 1e-2)

Determine if the abscissae v are regularly distributed, taking the standard deviation of the difference between the array of abscissae with respect to the straight line linking its first and last elements, normalized by the range of v. If this standard deviation is below the given threshold, the vector looks linear (return true). Internal function - interface may change.

FindFirstFunctions.searchsortedfirstcorrelatedMethod
searchsortedfirstcorrelated(v::AbstractVector, x, guess)

An accelerated findfirst on sorted vectors using a bracketed search. Requires a guess::Union{<:Integer, Guesser} to start the search from.

FindFirstFunctions.searchsortedlastcorrelatedMethod
searchsortedlastcorrelated(v::AbstractVector{T}, x, guess)

An accelerated findlast on sorted vectors using a bracketed search. Requires a guess::Union{<:Integer, Guesser} to start the search from.