[][src]Struct vpsearch::Tree

pub struct Tree<Item: MetricSpace<Impl> + Clone, Impl = (), Ownership = Owned<()>> { /* fields omitted */ }

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]

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]

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]

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]

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

impl<Item, Impl, Ownership> Send for Tree<Item, Impl, Ownership> where
    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

impl<Item, Impl, Ownership> Unpin for Tree<Item, Impl, Ownership> where
    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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.