public class CharSequenceKeyAnalyzer extends Object implements PatriciaTrie.KeyAnalyzer<CharSequence>
CharSequence keys with case sensitivity. With
CharSequenceKeyAnalyzer you can
compare, check prefix, and determine the index of a bit.
A typical use case for a CharSequenceKeyAnalyzer is with a
PatriciaTrie.
PatriciaTrie<String, String> trie = new PatriciaTrie<String, String>(new CharSequenceKeyAnalyzer());
trie.put("Lime", "Lime");
trie.put("LimeWire", "LimeWire");
trie.put("LimeRadio", "LimeRadio");
trie.put("Lax", "Lax");
trie.put("Lake", "Lake");
trie.put("Lovely", "Lovely");
System.out.println(trie.select("Lo"));
System.out.println(trie.select("Lime"));
System.out.println(trie.getPrefixedBy("La").toString());
Output:
Lovely
Lime
{Lake=Lake, Lax=Lax}
| Modifier and Type | Field and Description |
|---|---|
private static int[] |
BITS |
private static long |
serialVersionUID |
EQUAL_BIT_KEY, NULL_BIT_KEY| Constructor and Description |
|---|
CharSequenceKeyAnalyzer() |
| Modifier and Type | Method and Description |
|---|---|
int |
bitIndex(CharSequence key,
int keyOff,
int keyLength,
CharSequence found,
int foundOff,
int foundKeyLength)
Returns the n-th different bit between key and found.
|
int |
bitsPerElement()
Returns the number of bits per element in the key.
|
int |
compare(CharSequence o1,
CharSequence o2) |
static int[] |
createIntBitMask(int bitCount) |
boolean |
isBitSet(CharSequence key,
int keyLength,
int bitIndex)
Returns whether or not a bit is set
|
boolean |
isPrefix(CharSequence prefix,
int offset,
int length,
CharSequence key)
Determines whether or not the given prefix (from offset to length)
is a prefix of the given key.
|
int |
length(CharSequence key)
Returns the length of the Key in bits.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalsprivate static final long serialVersionUID
private static final int[] BITS
public CharSequenceKeyAnalyzer()
public static final int[] createIntBitMask(int bitCount)
public int length(CharSequence key)
PatriciaTrie.KeyAnalyzerlength in interface PatriciaTrie.KeyAnalyzer<CharSequence>public int bitIndex(CharSequence key, int keyOff, int keyLength, CharSequence found, int foundOff, int foundKeyLength)
PatriciaTrie.KeyAnalyzerbitIndex in interface PatriciaTrie.KeyAnalyzer<CharSequence>public boolean isBitSet(CharSequence key, int keyLength, int bitIndex)
PatriciaTrie.KeyAnalyzerisBitSet in interface PatriciaTrie.KeyAnalyzer<CharSequence>public int compare(CharSequence o1, CharSequence o2)
compare in interface Comparator<CharSequence>public int bitsPerElement()
PatriciaTrie.KeyAnalyzerbitsPerElement in interface PatriciaTrie.KeyAnalyzer<CharSequence>public boolean isPrefix(CharSequence prefix, int offset, int length, CharSequence key)
PatriciaTrie.KeyAnalyzerisPrefix in interface PatriciaTrie.KeyAnalyzer<CharSequence>