Trie

Trie

Root of a tree of TrieNode, and operations thereon required to convert the Trie into an optimal Directed Acyclic Word Graph (DAWG). As such this is mis-named; the structure starts life as a Trie but may also represent a DAWG.

Constructor

new Trie()

Description:
  • Construct a Trie from a simple word list

Source:

Members

_debug :function

Description:
  • Debug function

Source:

Debug function

Type:
  • function

numberOfNodes :number

Description:
  • Total number of nodes in this trie (count of all nodes)

Source:

Total number of nodes in this trie (count of all nodes)

Type:
  • number

numberOfWords :number

Description:
  • Total number of words in this trie (count of end nodes)

Source:

Total number of words in this trie (count of end nodes)

Type:
  • number

Methods

addWord(word)

Description:
  • Add a word to the Trie

Source:
Parameters:
Name Type Description
word string

word to add

eachWord(cb)

Description:
  • Visit all words in sorted order.

Source:
Parameters:
Name Type Description
cb TrieNode~wordCallback

callback function

encode() → {ArrayBuffer}

Description:
  • Convert a Trie (or DAWG) into a linear 32-bit integer array.

Source:
Returns:

array of 32-bit integers

Type
ArrayBuffer

generateDAWG()

Description:
  • Go through the steps to generate a DAWG from a Trie tree by merging duplicate sub-trees.

Source: