pub struct Dynamic<T: Indexable + Ord>{ /* private fields */ }Expand description
A dynamic PGM-Index that supports insertions and deletions.
This index owns its data and maintains insert/delete buffers that are periodically merged into the main index. When the buffers exceed a threshold, the index is automatically rebuilt.
§Example
use pgm_extra::index::owned::Dynamic;
let mut index: Dynamic<u64> = Dynamic::new(16, 4);
index.insert(5);
index.insert(3);
index.insert(7);
assert!(index.contains(&3));
assert!(index.contains(&5));
assert!(!index.contains(&4));Implementations§
Source§impl<T: Indexable + Ord + Copy> Dynamic<T>
impl<T: Indexable + Ord + Copy> Dynamic<T>
Sourcepub fn from_sorted(
data: Vec<T>,
epsilon: usize,
epsilon_recursive: usize,
) -> Result<Self, Error>
pub fn from_sorted( data: Vec<T>, epsilon: usize, epsilon_recursive: usize, ) -> Result<Self, Error>
Create a dynamic index from pre-sorted data.
Sourcepub fn with_rebuild_threshold(self, threshold: usize) -> Self
pub fn with_rebuild_threshold(self, threshold: usize) -> Self
Set the threshold for automatic rebuilding.
Sourcepub fn lower_bound(&self, value: &T) -> Option<T>
pub fn lower_bound(&self, value: &T) -> Option<T>
Find the smallest value >= the given value.
pub fn is_empty(&self) -> bool
Sourcepub fn pending_operations(&self) -> usize
pub fn pending_operations(&self) -> usize
Get the number of pending operations in buffers.
Sourcepub fn force_rebuild(&mut self)
pub fn force_rebuild(&mut self)
Force an immediate rebuild of the index.
Sourcepub fn range<'a, R>(&'a self, range: R) -> impl Iterator<Item = T> + 'awhere
R: RangeBounds<T> + Clone + 'a,
pub fn range<'a, R>(&'a self, range: R) -> impl Iterator<Item = T> + 'awhere
R: RangeBounds<T> + Clone + 'a,
Iterate over values in the given range.
Sourcepub fn size_in_bytes(&self) -> usize
pub fn size_in_bytes(&self) -> usize
Approximate memory usage in bytes.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Dynamic<T>where
T::Key: Ord + Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned + Indexable + Ord,
impl<'de, T> Deserialize<'de> for Dynamic<T>where
T::Key: Ord + Serialize + DeserializeOwned,
T: Serialize + DeserializeOwned + Indexable + Ord,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Indexable + Ord + Copy> Extend<T> for Dynamic<T>
impl<T: Indexable + Ord + Copy> Extend<T> for Dynamic<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl<T> Freeze for Dynamic<T>
impl<T> RefUnwindSafe for Dynamic<T>
impl<T> Send for Dynamic<T>where
T: Send,
impl<T> Sync for Dynamic<T>where
T: Sync,
impl<T> Unpin for Dynamic<T>
impl<T> UnwindSafe for Dynamic<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more