pub struct Tree<Item: MetricSpace<Impl> + Clone, Impl = (), Ownership = Owned<()>> { /* private fields */ }
Expand description
The VP-Tree.
Implementations§
Source§impl<Item: MetricSpace<Impl, UserData = ()> + Clone, Impl> Tree<Item, Impl, Owned<()>>
impl<Item: MetricSpace<Impl, UserData = ()> + Clone, Impl> Tree<Item, Impl, Owned<()>>
Sourcepub fn new(items: &[Item]) -> Self
pub fn new(items: &[Item]) -> Self
Creates a new tree from items. Maximum number of items is 2^31.
See Tree::new_with_user_data_owned
.
Examples found in repository?
More examples
Source§impl<U, Impl, Item: MetricSpace<Impl, UserData = U> + Clone> Tree<Item, Impl, Owned<U>>
impl<U, Impl, Item: MetricSpace<Impl, UserData = U> + Clone> Tree<Item, Impl, Owned<U>>
Sourcepub fn find_nearest(&self, needle: &Item) -> (usize, Item::Distance)
pub fn find_nearest(&self, needle: &Item) -> (usize, Item::Distance)
Finds item closest to the given needle
(that can be any item) and returns index of the item in items array from new()
.
Returns the index of the nearest item (index from the items slice passed to new()
) found and the distance from the nearest item.
Examples found in repository?
More examples
Source§impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, Owned<Item::UserData>>
impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, Owned<Item::UserData>>
Sourcepub fn new_with_user_data_owned(
items: &[Item],
user_data: Item::UserData,
) -> Self
pub fn new_with_user_data_owned( items: &[Item], user_data: Item::UserData, ) -> Self
Create a Vantage Point tree for fast nearest neighbor search.
items
— Array of items that will be searched.user_data
— Reference to any object that is passed down to item.distance()
Source§impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, ()>
impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, ()>
Sourcepub fn new_with_user_data_ref(
items: &[Item],
user_data: &Item::UserData,
) -> Self
pub fn new_with_user_data_ref( items: &[Item], user_data: &Item::UserData, ) -> Self
The tree doesn’t have to own the UserData. You can keep passing it to find_nearest().
pub fn find_nearest( &self, needle: &Item, user_data: &Item::UserData, ) -> (usize, Item::Distance)
Source§impl<Item: MetricSpace<Impl> + Clone, Ownership, Impl> Tree<Item, Impl, Ownership>
impl<Item: MetricSpace<Impl> + Clone, Ownership, Impl> Tree<Item, Impl, Ownership>
Sourcepub fn find_nearest_custom<ReturnBy: BestCandidate<Item, Impl>>(
&self,
needle: &Item,
user_data: &Item::UserData,
best_candidate: ReturnBy,
) -> ReturnBy::Output
pub fn find_nearest_custom<ReturnBy: BestCandidate<Item, Impl>>( &self, needle: &Item, user_data: &Item::UserData, best_candidate: ReturnBy, ) -> ReturnBy::Output
All the bells and whistles version. For best_candidate implement BestCandidate<Item, Impl>
trait.
Trait Implementations§
Auto Trait Implementations§
impl<Item, Impl, Ownership> Freeze for Tree<Item, Impl, Ownership>where
Ownership: Freeze,
impl<Item, Impl, Ownership> RefUnwindSafe for Tree<Item, Impl, Ownership>where
Ownership: RefUnwindSafe,
Item: RefUnwindSafe,
<Item as MetricSpace<Impl>>::Distance: RefUnwindSafe,
impl<Item, Impl, Ownership> Send for Tree<Item, Impl, Ownership>
impl<Item, Impl, Ownership> Sync for Tree<Item, Impl, Ownership>
impl<Item, Impl, Ownership> Unpin for Tree<Item, Impl, Ownership>
impl<Item, Impl, Ownership> UnwindSafe for Tree<Item, Impl, Ownership>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more