public final class WordLists extends Object
Modifier and Type | Field and Description |
---|---|
static Comparator<String> |
CASE_INSENSITIVE_COMPARATOR
Case insensitive comparator.
|
static Comparator<String> |
CASE_SENSITIVE_COMPARATOR
Case sensitive comparator.
|
static int |
NOT_FOUND
Index returned when word not found by binary search.
|
Modifier and Type | Method and Description |
---|---|
static int |
binarySearch(WordList wordList,
String word)
Performs a binary search of the given word list for the given word.
|
static ArrayWordList |
createFromReader(Reader[] readers)
Creates a case-sensitive
ArrayWordList by reading the contents of the given readers. |
static ArrayWordList |
createFromReader(Reader[] readers,
boolean caseSensitive)
Creates an
ArrayWordList by reading the contents of the given readers. |
static ArrayWordList |
createFromReader(Reader[] readers,
boolean caseSensitive,
ArraySorter sorter)
Creates an
ArrayWordList by reading the contents of the given file with support for sorting file contents. |
static void |
readWordList(Reader reader,
List<String> wordList)
Reads words, one per line, from a reader into the given word list.
|
public static final Comparator<String> CASE_SENSITIVE_COMPARATOR
public static final Comparator<String> CASE_INSENSITIVE_COMPARATOR
public static final int NOT_FOUND
public static int binarySearch(WordList wordList, String word)
wordList
- to searchword
- to search forpublic static ArrayWordList createFromReader(Reader[] readers) throws IOException
ArrayWordList
by reading the contents of the given readers.readers
- array of readersIOException
- if an error occurs reading from a readerpublic static ArrayWordList createFromReader(Reader[] readers, boolean caseSensitive) throws IOException
ArrayWordList
by reading the contents of the given readers.readers
- array of readerscaseSensitive
- set to true to create case-sensitive word list (default), false otherwiseIOException
- if an error occurs reading from a readerpublic static ArrayWordList createFromReader(Reader[] readers, boolean caseSensitive, ArraySorter sorter) throws IOException
ArrayWordList
by reading the contents of the given file with support for sorting file contents.readers
- array of readerscaseSensitive
- set to true to create case-sensitive word list (default), false otherwisesorter
- to sort the input array withIOException
- if an error occurs reading from a readerpublic static void readWordList(Reader reader, List<String> wordList) throws IOException
reader
- Reader containing words, one per line. The reader is closed on completion.wordList
- Destination word list.IOException
- on IO errors reading from reader.Copyright © 2003-2019 Virginia Tech. All Rights Reserved.