findclosest(pts[, dist = Euclidean()]) -> (d, (i, j))

Find the distance d and indices (i, j) of the two closest points pᵢ and pⱼ in pts, according to distance dist(pᵢ, pⱼ) (see the Distance.jl package). If length(pts) < 2, return nothing.

The search is performed using a single-threaded, multidimensional, divide-and-conquer algorithm, with runtime complexity O(n log(n)).


julia> using StaticArrays; pts = rand(SVector{3,Float64}, 10^3);

julia> findclosest(pts)
(0.007292429825826281, (75, 535))