Struct ArrayStump

Source
pub struct ArrayStump<T, C>
where C: Fn(&T, &T) -> Ordering,
{ /* private fields */ }
Expand description

The core data structure representing a two-level sorted stump.

Implementations§

Source§

impl<T, C> ArrayStump<T, C>
where C: Fn(&T, &T) -> Ordering, T: Clone + Debug,

Source

pub fn new(comparator: C) -> ArrayStump<T, C>

Creates a new ArrayStump instance.

Source

pub fn new_explicit(comparator: C, init_capacity: u16) -> ArrayStump<T, C>

Creates a new ArrayStump instance with explicit control over internal parameters.

Source

pub fn len(&self) -> usize

Returns the length (i.e., number of elements stored).

Source

pub fn insert(&mut self, t: T) -> Option<Index>

Insert a value.

Source

pub fn remove(&mut self, t: &T) -> bool

Remove a value.

Source

pub fn remove_by_index(&mut self, idx: Index)

Remove a value by its index.

Source

pub fn find(&self, t: &T) -> Option<Index>

Try to find an existing value.

Source

pub fn get_by_index(&self, idx: Index) -> &T

Returns the element at a given index. Caution: An index that has been obtained before mutating the data structure is an invalid index. Calling this function with an invalid index may panic with index out of bounds.

Source

pub fn next_index(&self, idx: Index) -> Option<Index>

Returns the index of the next element if there is one.

Source

pub fn prev_index(&self, idx: Index) -> Option<Index>

Returns the index of the previous element if there is one.

Source

pub fn min(&self) -> Option<&T>

Returns the minimum value.

Source

pub fn max(&self) -> Option<&T>

Returns the maximum value.

Source

pub fn traverse<F>(&self, f: F)
where F: FnMut(usize, &T),

Traverse collection given a callback.

Source

pub fn collect(&self) -> Vec<T>

Collect collection into a vector.

Source

pub fn get_leaf_fill_ratio(&self) -> f64

Get the average fill ratio of leafs, i.e., a value of 0.5 means that leafs are on average half full.

This is an O(1) operation.

Source

pub fn get_leaf_fill_min(&self) -> Option<usize>

Get the minimum number of elements in a leaf.

This requires iterating all blocks, and thus, is an O(sqrt N) operation.

Source

pub fn get_leaf_fill_max(&self) -> Option<usize>

Get the maximum number of elements in a leaf.

This requires iterating all blocks, and thus, is an O(sqrt N) operation.

Source

pub fn get_capacity(&self) -> u16

Get the current max leaf capacity.

Source

pub fn get_num_blocks(&self) -> usize

Get the current number of blocks.

Source

pub fn debug(&self)

Internal debug helper function.

Source

pub fn debug_order(&self)

Source

pub fn fix_index(&self, transition: IndexTransition, idx: Index) -> Index

Source

pub fn wiggle(&mut self, idx: Index) -> Option<IndexTransition>

Auto Trait Implementations§

§

impl<T, C> Freeze for ArrayStump<T, C>
where C: Freeze,

§

impl<T, C> RefUnwindSafe for ArrayStump<T, C>

§

impl<T, C> Send for ArrayStump<T, C>
where C: Send, T: Send,

§

impl<T, C> Sync for ArrayStump<T, C>
where C: Sync, T: Sync,

§

impl<T, C> Unpin for ArrayStump<T, C>
where C: Unpin, T: Unpin,

§

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