[][src]Struct hamming_heap::FixedHammingHeap

pub struct FixedHammingHeap<W, T> where
    W: ArrayLength<Vec<T>>, 
{ /* fields omitted */ }

This keeps the nearest cap items at all times.

This heap is not intended to be popped. Instead, this maintains the best cap items, and then when you are done adding items, you may fill a slice or iterate over the results. Theoretically, this could also allow popping elements in constant time, but that would incur a performance penalty for the highly specialized purpose this serves. This is specifically tailored for doing hamming space nearest neighbor searches.

Methods

impl<W, T> FixedHammingHeap<W, T> where
    W: ArrayLength<Vec<T>>, 
[src]

pub fn set_capacity(&mut self, cap: usize)[src]

This sets the capacity of the queue to cap, meaning that adding items to the queue will eject the worst ones if they are better once cap is reached. If the capacity is lowered, this removes the worst elements to keep size == cap.

pub fn set_len(&mut self, len: usize)[src]

This removes elements until it reaches len. If len is higher than the current number of elements, this does nothing. If the len is lowered, this will unconditionally allow insertions until cap is reached.

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

Gets the len or size of the heap.

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

Checks if the heap is empty.

pub fn clear(&mut self)[src]

Clear the queue while maintaining the allocated memory.

pub fn push(&mut self, distance: u32, item: T) -> bool[src]

Add a feature to the search.

Returns true if it was added.

pub fn fill_slice<'a>(&self, s: &'a mut [T]) -> &'a mut [T] where
    T: Clone
[src]

Fill a slice with the top elements and return the part of the slice written.

pub fn worst(&self) -> u32[src]

Gets the worst distance in the queue currently.

This is initialized to max (which is the worst possible distance) until cap elements have been inserted.

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

Returns true if the cap has been reached.

pub fn iter(&mut self) -> impl Iterator<Item = (u32, &T)>[src]

Iterate over the entire queue in best-to-worse order.

pub fn iter_mut(&mut self) -> impl Iterator<Item = (u32, &mut T)>[src]

Iterate over the entire queue in best-to-worse order.

pub unsafe fn push_at_cap(&mut self, distance: u32, item: T) -> bool[src]

Add a feature to the search with the precondition we are already at the cap.

Warning: This function cannot cause undefined behavior, but it can be used incorrectly. This should only be called after at_cap() can been called and returns true. This shouldn't be used unless you profile and actually find that the branch predictor is having issues with the if statement in push().

Trait Implementations

impl<W: Clone, T: Clone> Clone for FixedHammingHeap<W, T> where
    W: ArrayLength<Vec<T>>, 
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<W, T> Default for FixedHammingHeap<W, T> where
    W: ArrayLength<Vec<T>>, 
[src]

impl<W, T> Debug for FixedHammingHeap<W, T> where
    W: ArrayLength<Vec<T>>,
    T: Debug
[src]

Auto Trait Implementations

impl<W, T> Sync for FixedHammingHeap<W, T> where
    T: Sync

impl<W, T> Send for FixedHammingHeap<W, T> where
    T: Send

impl<W, T> Unpin for FixedHammingHeap<W, T> where
    <W as ArrayLength<Vec<T>>>::ArrayType: Unpin

impl<W, T> RefUnwindSafe for FixedHammingHeap<W, T> where
    <W as ArrayLength<Vec<T>>>::ArrayType: RefUnwindSafe

impl<W, T> UnwindSafe for FixedHammingHeap<W, T> where
    <W as ArrayLength<Vec<T>>>::ArrayType: UnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self