[−][src]Struct another_radix_trie::RadixTrie
RadixTrie stores values associated with strings
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<usize>::new(); trie.insert("ON", 3); trie.insert("ON20", 4) // The internal structure of this trie will be // - "ON" 3 // - "20" 4
Methods
impl<T> RadixTrie<T>
[src]
pub fn new() -> Self
[src]
Construct a new trie
pub fn insert(&mut self, label: &str, value: T)
[src]
Insert label and associated value into the trie. Values will be override if the label provided is already in the trie
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<()>::new(); trie.insert("label", ());
pub fn find(&self, label: &str) -> Option<&T>
[src]
Returns the borrowed value associated with related label. If the label does not exist in the
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<usize>::new(); trie.insert("label", 5); assert_eq!(trie.find("label"), Some(&5)); assert_eq!(trie.find("not exist"), None);
pub fn find_mut(&mut self, label: &str) -> Option<&mut T>
[src]
Returns the mutable borrowed value associated with related label. If the label does not exist in the
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<usize>::new(); trie.insert("label", 5); assert_eq!(trie.find_mut("label"), Some(&mut 5)); assert_eq!(trie.find("not exist"), None);
pub fn remove(&mut self, label: &str) -> Option<T>
[src]
Removes the value associated with related label. If the provided label does not exist in the trie, return None
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<usize>::new(); trie.insert("label", 5); assert_eq!(trie.remove("label"), Some(5)); assert_eq!(trie.remove("not exist"), None);
pub fn start_with(&self, prefix: &str) -> Vec<(String, &T)>
[src]
Returns all values with their labels where the labels start with given prefix
Example
use another_radix_trie::RadixTrie; let mut trie = RadixTrie::<usize>::new(); trie.insert("lab", 3); trie.insert("label", 5); assert_eq!(trie.start_with("la"), vec![(String::from("lab"), &3), (String::from("label"), &5)])
Auto Trait Implementations
impl<T> RefUnwindSafe for RadixTrie<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for RadixTrie<T> where
T: Send,
T: Send,
impl<T> Sync for RadixTrie<T> where
T: Sync,
T: Sync,
impl<T> Unpin for RadixTrie<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for RadixTrie<T> where
T: UnwindSafe,
T: 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, 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>,