pub struct Trie<T> { /* private fields */ }
Expand description
Prefix tree for parsing items.
Used to efficiently store and retrieve sequences of active items during parsing.
Implementations§
Source§impl<T: Clone> Trie<T>
impl<T: Clone> Trie<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new trie.
§Examples
use gf_core::Trie;
let trie: Trie<i32> = Trie::new();
assert!(trie.is_empty());
Sourcepub fn insert_chain(&mut self, keys: &[String], obj: Vec<T>)
pub fn insert_chain(&mut self, keys: &[String], obj: Vec<T>)
Sourcepub fn insert_chain1(&mut self, keys: &[String], obj: T)
pub fn insert_chain1(&mut self, keys: &[String], obj: T)
Inserts a chain with single item.
§Arguments
keys
- Slice of keys.obj
- Single item to insert.
§Examples
use gf_core::Trie;
let mut trie: Trie<i32> = Trie::new();
trie.insert_chain1(&["a".to_string(), "b".to_string()], 42);
// Verify the key path exists
assert!(trie.lookup("a").is_some());
assert!(trie.lookup("a").unwrap().lookup("b").is_some());
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Trie<T>
impl<T> RefUnwindSafe for Trie<T>where
T: RefUnwindSafe,
impl<T> Send for Trie<T>where
T: Send,
impl<T> Sync for Trie<T>where
T: Sync,
impl<T> Unpin for Trie<T>where
T: Unpin,
impl<T> UnwindSafe for Trie<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more