|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object WordTree
public class WordTree
The WordTree class is an efficient data structure for storing a dictionary of words and quickly checking to see if particular strings are contained in the dictionary, or if they are prefixes of words in the dictionary. Lookup times scale linearly with the length of the string being searched for and do not depend on the size of the dictionary. The data structure is inspired by http://nifty.stanford.edu/2006/reges-anagrams/ which refers to: http://www.ssynth.co.uk/~gay/anagabout.html
Constructor Summary | |
---|---|
WordTree(java.lang.String fileName)
Construct a WordTree. |
Method Summary | |
---|---|
boolean |
isWord(java.lang.String string)
Return true if the argument is a word, false otherwise. |
int |
longestWord(java.lang.String startString)
Return the length of the longest word that begins with the indicated string. |
int |
numWords(java.lang.String startString)
Return the number of words that begin with the indicated string. |
void |
printWords()
Print all of the words stored in the tree. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WordTree(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- Location of the word file.
java.io.FileNotFoundException
Method Detail |
---|
public void printWords()
public int longestWord(java.lang.String startString)
startString
- A string that may start some number of words.
public int numWords(java.lang.String startString)
startString
- A string that may start some number of words.
public boolean isWord(java.lang.String string)
string
- String which may or may not be a word.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |