Skip to main content

BinarySearchRLE

Struct BinarySearchRLE 

Source
pub struct BinarySearchRLE<T: Clone + Eq, S = usize> { /* private fields */ }
Expand description

An ordered sequence of runs, searchable in O(lg(n)) time via binary search.

Implementations§

Source§

impl<T: Clone + Eq, S: Copy + PartialEq + PartialOrd> BinarySearchRLE<T, S>

Source

pub fn new() -> Self

Create a new, empty BinarySearchRLE.

Source

pub fn append_run(&mut self, run: IndexedRLE<T, S>) -> bool

Appends the provided run to the sequence.

Returns true if the run was added to the end of the internal list, and returns false if it was instead merged into the last run.

Runs are expected to be inserted in ascending sorted order; this does no sorting.

Source

pub fn append_token(&mut self, token: T, start: S) -> bool

Appends an individual token to the sequence as its own run.

Returns true if the token was added to the end of the internal list as its own run, and returns false if it was instead merged into the last run.

Tokens are expected to be inserted in ascending sorted order; this does no sorting.

Source

pub fn find_token_at_index(&self, index: S) -> Option<T>

Search for the token value at a particular index in the sequence.

Returns None if:

  • The sequence is empty (there are no runs)
  • The sequence index requested is before the start of the first run

Otherwise, this returns the token value for the run that contains the requested index.

Source

pub fn num_runs(&self) -> usize

Returns the total number of runs contained in the sequence.

Source

pub fn memory_size(&self) -> usize

The amount of memory it takes to store this data.

Auto Trait Implementations§

§

impl<T, S> Freeze for BinarySearchRLE<T, S>

§

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

§

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

§

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

§

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

§

impl<T, S> UnsafeUnpin for BinarySearchRLE<T, S>

§

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