|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.eos.trie.CharSequenceKeyAnalyzer
public class CharSequenceKeyAnalyzer
Analyzes 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}
Note: Taken from Limewire sourcecode and repackaged by Sascha Kohlmann.
Field Summary |
---|
Fields inherited from interface net.sf.eos.trie.PatriciaTrie.KeyAnalyzer |
---|
EQUAL_BIT_KEY, NULL_BIT_KEY |
Constructor Summary | |
---|---|
CharSequenceKeyAnalyzer()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Constructor Detail |
---|
public CharSequenceKeyAnalyzer()
Method Detail |
---|
public static final int[] createIntBitMask(int bitCount)
public int length(CharSequence key)
PatriciaTrie.KeyAnalyzer
length
in interface PatriciaTrie.KeyAnalyzer<CharSequence>
public int bitIndex(CharSequence key, int keyOff, int keyLength, CharSequence found, int foundOff, int foundKeyLength)
PatriciaTrie.KeyAnalyzer
bitIndex
in interface PatriciaTrie.KeyAnalyzer<CharSequence>
public boolean isBitSet(CharSequence key, int keyLength, int bitIndex)
PatriciaTrie.KeyAnalyzer
isBitSet
in interface PatriciaTrie.KeyAnalyzer<CharSequence>
public int compare(CharSequence o1, CharSequence o2)
compare
in interface Comparator<CharSequence>
public int bitsPerElement()
PatriciaTrie.KeyAnalyzer
bitsPerElement
in interface PatriciaTrie.KeyAnalyzer<CharSequence>
public boolean isPrefix(CharSequence prefix, int offset, int length, CharSequence key)
PatriciaTrie.KeyAnalyzer
isPrefix
in interface PatriciaTrie.KeyAnalyzer<CharSequence>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |