[−][src]Struct vpsearch::Tree
The VP-Tree.
Methods
impl<Item: MetricSpace<Impl, UserData = ()> + Clone, Impl> Tree<Item, Impl, Owned<()>>
[src]
pub fn new(items: &[Item]) -> Self
[src]
Creates a new tree from items. Maximum number of items is 2^31.
See Tree::new_with_user_data_owned
.
impl<U, Impl, Item: MetricSpace<Impl, UserData = U> + Clone> Tree<Item, Impl, Owned<U>>
[src]
pub fn find_nearest(&self, needle: &Item) -> (usize, Item::Distance)
[src]
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.
impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, Owned<Item::UserData>>
[src]
pub fn new_with_user_data_owned(
items: &[Item],
user_data: Item::UserData
) -> Self
[src]
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()
impl<Item: MetricSpace<Impl> + Clone, Impl> Tree<Item, Impl, ()>
[src]
pub fn new_with_user_data_ref(
items: &[Item],
user_data: &Item::UserData
) -> Self
[src]
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)
[src]
&self,
needle: &Item,
user_data: &Item::UserData
) -> (usize, Item::Distance)
impl<Item: MetricSpace<Impl> + Clone, Ownership, Impl> Tree<Item, Impl, Ownership>
[src]
pub fn find_nearest_custom<ReturnBy: BestCandidate<Item, Impl>>(
&self,
needle: &Item,
user_data: &Item::UserData,
best_candidate: ReturnBy
) -> ReturnBy::Output
[src]
&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
impl<Item: Debug + Clone + MetricSpace<UserImpl>, UserImpl, Ownership> Debug for Tree<Item, UserImpl, Ownership>
[src]
Auto Trait Implementations
impl<Item, Impl, Ownership> RefUnwindSafe for Tree<Item, Impl, Ownership> where
Item: RefUnwindSafe,
Ownership: RefUnwindSafe,
<Item as MetricSpace<Impl>>::Distance: RefUnwindSafe,
Item: RefUnwindSafe,
Ownership: RefUnwindSafe,
<Item as MetricSpace<Impl>>::Distance: RefUnwindSafe,
impl<Item, Impl, Ownership> Send for Tree<Item, Impl, Ownership> where
Item: Send,
Ownership: Send,
<Item as MetricSpace<Impl>>::Distance: Send,
Item: Send,
Ownership: Send,
<Item as MetricSpace<Impl>>::Distance: Send,
impl<Item, Impl, Ownership> Sync for Tree<Item, Impl, Ownership> where
Item: Sync,
Ownership: Sync,
<Item as MetricSpace<Impl>>::Distance: Sync,
Item: Sync,
Ownership: Sync,
<Item as MetricSpace<Impl>>::Distance: Sync,
impl<Item, Impl, Ownership> Unpin for Tree<Item, Impl, Ownership> where
Item: Unpin,
Ownership: Unpin,
<Item as MetricSpace<Impl>>::Distance: Unpin,
Item: Unpin,
Ownership: Unpin,
<Item as MetricSpace<Impl>>::Distance: Unpin,
impl<Item, Impl, Ownership> UnwindSafe for Tree<Item, Impl, Ownership> where
Item: UnwindSafe,
Ownership: UnwindSafe,
<Item as MetricSpace<Impl>>::Distance: UnwindSafe,
Item: UnwindSafe,
Ownership: UnwindSafe,
<Item as MetricSpace<Impl>>::Distance: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,