import java.util.ArrayList;
/**
* A list of words (i.e., strings). This class is mainly intended to be
* a utility class for other things, such as chained hash tables (e.g.,
* as used in the Dictionary
class).
* @author Doug Baldwin
*/
public class WordList {
// Lists of words are really just wrappers around array lists of
// strings. But having the wrapper is important because Java doesn't
// allow arrays of generic classes, so some way of hiding this
// generic is important if I want to make arrays of lists of words.
private ArrayList contents;
/**
* Initialize a list of words to be empty.
*/
public WordList() {
contents = new ArrayList();
}
/**
* Add a word to a list.
* @param word The word being added.
*/
public void add( String word ) {
contents.add( word );
}
/**
* Check whether a word is in a list or not.
* @param word The word to look for.
* @return True if the word is in the list, False if it isn't.
*/
public boolean find( String word ) {
return contents.contains( word );
}
}