pub struct Llrb<K, V>{ /* private fields */ }
Expand description
Llrb manage a single instance of in-memory index using left-leaning-red-black tree.
Implementations§
Source§impl<K, V> Llrb<K, V>
Maintenance API.
impl<K, V> Llrb<K, V>
Maintenance API.
Source§impl<K, V> Llrb<K, V>
Write operations on Llrb instance.
impl<K, V> Llrb<K, V>
Write operations on Llrb instance.
Sourcepub fn create(&mut self, key: K, value: V) -> Result<(), Error<K>>
pub fn create(&mut self, key: K, value: V) -> Result<(), Error<K>>
Create a new {key, value} entry in the index. If key is already present return error.
Sourcepub fn set(&mut self, key: K, value: V) -> Option<V>
pub fn set(&mut self, key: K, value: V) -> Option<V>
Set value for key. If there is an existing entry for key, overwrite the old value with new value and return the old value.
Sourcepub fn delete<Q>(&mut self, key: &Q) -> Option<V>
pub fn delete<Q>(&mut self, key: &Q) -> Option<V>
Delete key from this instance and return its value. If key is not present, then delete is effectively a no-op.
Sourcepub fn validate(&self) -> Result<Stats, Error<K>>
pub fn validate(&self) -> Result<Stats, Error<K>>
Validate LLRB tree with following rules:
- From root to any leaf, no consecutive reds allowed in its path.
- Number of blacks should be same under left child and right child.
- Make sure keys are in sorted order.
Additionally return full statistics on the tree. Refer to Stats
for more information.
Source§impl<K, V> Llrb<K, V>
Read operations on Llrb instance.
impl<K, V> Llrb<K, V>
Read operations on Llrb instance.
Trait Implementations§
Source§impl<K, V> Extend<(K, V)> for Llrb<K, V>
impl<K, V> Extend<(K, V)> for Llrb<K, V>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
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<K, V> Freeze for Llrb<K, V>
impl<K, V> RefUnwindSafe for Llrb<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Llrb<K, V>
impl<K, V> Sync for Llrb<K, V>
impl<K, V> Unpin for Llrb<K, V>
impl<K, V> UnwindSafe for Llrb<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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