[][src]Struct hwt::Hwt

pub struct Hwt { /* fields omitted */ }

Methods

impl Hwt[src]

pub fn new() -> Self[src]

Makes an empty Hwt.

let hwt = Hwt::new();
assert!(hwt.is_empty());

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

Gets the number of entries in the Hwt.

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

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

Checks if the Hwt is empty.

let mut hwt = Hwt::new();
assert!(hwt.is_empty());
hwt.insert(0b101);
assert!(!hwt.is_empty());

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();
hwt.insert(0b101);
hwt.insert(0b010);
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();
hwt.insert(0b101);
hwt.insert(0b010);
assert!(hwt.contains(0b101));
assert!(hwt.contains(0b010));
assert!(!hwt.contains(0b000));
assert!(!hwt.contains(0b111));

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

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
[src]

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>, 
[src]

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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>, 
[src]