[][src]Struct wordfeud_solver::Wordlist

pub struct Wordlist {
    pub nodes: Vec<(u32, LabelSet)>,
    pub labels: Vec<u8>,
    pub terminal: Vec<bool>,
    pub wordfile: String,
    pub all_labels: LabelSet,
    pub word_count: usize,
    pub node_count: usize,
    pub codec: Codec,
}

A trie data structure that holds all the possible words.

Fields

nodes: Vec<(u32, LabelSet)>

List of nodes in trie. Each node is a tuple with the index of the first child node, and a CharSet with the labels of all child nodes.

labels: Vec<u8>

List of labels.

terminal: Vec<bool>

List indicating terminal nodes

wordfile: String

Path of the wordfile used to build the wordlist. Empty if the wordlist is not build from a file.

all_labels: LabelSet

The set of all characters used in the wordlist.

word_count: usize

The number of words in the wordlist

node_count: usize

The number of nodes in the wordlist.

codec: Codec

Encode words to/from labelvec

Implementations

impl Wordlist[src]

pub fn matches<'a>(
    &'a self,
    node: usize,
    row: Row,
    rowdata: &'a RowData,
    pos: usize,
    letters: &Letters
) -> Matches<'_>
[src]

Return a list of matching words. TODO.

pub fn words<'a>(
    &'a self,
    row: &'a Row,
    rowdata: &'a RowData,
    letters: &'a Letters,
    maxdist: Option<usize>
) -> impl Iterator<Item = (usize, Word)> + 'a
[src]

Return a set of characters that go in the first empty position in word

impl Wordlist[src]

pub fn from_file(wordfile: &str, codec: &Codec) -> Result<Wordlist, Error>[src]

Read the wordlist from a file. The file must be encoded in utf-8 and have one word per line.

Errors

Fails if the wordlist can not be read, or a word can not be encoded.

pub fn from_words(words: &[&str], codec: &Codec) -> Result<Wordlist, Error>[src]

Build a wordlist from a list of words.

Errors

If a word can not be encoded with the given codec.

pub fn encode<T: Item>(&self, word: &str) -> Result<ItemList<T>, Error>[src]

Encode a word with our codec.

Errors

If the word can not be encoded.

pub fn decode<T: Item>(&self, items: ItemList<T>) -> String[src]

Decode labels with our codec, and return the result as String.

Errors

If the labels can not be decoded.

pub fn range_children(&self, i: usize) -> Option<(usize, usize)>[src]

Return the start and end index of the child nodes of node i, or None if node is empty.

pub fn iter_children(&self, i: usize) -> IteratorChildren<'_>[src]

Iterate over the children of node i.

pub fn get(&self, i: usize, label: u8) -> Option<usize>[src]

Get the index of child with label for node i if present.

pub fn is_word<K: AsRef<[u8]>>(&self, word: K) -> bool[src]

Returns true if word is in wordlist

pub fn connected_row(&self, row: &Row) -> RowData[src]

Trait Implementations

impl Clone for Wordlist[src]

impl Debug for Wordlist[src]

impl Display for Wordlist[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,