Struct vpsearch::Handle [] [src]

pub struct Handle<Item: MetricSpace + Copy> {
    // some fields omitted
}

Methods

impl<Item: MetricSpace + Copy> Handle<Item>
[src]

fn new(items: &[Item]) -> Handle<Item>

Create a Vantage Point tree for fast nearest neighbor search.

Note that the callback must return distances that meet triangle inequality. Specifically, it can't return squared distance (you must use sqrt if you use Euclidean distance)

@param items Array of pointers to items that will be searched. Must not be freed until the tree is freed! @param num_items Number of items in the array. Must be > 0 @param get_distance A callback function that will calculdate distance between two items given their pointers. @return NULL on error or a handle that must be freed with vp_free().

fn find_nearest(&self, needle: &Item) -> usize

Finds item closest to given needle (that can be any item) and returns index of the item in items array from vp_init.

@param handle VP tree from vp_init(). Must not be NULL. @param needle The query. @return Index of the nearest item found.