org.thdl.util
Class Trie

java.lang.Object
  |
  +--org.thdl.util.Trie

public class Trie
extends Object

A digital search trie for 7-bit ASCII text. The API is a subset of java.util.Hashtable. The key must be a 7-bit ASCII string. The value may be any Java Object.


Field Summary
static int ALPHA_SIZE
          Size of the m_nextChar array.
 
Constructor Summary
Trie()
          Constructs a trie.
 
Method Summary
 Object get(String key)
          Gets an object that matches the key.
 boolean hasPrefix(String key)
          Returns true if and only if key is a prefix of another, distinct member of the trie.
 Object put(String key, Object value)
          Puts an object into the trie for lookup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALPHA_SIZE

public static final int ALPHA_SIZE
Size of the m_nextChar array.

See Also:
Constant Field Values
Constructor Detail

Trie

public Trie()
Constructs a trie.

Method Detail

put

public Object put(String key,
                  Object value)
Puts an object into the trie for lookup.

Parameters:
key - must be a 7-bit ASCII string
value - any java object, but not null.
Returns:
The old object that matched key, or null.
Throws:
NullPointerException - if value is null or if key is null

get

public Object get(String key)
Gets an object that matches the key.

Parameters:
key - must be a 7-bit ASCII string
Returns:
The object that matches the key, or null.

hasPrefix

public boolean hasPrefix(String key)
Returns true if and only if key is a prefix of another, distinct member of the trie. Note that key may be in the trie as well as a prefix of something in the trie, but not all keys in the trie are prefixes of other keys. (In the trie you might naturally construct for the extended Wylie keyboard, "t" is a prefix, as is "ts", but "tsh", though a member of the trie, is not a prefix because there is no string x such that x begins with "tsh" but is not equal to "tsh" that is in the trie.)

Parameters:
key - must be a 7-bit ASCII string
Returns:
The object that matches the key, or null.


These API docs were created 02/02/2003 08:19 PM.
Copyright © 2001-2002 Tibetan and Himalayan Digital Library. All Rights Reserved.
Hosted by SourceForge_Logo