Struct radix_trie::Trie [] [src]

pub struct Trie<K, V> { /* fields omitted */ }

Data-structure for storing and querying string-like keys and associated values.

Any keys which share a common prefix are stored below a single copy of that prefix. This saves space, and also allows the longest prefix of any given key to be found.

You can read more about Radix Tries on Wikipedia.

Lots of the methods on Trie return optional values - they can be composed nicely using Option::and_then.

Methods

impl<K, V> Trie<K, V> where
    K: TrieKey
[src]

[src]

Create an empty Trie.

[src]

Fetch a reference to the given key's corresponding value, if any.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Fetch a mutable reference to the given key's corresponding value, if any.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Insert the given key-value pair, returning any previous value associated with the key.

[src]

Remove the value associated with the given key.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Get a mutable reference to the value stored at this node, if any.

[src]

Fetch a reference to the subtrie for a given key.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Fetch a mutable reference to the subtrie for a given key.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Fetch a reference to the closest ancestor node of the given key.

If key is encoded as byte-vector b, return the node n in the tree such that n's key's byte-vector is the longest possible prefix of b, and n has a value.

Invariant: result.is_some() => result.key_value.is_some().

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Fetch the closest ancestor value for a given key.

See get_ancestor for precise semantics, this is just a shortcut.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Fetch the closest descendant for a given key.

If the key is in the trie, this is the same as subtrie.

The key may be any borrowed form of the trie's key type, but TrieKey on the borrowed form must match those for the key type

[src]

Take a function f and apply it to the value stored at key.

If no value is stored at key, store default.

Trait Implementations

impl<K, V> FromIterator<(K, V)> for Trie<K, V> where
    K: TrieKey
[src]

[src]

Creates a value from an iterator. Read more

impl<K, V> PartialEq for Trie<K, V> where
    K: TrieKey,
    V: PartialEq
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<'a, K: 'a, V: 'a> TrieCommon<'a, K, V> for &'a Trie<K, V> where
    K: TrieKey
[src]

[src]

Number of key/value pairs stored in this trie.

[src]

Return an iterator over the child subtries of this node.

[src]

Get the key stored at this node, if any.

[src]

Get the value stored at this node, if any.

[src]

Determine if the Trie contains 0 key-value pairs.

[src]

Determine if the trie is a leaf node (has no children).

[src]

Return an iterator over the keys and values of the Trie.

[src]

Return an iterator over the keys of the Trie.

[src]

Return an iterator over the values of the Trie.

impl<K: Debug, V: Debug> Debug for Trie<K, V>
[src]

[src]

Formats the value using the given formatter.