All Packages Class Hierarchy This Package Previous Next Index
Class key.Trie
java.lang.Object
|
+----key.Trie
- public final class Trie
- extends Object
The only thing that can't be stored in a
Trie safely is another Trie - we use
instanceof to determine if a Trie is
terminated or not
-
Trie()
- Creates a new trie with no entries
-
contents()
-
-
contents(StringBuffer)
-
-
elements()
- Returns an alphabetically sorted list of
the elements in this trie.
-
elements(Vector)
- Recursive function to append elements
to a linked list
-
getSortedList()
- Returns an alphabetically sorted list of
the elements in this trie
-
getTrieFor(String)
- Returns a Trie of all the elements starting with
'key', or an Object which is a single exact match
-
index(char)
- Converts a letter between a and z to a number
between 0 and 25
-
input(String)
-
-
insert(String, Object)
- Inserts the provided object into the trie
with the given key.
-
length()
- Counts the number of linked objects off this trie
-
listElements(LinkedList)
- Recursive function to append elements
to a linked list
-
main(String[])
- This is a simple little test routine
included so this class can be run as
an application to test its cababilities
-
negIndex(char)
- Returns -1 on an error as opposed to throwing an
exceptions (exceptions are slow and ugly)
-
remove(String)
- Removes the object with the given key from the
trie
-
search(String)
- Returns a trie for multiple matches,
else returns null for no object matched,
or returns the object matched.
-
searchExact(String)
- searchExact does *not* return a Trie for 'multiple matches',
but will return null in that case.
Trie
public Trie()
- Creates a new trie with no entries
length
public int length()
- Counts the number of linked objects off this trie
remove
public void remove(String key) throws NonUniqueKeyException, NoSuchElementException, BadKeyException
- Removes the object with the given key from the
trie
insert
public void insert(String key,
Object item) throws NonUniqueKeyException, BadKeyException
- Inserts the provided object into the trie
with the given key.
searchExact
public Object searchExact(String key)
- searchExact does *not* return a Trie for 'multiple matches',
but will return null in that case.
getTrieFor
public Object getTrieFor(String key)
- Returns a Trie of all the elements starting with
'key', or an Object which is a single exact match
search
public Object search(String key)
- Returns a trie for multiple matches,
else returns null for no object matched,
or returns the object matched. could
easily be optimised
index
public static final int index(char c) throws BadKeyException
- Converts a letter between a and z to a number
between 0 and 25
- See Also:
- letter
negIndex
public static final int negIndex(char c)
- Returns -1 on an error as opposed to throwing an
exceptions (exceptions are slow and ugly)
elements
public Enumeration elements()
- Returns an alphabetically sorted list of
the elements in this trie. This routine
is rather inefficient.
getSortedList
public LinkedList getSortedList()
- Returns an alphabetically sorted list of
the elements in this trie
listElements
protected void listElements(LinkedList ll)
- Recursive function to append elements
to a linked list
elements
protected void elements(Vector v)
- Recursive function to append elements
to a linked list
main
public static void main(String args[])
- This is a simple little test routine
included so this class can be run as
an application to test its cababilities
input
public static String input(String prompt)
contents
public String contents()
contents
public String contents(StringBuffer b)
All Packages Class Hierarchy This Package Previous Next Index