Performance of the set is comparable to that of java.
for Strings, ie. 2-3x slower than java. when
using pre-constructed Strings. This is generally result of algorithmic
complexity of structures; Word and Tree sets are roughly logarithmic
to the whole data, whereas Hash set is linear to the length of key.
However:
Although this is an efficient set for specific set of usage patterns, one restriction is that the full set of words to include has to be known before constructing the set. Also, the size of the set is limited to total word content of about 20k characters; factory method does verify the limit and indicates if an instance can not be created.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final char | |
| pack-priv final char[] | mData
Compressed presentation of the word set. |
| pack-priv static final int | MIN_BINARY_SEARCH
This is actually just a guess; but in general linear search should be faster for short sequences (definitely for 4 or less; maybe up to 8 or less?) |
| pack-priv static final int | NEGATIVE_OFFSET
Offset added to numbers to mark 'negative' numbers. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static char[] | |
| public static WordSet | |
| public boolean | |
| public static boolean | |
| public boolean | |
| public static boolean |
| CHAR_NULL | back to summary |
|---|---|
| pack-priv static final char CHAR_NULL | |
| mData | back to summary |
|---|---|
| pack-priv final char[] mData Compressed presentation of the word set. | |
| MIN_BINARY_SEARCH | back to summary |
|---|---|
| pack-priv static final int MIN_BINARY_SEARCH This is actually just a guess; but in general linear search should be faster for short sequences (definitely for 4 or less; maybe up to 8 or less?) | |
| NEGATIVE_OFFSET | back to summary |
|---|---|
| pack-priv static final int NEGATIVE_OFFSET Offset added to numbers to mark 'negative' numbers. Asymmetric, since range of negative markers needed is smaller than positive numbers... | |
| WordSet | back to summary |
|---|---|
| private WordSet(char[] data) | |
| constructRaw | back to summary |
|---|---|
| public static char[] constructRaw(TreeSet<String> wordSet) | |
| constructSet | back to summary |
|---|---|
| public static WordSet constructSet(TreeSet<String> wordSet) | |
| contains | back to summary |
|---|---|
| public boolean contains(char[] buf, int start, int end) | |
| contains | back to summary |
|---|---|
public static boolean contains(char[] data, char[] str, int start, int end)
| |
| contains | back to summary |
|---|---|
| public boolean contains(String str) | |
| contains | back to summary |
|---|---|
public static boolean contains(char[] data, String str)
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv char[] | |
| pack-priv int | mSize
Number of characters currently used from mData |
| pack-priv final String[] |
| Modifier and Type | Method and Description |
|---|---|
| public char[] | |
| private void | constructBranch(int
Index of the character in words to consider
for this round charIndex, int Index of the first word to be processed start, int Index of the word after last word to be processed
(so that number of words is end)end - start - 1Method that is called recursively to build the data representation for a branch, ie. |
| private void | constructLeaf(int charIndex, int wordIndex)
Method called to add leaf entry to word set; basically "here is the rest of the only matching word" |
| private char[] |
| mData | back to summary |
|---|---|
| pack-priv char[] mData | |
| mSize | back to summary |
|---|---|
| pack-priv int mSize Number of characters currently used from mData | |
| mWords | back to summary |
|---|---|
| pack-priv final String[] mWords | |
| Builder | back to summary |
|---|---|
| public Builder(TreeSet<String> wordSet) | |
| construct | back to summary |
|---|---|
public char[] construct()
| |
| constructBranch | back to summary |
|---|---|
| private void constructBranch(int charIndex, int start, int end) Method that is called recursively to build the data representation for a branch, ie. part of word set tree that still has more than one ending
| |
| constructLeaf | back to summary |
|---|---|
| private void constructLeaf(int charIndex, int wordIndex) Method called to add leaf entry to word set; basically "here is the rest of the only matching word" | |
| expand | back to summary |
|---|---|
| private char[] expand(int needSpace) | |