[][src]Struct prefix_tree::PrefixTreeMap

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

A map implemented with prefix tree.

Methods

impl<K: Eq + Clone, V> PrefixTreeMap<K, V>[src]

pub fn new() -> PrefixTreeMap<K, V>[src]

Creates an empty PrefixTreeMap.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();

pub fn contains_key<Q>(&self, key: Q) -> bool where
    Q: AsRef<[K]>, 
[src]

Returns true if the map contains a value for the specified key.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
map.insert("foo", 1);
assert_eq!(map.contains_key("foo"), true);
assert_eq!(map.contains_key("bar"), false);

pub fn clear(&mut self)[src]

Clears the map, removing all key-value pairs.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
map.insert("foo", 1);
map.clear();
assert!(map.is_empty());

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

Returns a reference to the value corresponding to the key.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
map.insert("foo", 1);
assert_eq!(map.get("foo"), Some(&1));
assert_eq!(map.get("bar"), None);

pub fn get_mut<Q>(&mut self, key: Q) -> Option<&mut V> where
    Q: AsRef<[K]>, 
[src]

Returns a mutable reference to the value corresponding to the key.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
map.insert("foo", 1);
if let Some(x) = map.get_mut("foo") {
    *x = 2;
}
assert_eq!(map.get("foo"), Some(&2));

pub fn insert<Q>(&mut self, key: Q, value: V) -> Option<V> where
    Q: AsRef<[K]>, 
[src]

Inserts a key-value pair into the map.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
assert_eq!(map.insert("a", 42), None);
assert_eq!(map.is_empty(), false);
assert_eq!(map.insert("a", 5), Some(42));
assert_eq!(map.get("a"), Some(&5));

pub fn is_empty(&self) -> bool[src]

Returns true if the map contains no elements.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
assert_eq!(map.is_empty(), true);
map.insert("foo", 1);
assert_eq!(map.is_empty(), false);

pub fn len(&self) -> usize[src]

Returns the number of elements in the map.

Examples

use prefix_tree::PrefixTreeMap;

let mut map: PrefixTreeMap<u8, i32> = PrefixTreeMap::new();
assert_eq!(map.len(), 0);
map.insert("foo", 1);
assert_eq!(map.len(), 1);

Trait Implementations

impl<K: Clone, V: Clone> Clone for PrefixTreeMap<K, V>[src]

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

impl<K: Default, V: Default> Default for PrefixTreeMap<K, V>[src]

Auto Trait Implementations

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

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

impl<K, V> Sync for PrefixTreeMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Unpin for PrefixTreeMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> UnwindSafe for PrefixTreeMap<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.