File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 7979//! marker trait. For example, a [`VpTree`] will be exact when the [`Proximity`] function is a
8080//! [`Metric`].
8181//!
82+ //! # Examples
83+ //!
84+ //! ## Searching without owning
85+ //!
86+ //! Since [`Proximity`] has a blanket implementation for references, you can store references in a
87+ //! nearest neighbor index instead of having it hold the data itself:
88+ //!
89+ //! use acap::euclid::Euclidean;
90+ //! use acap::vp::VpTree;
91+ //! use acap::NearestNeighbors;
92+ //!
93+ //! let points = vec![
94+ //! Euclidean([3, 4]),
95+ //! Euclidean([5, 12]),
96+ //! Euclidean([8, 15]),
97+ //! Euclidean([7, 24]),
98+ //! ];
99+ //!
100+ //! let tree = VpTree::balanced(points.iter());
101+ //!
102+ //! let nearest = tree.nearest(&&[7, 7]).unwrap();
103+ //! assert!(std::ptr::eq(*nearest.item, &points[0]));
104+ //!
105+ //! ## Custom distance functions
106+ //!
107+ //! See the [`Proximity`] documentation.
108+ //!
82109//! [nearest neighbor search]: https://en.wikipedia.org/wiki/Nearest_neighbor_search
83110//! [`distance()`]: Proximity#tymethod.distance
84111//! [`value()`]: Distance#method.value
You can’t perform that action at this time.
0 commit comments