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>
impl<T: Clone + Eq, S: Copy + PartialEq + PartialOrd> BinarySearchRLE<T, S>
Sourcepub fn append_run(&mut self, run: IndexedRLE<T, S>) -> bool
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.
Sourcepub fn append_token(&mut self, token: T, start: S) -> bool
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.
Sourcepub fn find_token_at_index(&self, index: S) -> Option<T>
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.
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
The amount of memory it takes to store this data.