Class PatriciaTrie<E>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.apache.commons.collections4.trie.AbstractBitwiseTrie<K,V>
-
- org.apache.commons.collections4.trie.AbstractPatriciaTrie<java.lang.String,E>
-
- org.apache.commons.collections4.trie.PatriciaTrie<E>
-
- Type Parameters:
E
- the type of the values in this map
- All Implemented Interfaces:
java.io.Serializable
,java.util.Map<java.lang.String,E>
,java.util.SortedMap<java.lang.String,E>
,Get<java.lang.String,E>
,IterableGet<java.lang.String,E>
,IterableMap<java.lang.String,E>
,IterableSortedMap<java.lang.String,E>
,OrderedMap<java.lang.String,E>
,Put<java.lang.String,E>
,Trie<java.lang.String,E>
public class PatriciaTrie<E> extends AbstractPatriciaTrie<java.lang.String,E>
Implementation of a PATRICIA Trie (Practical Algorithm to Retrieve Information Coded in Alphanumeric).A PATRICIA
Trie
is a compressedTrie
. Instead of storing all data at the edges of theTrie
(and having empty internal nodes), PATRICIA stores data in every node. This allows for very efficient traversal, insert, delete, predecessor, successor, prefix, range, andAbstractPatriciaTrie.select(Object)
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 'prefixMap', 'submap', or 'iterator' methods. TheTrie
can also scan for items that are 'bitwise' (using an XOR metric) by the 'select' method. Bitwise closeness is determined by theKeyAnalyzer
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 asAbstractPatriciaTrie.prefixMap(Object)
are suited only to variable length keys.- Since:
- 4.0
- See Also:
- Radix Tree, PATRICIA, Crit-Bit Tree, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.collections4.trie.AbstractPatriciaTrie
AbstractPatriciaTrie.TrieEntry<K,V>, AbstractPatriciaTrie.TrieIterator<E>
-
Nested classes/interfaces inherited from class org.apache.commons.collections4.trie.AbstractBitwiseTrie
AbstractBitwiseTrie.BasicEntry<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Fields inherited from class org.apache.commons.collections4.trie.AbstractPatriciaTrie
modCount
-
-
Constructor Summary
Constructors Constructor Description PatriciaTrie()
PatriciaTrie(java.util.Map<? extends java.lang.String,? extends E> m)
-
Method Summary
-
Methods inherited from class org.apache.commons.collections4.trie.AbstractPatriciaTrie
addEntry, ceilingEntry, clear, comparator, containsKey, decrementSize, entrySet, firstEntry, firstKey, floorEntry, followLeft, followRight, get, getEntry, getNearestEntryForKey, headMap, higherEntry, incrementSize, isValidUplink, keySet, lastEntry, lastKey, lowerEntry, mapIterator, nextEntry, nextEntryImpl, nextEntryInSubtree, nextKey, prefixMap, previousEntry, previousKey, put, remove, removeEntry, select, selectKey, selectValue, size, subMap, subtree, tailMap, values
-
Methods inherited from class org.apache.commons.collections4.trie.AbstractBitwiseTrie
bitIndex, bitsPerElement, castKey, compare, compareKeys, getKeyAnalyzer, isBitSet, lengthInBits, toString
-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.collections4.Get
containsValue, isEmpty
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PatriciaTrie
public PatriciaTrie()
-
PatriciaTrie
public PatriciaTrie(java.util.Map<? extends java.lang.String,? extends E> m)
-
-