|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFreqData
class FreqData
A fast, simple, in-memory data structure for holding frequency data used to produce spelling suggestions.
Field Summary | |
---|---|
private IntList |
counts
One count per key |
private LongList |
keys
List of keys |
(package private) static long |
MAGIC_NUM
Magic number stored in file when data is written |
private static int |
MAX_UNSORTED
Upper limit on the number of unsorted entries |
private int |
sortTop
Tracks the section of the data that has been sorted. |
Constructor Summary | |
---|---|
FreqData()
|
Method Summary | |
---|---|
void |
add(File f)
Append sorted counts from an input stream that were saved by save(File) . |
void |
add(long hash,
int count)
Add a count for a given hash code and count |
void |
add(String word,
int count)
Add a count for a given word |
void |
add(String word1,
String word2,
int count)
Add a count for a given word pair |
int |
get(long hash)
Get the count for a given hash code, or zero if not found |
int |
get(String word)
Get the count for a given word, or zero if not found |
int |
get(String word1,
String word2)
Get the count for a given word pair, or zero if not found |
void |
save(File f)
Save sorted counts to an input stream. |
private int |
searchSorted(long hash)
Search within the sorted keys for the given one. |
private void |
sort()
If not already sorted, re-sort the data |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private LongList keys
private IntList counts
private int sortTop
private static final int MAX_UNSORTED
static final long MAGIC_NUM
Constructor Detail |
---|
FreqData()
Method Detail |
---|
public final void add(String word, int count)
public final void add(String word1, String word2, int count)
public void add(long hash, int count)
private int searchSorted(long hash)
public final int get(String word)
public final int get(String word1, String word2)
public final int get(long hash)
public void add(File f) throws IOException
save(File)
.
f
- File to load from
IOException
- if anything goes wrongpublic void save(File f) throws IOException
add(File)
.
f
- File to write to (existing contents are replaced)
IOException
- if anything goes wrongprivate void sort()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |