pub struct PatriciaTree<K: Copy, V> { /* private fields */ }
Expand description
Patricia troo
Implementations§
Source§impl<K, V> PatriciaTree<K, V>
impl<K, V> PatriciaTree<K, V>
Sourcepub fn new() -> PatriciaTree<K, V>
pub fn new() -> PatriciaTree<K, V>
Constructs a new Patricia tree
Sourcepub fn lookup_mut(&mut self, key: &K, key_len: usize) -> Option<&mut V>
pub fn lookup_mut(&mut self, key: &K, key_len: usize) -> Option<&mut V>
Lookup a value by exactly matching key
and return a referenc
Sourcepub fn lookup(&self, key: &K, key_len: usize) -> Option<&V>
pub fn lookup(&self, key: &K, key_len: usize) -> Option<&V>
Lookup a value by exactly matching key
and return a mutable reference
Sourcepub fn insert(&mut self, key: &K, key_len: usize, value: V) -> bool
pub fn insert(&mut self, key: &K, key_len: usize, value: V) -> bool
Inserts a value with key key
, returning true on success. If a value is already
stored against key
, do nothing and return false.
Sourcepub fn insert_or_update(&mut self, key: &K, key_len: usize, value: V) -> bool
pub fn insert_or_update(&mut self, key: &K, key_len: usize, value: V) -> bool
Inserts a value with key key
, returning true on success. If a value is already
stored against key
, overwrite it and return false.
Sourcepub fn delete(&mut self, key: &K, key_len: usize) -> Option<V>
pub fn delete(&mut self, key: &K, key_len: usize) -> Option<V>
Deletes a value with key key
, returning it on success. If no value with
the given key is found, return None
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count all the nodes
Trait Implementations§
Source§impl<D, K, V> Decodable<D> for PatriciaTree<K, V>
impl<D, K, V> Decodable<D> for PatriciaTree<K, V>
Source§fn consensus_decode(d: &mut D) -> Result<PatriciaTree<K, V>, Error>
fn consensus_decode(d: &mut D) -> Result<PatriciaTree<K, V>, Error>
Decode an object with a well-defined format
Auto Trait Implementations§
impl<K, V> Freeze for PatriciaTree<K, V>
impl<K, V> RefUnwindSafe for PatriciaTree<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PatriciaTree<K, V>
impl<K, V> Sync for PatriciaTree<K, V>
impl<K, V> Unpin for PatriciaTree<K, V>
impl<K, V> UnwindSafe for PatriciaTree<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