The vantage point tree implementation in OCaml has a new functorial interface.

Thanks to Ilias Garnier for contributing.

Toplevel usage example:

#require “minivpt”;;

module Point_2D =

struct

type t = float * float

let dist (x0, y0) (x1, y1) =

let square x =

x *. x

in

sqrt (square (x0 -. x1) +. square (y0 -. y1))

end

module Vpt = Vp_tree.Make(Point_2D)

–>

module Vpt :

sig

type t = Vp_tree.Make(Point_2D).t

val create : Point_2D.t list -> t

val nearest_neighbor : Point_2D.t -> t -> float * Point_2D.t

val to_list : t -> Point_2D.t list

val is_empty : t -> bool

end