Struct ImplicitMinimizerQueue

Source
pub struct ImplicitMinimizerQueue<S: BuildHasher = DefaultHashBuilder> { /* private fields */ }
Expand description

A monotone queue that can compute the positions of consecutive minimizers in constant time.

§Examples

use minimizer_queue::ImplicitMinimizerQueue;

let mut queue = ImplicitMinimizerQueue::new(3); // width 3
queue.insert(&1);
queue.insert(&2);
queue.insert(&3);
queue.get_min_pos(); // position of the element with the smallest hash among 1, 2 and 3

queue.insert(&4);
queue.get_min_pos(); // position of the element with the smallest hash among 2, 3 and 4

Implementations§

Source§

impl ImplicitMinimizerQueue

Source

pub fn new(width: u16) -> Self

Creates an empty ImplicitMinimizerQueue with the given width.

Source

pub fn with_seed(width: u16, seed: u64) -> Self

Creates an empty ImplicitMinimizerQueue with the given width and seed. Changing the seed will change the ordering of the minimizers.

Source§

impl<S: BuildHasher> ImplicitMinimizerQueue<S>

Source

pub fn with_hasher(width: u16, hash_builder: S) -> Self

Creates an empty ImplicitMinimizerQueue with the given width and hasher. The hasher will define the ordering of the minimizers, based on their hashes.

Source

pub fn width(&self) -> usize

Returns the width of the ImplicitMinimizerQueue.

Source

pub fn is_empty(&self) -> bool

Returns true if the ImplicitMinimizerQueue is empty.

Source

pub fn multiple_mins(&self) -> bool

Returns true if there are multiple minimizers in the queue.

Source

pub fn get_min_pos(&self) -> usize

Returns the relative position of the leftmost minimizer.

Source

pub fn get_inner_min_pos(&self) -> (usize, Option<usize>)

Returns the relative position of the innermost minimizer, with a second choice in case of tie.

Source

pub fn insert<T: Hash>(&mut self, x: &T)

Inserts x in the queue and updates the current minimizer.

Source

pub fn insert_hash(&mut self, hash: u64)

Inserts x in the queue with the given hash and updates the current minimizer.

Source

pub fn clear(&mut self)

Clears the deque, removing all elements.

Auto Trait Implementations§

§

impl<S> Freeze for ImplicitMinimizerQueue<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for ImplicitMinimizerQueue<S>
where S: RefUnwindSafe,

§

impl<S> Send for ImplicitMinimizerQueue<S>
where S: Send,

§

impl<S> Sync for ImplicitMinimizerQueue<S>
where S: Sync,

§

impl<S> Unpin for ImplicitMinimizerQueue<S>
where S: Unpin,

§

impl<S> UnwindSafe for ImplicitMinimizerQueue<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.