pub struct IncSearch<'a, Label, Value> { /* private fields */ }
Expand description
An incremental search of the trie.
Implementations§
Source§impl<'a, Label: Ord, Value> IncSearch<'a, Label, Value>
impl<'a, Label: Ord, Value> IncSearch<'a, Label, Value>
Sourcepub fn resume(trie: &'a Trie<Label, Value>, position: Position) -> Self
pub fn resume(trie: &'a Trie<Label, Value>, position: Position) -> Self
Resume an incremental search at a particular point.
use trie_rs::{Trie, inc_search::{Answer, IncSearch}};
use louds_rs::LoudsNodeNum;
let trie: Trie<u8> = ["hello", "bye"].into_iter().collect();
let mut inc_search = trie.inc_search();
assert_eq!(inc_search.query_until("he"), Ok(Answer::Prefix));
let position = LoudsNodeNum::from(inc_search);
// inc_search is dropped.
let mut inc_search2 = IncSearch::resume(&trie.0, position);
assert_eq!(inc_search2.query_until("llo"), Ok(Answer::Match));
Sourcepub fn peek(&self, chr: &Label) -> Option<Answer>
pub fn peek(&self, chr: &Label) -> Option<Answer>
Query but do not change the node we’re looking at on the trie.
Sourcepub fn query(&mut self, chr: &Label) -> Option<Answer>
pub fn query(&mut self, chr: &Label) -> Option<Answer>
Query the trie and go to node if there is a match.
Sourcepub fn query_until(
&mut self,
query: impl AsRef<[Label]>,
) -> Result<Answer, usize>
pub fn query_until( &mut self, query: impl AsRef<[Label]>, ) -> Result<Answer, usize>
Query the trie with a sequence. Will return Err(index of query)
on
first failure to match.
Sourcepub fn value(&self) -> Option<&'a Value>
pub fn value(&self) -> Option<&'a Value>
Return the value at current node. There should be one for any node where
answer.is_match()
is true.
Sourcepub fn goto_longest_prefix(&mut self) -> Result<usize, usize>
pub fn goto_longest_prefix(&mut self) -> Result<usize, usize>
Go to the longest shared prefix.
Sourcepub fn prefix<C, M>(&self) -> Cwhere
C: TryFromIterator<Label, M>,
Label: Clone,
pub fn prefix<C, M>(&self) -> Cwhere
C: TryFromIterator<Label, M>,
Label: Clone,
Return the current prefix for this search.
Sourcepub fn prefix_len(&self) -> usize
pub fn prefix_len(&self) -> usize
Returne the length of the current prefix for this search.
Trait Implementations§
Auto Trait Implementations§
impl<'a, Label, Value> Freeze for IncSearch<'a, Label, Value>
impl<'a, Label, Value> RefUnwindSafe for IncSearch<'a, Label, Value>where
Label: RefUnwindSafe,
Value: RefUnwindSafe,
impl<'a, Label, Value> Send for IncSearch<'a, Label, Value>
impl<'a, Label, Value> Sync for IncSearch<'a, Label, Value>
impl<'a, Label, Value> Unpin for IncSearch<'a, Label, Value>
impl<'a, Label, Value> UnwindSafe for IncSearch<'a, Label, Value>where
Label: RefUnwindSafe,
Value: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more