[−][src]Struct llrb_index::Llrb
Llrb manage a single instance of in-memory index using left-leaning-red-black tree.
Implementations
impl<K, V> Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
Different ways to construct a new Llrb instance.
pub fn new<S>(name: S) -> Llrb<K, V> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Create an empty instance of Llrb, identified by name
.
Applications can choose unique names.
impl<K, V> Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
Maintenance API.
pub fn id(&self) -> String
[src]
Identify this instance. Applications can choose unique names while creating Llrb instances.
pub fn len(&self) -> usize
[src]
Return number of entries in this instance.
pub fn is_empty(&self) -> bool
[src]
Check whether this index is empty.
pub fn stats(&self) -> Stats
[src]
Return quickly with basic statisics, only entries() method is valid with this statisics.
impl<K, V> Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
Write operations on Llrb instance.
pub fn create(&mut self, key: K, value: V) -> Result<(), Error<K>>
[src]
Create a new {key, value} entry in the index. If key is already present return error.
pub fn set(&mut self, key: K, value: V) -> Option<V>
[src]
Set value for key. If there is an existing entry for key, overwrite the old value with new value and return the old value.
pub fn delete<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
Delete key from this instance and return its value. If key is not present, then delete is effectively a no-op.
pub fn validate(&self) -> Result<Stats, Error<K>>
[src]
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.
impl<K, V> Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
Read operations on Llrb instance.
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
Get the value for key.
pub fn random<R: Rng>(&self, rng: &mut R) -> Option<(K, V)>
[src]
Return a random entry from this index.
pub fn iter(&self) -> Iter<'_, K, V>
[src]
Return an iterator over all entries in this instance.
pub fn range<Q: ?Sized, R>(&self, range: R) -> Range<'_, K, V, R, Q> where
K: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord,
Range over all entries from low to high.
pub fn reverse<R, Q: ?Sized>(&self, range: R) -> Reverse<'_, K, V, R, Q> where
K: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord,
Reverse range over all entries from high to low.
Trait Implementations
impl<K: Clone, V: Clone> Clone for Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
impl<K, V> Extend<(K, V)> for Llrb<K, V> where
K: Clone + Ord,
V: Clone,
[src]
K: Clone + Ord,
V: Clone,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (K, V)>,
[src]
I: IntoIterator<Item = (K, V)>,
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for Llrb<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Llrb<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for Llrb<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for Llrb<K, V>
impl<K, V> UnwindSafe for Llrb<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,