Struct MinimizerQueue

Source
pub struct MinimizerQueue<T: Hash + Copy, S: BuildHasher = DefaultHashBuilder> { /* private fields */ }
Expand description

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

§Examples

use minimizer_queue::MinimizerQueue;

let mut queue = MinimizerQueue::new(3); // width 3
queue.insert(1);
queue.insert(2);
queue.insert(3);
queue.get_min(); // element with the smallest hash among 1, 2 and 3

queue.insert(4);
queue.get_min(); // element with the smallest hash among 2, 3 and 4

Implementations§

Source§

impl<T: Hash + Copy> MinimizerQueue<T>

Source

pub fn new(width: u16) -> Self

Creates an empty MinimizerQueue with the given width.

Source

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

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

Source§

impl<T: Hash + Copy, S: BuildHasher> MinimizerQueue<T, S>

Source

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

Creates an empty MinimizerQueue 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 MinimizerQueue.

Source

pub fn is_empty(&self) -> bool

Returns true if the MinimizerQueue is empty.

Source

pub fn multiple_mins(&self) -> bool

Returns true if there are multiple minimizers in the queue.

Source

pub fn get_min(&self) -> T

Returns the leftmost minimizer in the queue.

Source

pub fn get_min_pos(&self) -> (T, usize)

Returns the leftmost minimizer and its relative position in the queue.

Source

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

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

Source

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

Inserts x in the queue and updates the current minimizer.

Source

pub fn insert_with_hash(&mut self, x: T, 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<T, S> Freeze for MinimizerQueue<T, S>
where S: Freeze,

§

impl<T, S> RefUnwindSafe for MinimizerQueue<T, S>

§

impl<T, S> Send for MinimizerQueue<T, S>
where S: Send, T: Send,

§

impl<T, S> Sync for MinimizerQueue<T, S>
where S: Sync, T: Sync,

§

impl<T, S> Unpin for MinimizerQueue<T, S>
where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for MinimizerQueue<T, S>
where S: UnwindSafe, T: 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.