edu.vt.middleware.dictionary
Class ArrayWordList

java.lang.Object
  extended by edu.vt.middleware.dictionary.AbstractWordList
      extended by edu.vt.middleware.dictionary.ArrayWordList
All Implemented Interfaces:
WordList

public class ArrayWordList
extends AbstractWordList

Provides a WordList backed by a string array. Since the entire word list is stored in memory java heap settings may need to be modified in order to store large word lists.

Version:
$Revision: 1252 $ $Date: 2010-04-16 17:24:23 -0400 (Fri, 16 Apr 2010) $
Author:
Middleware Services

Field Summary
protected  java.lang.String[] words
          file containing words.
 
Fields inherited from class edu.vt.middleware.dictionary.AbstractWordList
comparator
 
Constructor Summary
ArrayWordList(java.lang.String[] array)
          Creates a new case-sensitive word list backed by the given array.
ArrayWordList(java.lang.String[] array, boolean caseSensitive)
          Creates a new word list backed by the given array.
ArrayWordList(java.lang.String[] array, boolean caseSensitive, ArraySorter sorter)
          Creates a new word list backed by the given array with optional sorting of the input string array.
 
Method Summary
 java.lang.String get(int index)
          Gets the word at the given 0-based index.
 int size()
          Gets the number of words in the list.
 
Methods inherited from class edu.vt.middleware.dictionary.AbstractWordList
checkIsString, checkRange, getComparator, iterator, medianIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

words

protected java.lang.String[] words
file containing words.

Constructor Detail

ArrayWordList

public ArrayWordList(java.lang.String[] array)
Creates a new case-sensitive word list backed by the given array.

Parameters:
array - Array of words.
Throws:
java.lang.IllegalArgumentException - If array is null or contains any null entries.

ArrayWordList

public ArrayWordList(java.lang.String[] array,
                     boolean caseSensitive)
Creates a new word list backed by the given array.

Parameters:
array - Array of words.
caseSensitive - Set to true to create case-sensitive word list, false otherwise.
Throws:
java.lang.IllegalArgumentException - If array is null or contains any null entries.

ArrayWordList

public ArrayWordList(java.lang.String[] array,
                     boolean caseSensitive,
                     ArraySorter sorter)
Creates a new word list backed by the given array with optional sorting of the input string array.

Parameters:
array - Array of words.
caseSensitive - Set to true to create case-sensitive word list, false otherwise.
sorter - To sort the input array with. The sort routine is consistent with AbstractWordList.getComparator(), which respects the case sensitivity of the word list.
Throws:
java.lang.IllegalArgumentException - If array is null or contains any null entries.
Method Detail

get

public java.lang.String get(int index)
Gets the word at the given 0-based index.

Parameters:
index - 0-based index.
Returns:
Word at given index.

size

public int size()
Gets the number of words in the list.

Returns:
Total number of words in list.


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.