[][src]Struct llrb_index::Llrb

pub struct Llrb<K, V> where
    K: Clone + Ord,
    V: Clone
{ /* fields omitted */ }

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]

Different ways to construct a new Llrb instance.

pub fn new<S>(name: S) -> Llrb<K, V> where
    S: AsRef<str>, 
[src]

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]

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]

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]

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]

Read operations on Llrb instance.

pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<V> where
    K: Borrow<Q>,
    Q: Ord
[src]

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]

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]

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]

impl<K, V> Extend<(K, V)> for Llrb<K, V> where
    K: Clone + Ord,
    V: Clone
[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for Llrb<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Send for Llrb<K, V> where
    K: Send,
    V: Send

impl<K, V> Sync for Llrb<K, V> where
    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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.