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


Constructor Index

 o Trie()
Creates a new trie with no entries

Method Index

 o contents()
 o contents(StringBuffer)
 o elements()
Returns an alphabetically sorted list of the elements in this trie.
 o elements(Vector)
Recursive function to append elements to a linked list
 o getSortedList()
Returns an alphabetically sorted list of the elements in this trie
 o getTrieFor(String)
Returns a Trie of all the elements starting with 'key', or an Object which is a single exact match
 o index(char)
Converts a letter between a and z to a number between 0 and 25
 o input(String)
 o insert(String, Object)
Inserts the provided object into the trie with the given key.
 o length()
Counts the number of linked objects off this trie
 o listElements(LinkedList)
Recursive function to append elements to a linked list
 o main(String[])
This is a simple little test routine included so this class can be run as an application to test its cababilities
 o negIndex(char)
Returns -1 on an error as opposed to throwing an exceptions (exceptions are slow and ugly)
 o remove(String)
Removes the object with the given key from the trie
 o search(String)
Returns a trie for multiple matches, else returns null for no object matched, or returns the object matched.
 o searchExact(String)
searchExact does *not* return a Trie for 'multiple matches', but will return null in that case.

Constructors

 o Trie
 public Trie()
Creates a new trie with no entries

Methods

 o length
 public int length()
Counts the number of linked objects off this trie

 o remove
 public void remove(String key) throws NonUniqueKeyException, NoSuchElementException, BadKeyException
Removes the object with the given key from the trie

 o insert
 public void insert(String key,
                    Object item) throws NonUniqueKeyException, BadKeyException
Inserts the provided object into the trie with the given key.

 o searchExact
 public Object searchExact(String key)
searchExact does *not* return a Trie for 'multiple matches', but will return null in that case.

 o 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

 o 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

 o 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
 o negIndex
 public static final int negIndex(char c)
Returns -1 on an error as opposed to throwing an exceptions (exceptions are slow and ugly)

 o elements
 public Enumeration elements()
Returns an alphabetically sorted list of the elements in this trie. This routine is rather inefficient.

 o getSortedList
 public LinkedList getSortedList()
Returns an alphabetically sorted list of the elements in this trie

 o listElements
 protected void listElements(LinkedList ll)
Recursive function to append elements to a linked list

 o elements
 protected void elements(Vector v)
Recursive function to append elements to a linked list

 o 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

 o input
 public static String input(String prompt)
 o contents
 public String contents()
 o contents
 public String contents(StringBuffer b)

All Packages  Class Hierarchy  This Package  Previous  Next  Index