[][src]Struct hwt::Hwt

pub struct Hwt { /* fields omitted */ }


impl Hwt[src]

pub fn new() -> Self[src]

Makes an empty Hwt.

let hwt = Hwt::new();

pub fn len(&self) -> usize[src]

Gets the number of entries in the Hwt.

let mut hwt = Hwt::new();
assert_eq!(hwt.len(), 1);

pub fn is_empty(&self) -> bool[src]

Checks if the Hwt is empty.

let mut hwt = Hwt::new();

pub fn insert(&mut self, feature: u128)[src]

Inserts an item ID to the Hwt.

  • F: A function which should give the feature for the given ID.

The most significant bit must not be set on the item.

Returns Some(t) if item t was replaced by item.

let mut hwt = Hwt::new();
assert_eq!(hwt.len(), 2);

pub fn contains(&mut self, feature: u128) -> bool[src]

Checks if a feature is in the Hwt.

let mut hwt = Hwt::new();

pub fn nearest<'a>(
    feature: u128,
    max_weight: u32,
    max_error: u32,
    node_queue: &mut NodeQueue,
    feature_heap: &mut FeatureHeap,
    dest: &'a mut [u128]
) -> &'a mut [u128]

Find the nearest neighbors to a feature. This will give the nearest neighbors first and expand outwards. It will fill dest until its full with nearest neighbors in order or until max_weight is reached, whichever comes first. max_error specifies the level of weight error allowed in the output. If it is set to 0 it will always perform an exact nearest-neighbor search. Any other number will allow this method to end once it has retrieved enough features at the current search weight and up to max_error above the weight. These features are much more likely to be nearest neighbors, but there are no guarantees that they are, since we haven't exhausted all possible locations in the search tree.

Returns the slice of filled neighbors. It may consume only part of dest if less neighbors are found than dest. It stops searching at max_weight, but might obtain features beyond that and still gives them to the user.

pub fn search_radius<'a>(
    &'a self,
    radius: u32,
    feature: u128
) -> impl Iterator<Item = u128> + 'a

Find all neighbors within a given radius.

Trait Implementations

impl Default for Hwt[src]

Auto Trait Implementations

impl Send for Hwt

impl Sync for Hwt

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized

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

impl<T> BorrowMut for T where
    T: ?Sized

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> FromCast for T[src]

impl<T, U> Cast for T where
    U: FromCast<T>,