[][src]Trait hat_trie::TrieNode

pub trait TrieNode<K, V> where
    K: Copy + Hash + PartialEq + PartialOrd + Sized,
    Box<[K]>: Clone + PartialEq,
    V: Clone,
    Self: Sized
{ fn new_split(
        bucket: ArrayHash<XxHash64, Box<[K]>, V>,
        threshold: usize
    ) -> Self;
fn child(&self, key: &K) -> &NodeType<K, Self, V>;
fn value(&self) -> Option<&V>;
fn value_mut(&mut self) -> &mut Option<V>;
fn put(&mut self, key: &[K], value: V) -> Option<V>;
fn try_put<'a>(&'a mut self, key: &[K], value: V) -> Option<&'a V>
    where
        K: 'a
; fn max_key_len(&self) -> usize { ... }
fn min_key_len(&self) -> usize { ... }
fn get<'a>(&'a self, key: &[K]) -> Option<&'a V>
    where
        K: 'a
, { ... }
fn prefix<'a, 'b>(
        &'a self,
        key: &'b [K]
    ) -> PrefixIterator<'a, 'b, K, Self, V> { ... }
fn longest_prefix<'a, 'b>(
        &'a self,
        key: &'b [K]
    ) -> Option<(&'b [K], &'a V)>
    where
        K: 'a
, { ... } }

A TrieNode operation where every implementation of Trie in this crate shall support.

Required methods

fn new_split(bucket: ArrayHash<XxHash64, Box<[K]>, V>, threshold: usize) -> Self

Construct a new trie node from a bucket of pure node. This happen whenever burst or split threshold reach. It consume a given bucket and return a new Trie node which contains splitted bucket as childs.

The new trie node will have specified burst/split threshold.

fn child(&self, key: &K) -> &NodeType<K, Self, V>

Get a child node of given key from current node.

fn value(&self) -> Option<&V>

Retrieve a value of current node.

fn value_mut(&mut self) -> &mut Option<V>

Retrieve a mutable value of current node.

fn put(&mut self, key: &[K], value: V) -> Option<V>

Put value into this trie node.

If key is already exist in this trie, it replace existing entry with give key/value and return existing value to caller.

fn try_put<'a>(&'a mut self, key: &[K], value: V) -> Option<&'a V> where
    K: 'a, 

Try putting value into this trie.

If key is already exist in this trie, it will return existing value to caller without any change to the trie.

Loading content...

Provided methods

fn max_key_len(&self) -> usize

Utilities function that help shortcut key lookup when caller request key greater than max_key_len, it mean there's no such key in this trie.

By default, it return MAX value of usize.

fn min_key_len(&self) -> usize

Utilities function that help shortcut key lookup when caller request key less than min_key_len, it mean there's no such key in this trie.

By default, it return MIN value of usize.

fn get<'a>(&'a self, key: &[K]) -> Option<&'a V> where
    K: 'a, 

Get a value from this trie associated with given key slice.

fn prefix<'a, 'b>(&'a self, key: &'b [K]) -> PrefixIterator<'a, 'b, K, Self, V>

Find all possible prefix in given key that match with this trie node.

Parameter

key - a slice of key to find a prefix.

Return

It return PrefixIterator which can be used to access tuple of prefix slice and value of node in this trie.

fn longest_prefix<'a, 'b>(&'a self, key: &'b [K]) -> Option<(&'b [K], &'a V)> where
    K: 'a, 

Find a longest prefix from given key from this Trie.

This is a utility function that perform exactly like you iterate on method prefix to find a longest prefix by yourself.

Loading content...

Implementors

impl<K, V> TrieNode<K, V> for DenseVecTrieNode<K, V> where
    K: AsPrimitive<usize> + Bounded + Copy + Debug + Hash + FromPrimitive + PartialEq + PartialOrd + Sized + Unsigned,
    Box<[K]>: Clone + PartialEq,
    V: Clone + Debug + Default
[src]

Loading content...