Class WordBank
java.lang.Object
|
+----WordBank
public class WordBank
extends Object
implements Serializable
Stores words in a tree (Trie structure)
WordBank ()
WordBank (int)
constructor: maxlen is maximum length a word may have to be
allowed into the bank
add (String)
add word to bank.
exists (String)
returns true if word is in bank
getMaxLength ()
returns maximum allowed length of word in this instance of
the WordBank object
getTree ()
returns Trie data structure that words are stored in
load (String)
loadWords (String)
include all words found in file into bank
main (String[])
default bank form:
java -DDBANK=
-DSBANK=
-DMAXLEN=
-DDLIST=
WordBank
makeList ()
put all words in bank in Vector
makeList (String)
put all words in bank that start with prefix in Vector
remove (String)
remove word from bank
save (String)
saves Trie tree as a DFS stream.
saveWords (String)
put all words in bank in ascii file
saveWords (String, String)
put all words in bank that starts with prefix in ascii file
size ()
returns number of words in current bank
WordBank
public WordBank(int maxlen)
constructor: maxlen is maximum length a word may have to be
allowed into the bank
WordBank
public WordBank()
add
public boolean add(String word)
add word to bank. If word has any special characters or
numbers, it will not be added (unless the special character
starts and/or ends the word i.e. "'fish'" (fishes.) alas, )
remove
public void remove(String word)
remove word from bank
exists
public boolean exists(String word)
returns true if word is in bank
makeList
public Vector makeList(String prefix)
put all words in bank that start with prefix in Vector
makeList
public Vector makeList()
put all words in bank in Vector
size
public int size()
returns number of words in current bank
getMaxLength
public int getMaxLength()
returns maximum allowed length of word in this instance of
the WordBank object
getTree
public WordTreeNode getTree()
returns Trie data structure that words are stored in
save
public void save(String filename) throws IOException
saves Trie tree as a DFS stream. This is the most compact
and the most effficient file format out of the three
available for WordBank
load
public synchronized void load(String filename) throws FileNotFoundException, IOException
saveWords
public void saveWords(String prefix,
String filename) throws IOException
put all words in bank that starts with prefix in ascii file
saveWords
public void saveWords(String filename) throws IOException
put all words in bank in ascii file
loadWords
public void loadWords(String filename) throws FileNotFoundException, IOException
include all words found in file into bank
main
public static void main(String argv[])
default bank form:
java -DDBANK=
-DSBANK=
-DMAXLEN=
-DDLIST=
WordBank