[−][src]Struct prefix_tree::PrefixTreeMap
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]
Q: AsRef<[K]>,
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]
Q: AsRef<[K]>,
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]
Q: AsRef<[K]>,
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]
Q: AsRef<[K]>,
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]
fn clone(&self) -> PrefixTreeMap<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K: Debug, V: Debug> Debug for PrefixTreeMap<K, V>
[src]
impl<K: Default, V: Default> Default for PrefixTreeMap<K, V>
[src]
fn default() -> PrefixTreeMap<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for PrefixTreeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PrefixTreeMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for PrefixTreeMap<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for PrefixTreeMap<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for PrefixTreeMap<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,