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
+ * {@link 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}
+
+ *
+ *
+ * @author Sam Berlin
+ * @author Roger Kapsi
+ */
+public class CharSequenceKeyAnalyzer implements PatriciaTrie.KeyAnalyzer+ * PATRICIA = Practical Algorithm to Retrieve Information Coded in Alphanumeric + *
+ * A PATRICIA Trie is a compressed Trie. Instead of storing all data at the + * edges of the Trie (and having empty internal nodes), PATRICIA stores data + * in every node. This allows for very efficient traversal, insert, delete, + * predecessor, successor, prefix, range, and 'select' operations. All operations + * are performed at worst in O(K) time, where K is the number of bits in the + * largest item in the tree. In practice, operations actually take O(A(K)) + * time, where A(K) is the average number of bits of all items in the tree. + *
+ * Most importantly, PATRICIA requires very few comparisons to keys while + * doing any operation. While performing a lookup, each comparison + * (at most K of them, described above) will perform a single bit comparison + * against the given key, instead of comparing the entire key to another key. + *
+ * The Trie can return operations in lexicographical order using the 'traverse', + * 'prefix', 'submap', or 'iterator' methods. The Trie can also scan for items + * that are 'bitwise' (using an XOR metric) by the 'select' method. Bitwise + * closeness is determined by the {@link KeyAnalyzer} returning true or + * false for a bit being set or not in a given key. + *
+ * This PATRICIA Trie supports both variable length & fixed length keys.
+ * Some methods, such as getPrefixedBy(...) are suited only to
+ * variable length keys, whereas getPrefixedByBits(...) is suited
+ * to fixed-size keys.
+ *
+ * Additionally see PATRICIA + * for more information. + *
+ * Any methods here that take an Object may throw a
+ * ClassCastException if the method is expecting an instance of K
+ * (and it isn't K).
+ *
+ *
+ 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}
+
+ *
+ * @author Roger Kapsi
+ * @author Sam Berlin
+
+ */
+public class PatriciaTrie