WordCharTreeRootNode

Struct WordCharTreeRootNode 

Source
pub struct WordCharTreeRootNode<'a, W> { /* private fields */ }
Expand description

The root node of a tree, where the edges are chars and the nodes are Option<W> words

Regarding the Option<W> words in the tree, see in particular the following:

Implementations§

Source§

impl<W> WordCharTreeRootNode<'_, W>

Source

pub fn get_max_depth(&self) -> usize

Get the max depth of the tree

Measured in number of lowercase char edges from the root node to the deepest node in the tree.

In a fully well-formed word char tree, this depth corresponds to the length in chars of the longest word in the tree.

Source

pub fn is_fully_well_formed(&self) -> bool

The tree is fully well-formed as long as either of the following is true:

  • The tree is empty, or
  • every leaf node (node without child edges) corresponds to a word W.

Additional notes:

  • Non-leaf nodes are allowed to have word: None.
  • Non-leaf nodes are allowed to have word: Some(W).

The tree is NOT fully well-formed if any of the leaf nodes have word: None.

The tree is suitable for iterative char search for words W if the following is true:

  • Every non-leaf node has word: None.

Additional notes:

  • Leaf nodes are allowed to have word: None.
  • Leaf nodes are allowed to have word: Some(W).

In iterative char search, words are fed into the search one char at a time. Because of this, the search will return a match as soon as the shortest match is found.

Example:

  1. You have a list of words [..., arm, army, ..., man, ...].
  2. You have the string “army man”.
  3. You start an iterative char search on the string to find words from the list in your string.
  4. The iterative char search will return a match for the word arm. You wanted to find the word army.
  5. In this case, it was not appropriate to use iterative char search, because the wordlist was not suitable for iterative char search.
Source

pub fn words(&self) -> Words<'_, W>

Returns an iterator over the words W of a word char tree

Auto Trait Implementations§

§

impl<'a, W> Freeze for WordCharTreeRootNode<'a, W>

§

impl<'a, W> RefUnwindSafe for WordCharTreeRootNode<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for WordCharTreeRootNode<'a, W>
where W: Sync,

§

impl<'a, W> Sync for WordCharTreeRootNode<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for WordCharTreeRootNode<'a, W>

§

impl<'a, W> UnwindSafe for WordCharTreeRootNode<'a, W>
where W: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.