Method SearchPatterns
SearchPatterns(Char[], Int32, Byte[])
Search for all possible partial matches of word starting at index an update interletter values. In other words, it does something like:
for (i=0; i<patterns.Length; i++)
{
if (word.Substring(index).StartsWith(patterns[i]))
update_interletter_values(patterns[i]);
}
But it is done in an efficient way since the patterns are stored in a ternary tree. In fact, this is the whole purpose of having the tree: doing this search without having to test every single pattern. The number of patterns for languages such as English range from 4000 to 10000. Thus, doing thousands of string comparisons for each word to hyphenate would be really slow without the tree. The tradeoff is memory, but using a ternary tree instead of a trie, almost halves the the memory used by Lout or TeX. It's also faster than using a hash table
Declaration
protected virtual void SearchPatterns(char[] word, int index, byte[] il)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | word | null terminated word to match |
System.Int32 | index | start index from word |
System.Byte[] | il | interletter values array to update |