Struct qptrie::Trie

source ·
pub struct Trie<TK: PartialEq + AsRef<[u8]>, TV> { /* private fields */ }
Expand description

A qp-trie.

Implementations§

source§

impl<TK: PartialEq + AsRef<[u8]>, TV> Trie<TK, TV>

source

pub fn new() -> Self

Creates a new, empty qp-trie.

source

pub fn max_height(self, max_height: usize) -> Self

Refuses to insert nodes that would make the trie height greater than max_height.

source

pub fn is_empty(&self) -> bool

Returns true if the trie is empty.

source

pub fn insert(&mut self, key: TK, val: TV) -> bool

Inserts a new node with the key key.

source

pub fn get(&self, key: &TK) -> Option<&TV>

Returns the value associated with the key key, or None if the key is not present in the trie.

source

pub fn get_mut(&mut self, key: &TK) -> Option<&mut TV>

Returns a mutable value associated with the key key, or None if the key is not present in the trie.

source

pub fn remove(&mut self, key: &TK) -> bool

Removes the node associated with the key key.

Returns true if the key was found, or false if the operation was a no-op.

source

pub fn prefix_iter<'t>( &'t self, prefix: &'t TK ) -> TriePrefixIterator<'_, TK, TV>

Creates a new iterator over all the nodes whose key includes prefix as a prefix.

Trait Implementations§

source§

impl<TK: Clone + PartialEq + AsRef<[u8]>, TV: Clone> Clone for Trie<TK, TV>

source§

fn clone(&self) -> Trie<TK, TV>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<TK: Debug + PartialEq + AsRef<[u8]>, TV: Debug> Debug for Trie<TK, TV>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<TK: PartialEq + AsRef<[u8]>, TV> Default for Trie<TK, TV>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<TK, TV> RefUnwindSafe for Trie<TK, TV>

§

impl<TK, TV> Send for Trie<TK, TV>
where TK: Send, TV: Send,

§

impl<TK, TV> Sync for Trie<TK, TV>
where TK: Sync, TV: Sync,

§

impl<TK, TV> Unpin for Trie<TK, TV>
where TK: Unpin, TV: Unpin,

§

impl<TK, TV> UnwindSafe for Trie<TK, TV>
where TK: UnwindSafe, TV: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.