au.id.pbw.hyfo.hyph
Class ShortTernaryTree

java.lang.Object
  extended by au.id.pbw.hyfo.hyph.ShortTernaryTree
All Implemented Interfaces:
TernaryTree, Serializable

public class ShortTernaryTree
extends Object
implements TernaryTree, Serializable

Author:
pbw
See Also:
Serialized Form

Nested Class Summary
 class ShortTernaryTree.TernaryIterator
           
 class ShortTernaryTree.TernaryTreeWalker
           
 
Constructor Summary
ShortTernaryTree(int size)
          Creates a new instance of ShortTernaryTree
 
Method Summary
 Subsearch find_next(int[] key, int index, int node_num)
          Returns a Subsearch representing a position in the tree at which non-null DATA was found while tracing a given key.
 int find(int[] key)
          Find the data pointer associated with a given key, or 0 if the key does not occur .
 int get_equal_node(int node)
          Gets the node number from the equal link of the given node.
 String get_key(List<Integer> stack)
          Derive a string from the list of codepoints representing the key.
 int get_node_data_ptr(int node)
          Gets the node data.
 void initialize_data_array()
          Finalizes the data initialization of this ShortTernaryTree.
 ShortTernaryTree.TernaryIterator iterator()
          Gets an in-order iterator over the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortTernaryTree

public ShortTernaryTree(int size)
                 throws HyphenationException
Creates a new instance of ShortTernaryTree

Throws:
HyphenationException
Method Detail

get_node_data_ptr

public int get_node_data_ptr(int node)
Gets the node data.

Specified by:
get_node_data_ptr in interface TernaryTree
Parameters:
node - the number of the data node.
Returns:
the node data payload.

find

public int find(int[] key)
Find the data pointer associated with a given key, or 0 if the key does not occur .

Specified by:
find in interface TernaryTree
Parameters:
key - the key, as an array of Unicode codepoints.
Returns:
the DATA or null.

find_next

public Subsearch find_next(int[] key,
                           int index,
                           int node_num)
Returns a Subsearch representing a position in the tree at which non-null DATA was found while tracing a given key. This is a match of a prefix of the search key. The returned Subsearch can subsequently be used to find the next longer prefix of the key with associated DATA.

Specified by:
find_next in interface TernaryTree
Parameters:
key - the key of which prefixes are being sought.
index - the next Unicode character of the search string. A prefix equal to or longer than this position of the key will be the next found, if one exists.
node_num - the node number at which the search commences.
Returns:
a Subsearch representing the next located prefix of the key, or null.

initialize_data_array

public void initialize_data_array()
                           throws HyphenationException
Finalizes the data initialization of this ShortTernaryTree. This assumes that all required nodes have been added to the tree. The parallel arrays representing the node links (equal, less, greater, parent and the pointer to the node data are all reset to their minimum size. The List of DATA values which has been collected is reduced to an array.

Specified by:
initialize_data_array in interface TernaryTree
Throws:
HyphenationException

get_key

public String get_key(List<Integer> stack)
Description copied from interface: TernaryTree
Derive a string from the list of codepoints representing the key.

Specified by:
get_key in interface TernaryTree
Parameters:
stack - the list of codepoints representing the key.
Returns:
the key as a string.

iterator

public ShortTernaryTree.TernaryIterator iterator()
Description copied from interface: TernaryTree
Gets an in-order iterator over the tree.

Specified by:
iterator in interface TernaryTree
Returns:
the in-order iterator.

get_equal_node

public int get_equal_node(int node)
Description copied from interface: TernaryTree
Gets the node number from the equal link of the given node.

Specified by:
get_equal_node in interface TernaryTree
Parameters:
node - the node whoe equal link is required.
Returns:
the equal link or 0.


Copyright © 2005-2006 Peter B. West.