Deprecated
A Ternary Trie String lookup data structure.
This Trie is of a fixed size and cannot grow (which can be a good thing with regards to DOS when used as a cache).
The Trie is stored in 3 arrays:
The lookup of a value will iterate through the _tree array matching characters. If the equal tree branch is followed, then the _key array is looked up to see if this is a complete match. If a match is found then the _value array is looked up to return the matching value.
This Trie may be instantiated either as case sensitive or insensitive.
This Trie is not Threadsafe and contains no mutual exclusion or deliberate memory barriers. It is intended for an ArrayTrie to be built by a single thread and then used concurrently by multiple threads and not mutated during that access. If concurrent mutations of the Trie is required external locks need to be applied.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private final String[] | _key
The key (if any) for a Trie row. |
| private char | _rows
The number of rows allocated |
| private final char[] | _tree
The Trie rows in a single array which allows a lookup of row,character to the next row in the Trie. |
| private final V[] | _value
The value (if any) for a Trie row. |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | MAX_CAPACITY
The maximum capacity of the implementation. |
| private static final int | ROW_SIZE
The Size of a Trie row is the char, and the low, equal and high child pointers |
| Access | Constructor and Description |
|---|---|
| pack-priv | ArrayTernaryTrie(boolean
true if the Trie is insensitive to the case of the key. caseSensitive, int The capacity of the Trie, which is in the worst case
is the total number of characters of all keys stored in the Trie. capacity)Create a Trie |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public Set | |
| public V | get(String
The key s, int The offset within the string of the key offset, int the length of the key len)Implements org. |
| public V | get(ByteBuffer
The buffer b, int The offset within the buffer of the key offset, int the length of the key len)Implements org. |
| public V | getBest(String
The string s)Overrides org. Implements org. |
| public V | getBest(String
The string s, int The offset within the string of the key offset, int the length of the key length)Implements org. |
| private V | |
| public V | getBest(ByteBuffer
The buffer b, int The offset within the buffer of the key offset, int the length of the key len)Implements org. |
| public V | getBest(byte[]
The buffer b, int The offset within the array of the key offset, int the length of the key len)Overrides org. Implements org. |
| private V | |
| private V | |
| public static int | |
| public boolean | |
| public Set | keySet()
Implements org. Set of the keys contained in this index.
|
| public boolean | put(String
The key for the entry. Must be non null, but can be empty. s, V The value of the entry. Must be non null. v)Implements org. |
| public int | |
| public String |
| _key | back to summary |
|---|---|
| private final String[] _key The key (if any) for a Trie row. A row may be a leaf, a node or both in the Trie tree. | |
| _rows | back to summary |
|---|---|
| private char _rows The number of rows allocated | |
| _tree | back to summary |
|---|---|
| private final char[] _tree The Trie rows in a single array which allows a lookup of row,character to the next row in the Trie. This is actually a 2 dimensional array that has been flattened to achieve locality of reference. | |
| _value | back to summary |
|---|---|
| private final V[] _value The value (if any) for a Trie row. A row may be a leaf, a node or both in the Trie tree. | |
| EQ | back to summary |
|---|---|
| private static final int EQ | |
| HI | back to summary |
|---|---|
| private static final int HI | |
| LO | back to summary |
|---|---|
| private static final int LO | |
| MAX_CAPACITY | back to summary |
|---|---|
| private static final int MAX_CAPACITY The maximum capacity of the implementation. Over that, the 16 bit indexes can overflow and the trie cannot find existing entries anymore. | |
| ROW_SIZE | back to summary |
|---|---|
| private static final int ROW_SIZE The Size of a Trie row is the char, and the low, equal and high child pointers | |
| ArrayTernaryTrie | back to summary |
|---|---|
| pack-priv ArrayTernaryTrie(boolean caseSensitive, int capacity) Create a Trie
| |
| clear | back to summary |
|---|---|
| public void clear() Implements org. Doc from org. Remove all entries from the index.
| |
| dump | back to summary |
|---|---|
| public void dump() | |
| entrySet | back to summary |
|---|---|
| public Set | |
| get | back to summary |
|---|---|
| public V get(String s, int offset, int len) Implements org. Doc from org. Get an exact match from a String key | |
| get | back to summary |
|---|---|
| public V get(ByteBuffer b, int offset, int len) Implements org. Doc from org. Get an exact match from a segment of a ByteBuffer as key
| |
| getBest | back to summary |
|---|---|
| public V getBest(String s) Overrides org. Implements org. Doc from org. Get the best match from key in a String, which may be a prefix match or an exact match. | |
| getBest | back to summary |
|---|---|
| public V getBest(String s, int offset, int length) Implements org. Doc from org. Get the best match from key in a String. | |
| getBest | back to summary |
|---|---|
| private V getBest(int t, String s, int offset, int len) | |
| getBest | back to summary |
|---|---|
| public V getBest(ByteBuffer b, int offset, int len) Implements org. Doc from org. Get the best match from key in a byte buffer. The key is assumed to by ISO_8859_1 characters.
| |
| getBest | back to summary |
|---|---|
| public V getBest(byte[] b, int offset, int len) Overrides org. Implements org. Doc from org. Get the best match from key in a byte array. The key is assumed to by ISO_8859_1 characters.
| |
| getBest | back to summary |
|---|---|
| private V getBest(int t, byte[] b, int offset, int len) | |
| getBest | back to summary |
|---|---|
| private V getBest(int t, ByteBuffer b, int offset, int len) | |
| hilo | back to summary |
|---|---|
| public static int hilo(int diff) | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements org. Doc from org. Check if the index contains any entry.
| |
| keySet | back to summary |
|---|---|
| public Set Implements org. Doc from org. Get a | |
| put | back to summary |
|---|---|
| public boolean put(String s, V v) Implements org. Doc from org. Put an entry into the index. | |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from org. Get the number of entries in the index.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
Deprecated
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private ArrayTernaryTrie | _trie
Deprecated
as a consequence of
ArrayTernaryTrie being deprecated.
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public V | get(String
The key s)Overrides org. Implements org. |
| public V | get(ByteBuffer
The buffer b)Overrides org. Implements org. |
| public V | get(String
The key s, int The offset within the string of the key offset, int the length of the key len)Implements org. |
| public V | get(ByteBuffer
The buffer b, int The offset within the buffer of the key offset, int the length of the key len)Implements org. |
| public V | getBest(byte[]
The buffer b, int The offset within the array of the key offset, int the length of the key len)Overrides org. Implements org. |
| public V | getBest(String
The string s)Overrides org. Implements org. |
| public V | getBest(String
The string s, int The offset within the string of the key offset, int the length of the key length)Implements org. |
| public V | getBest(ByteBuffer
The buffer b, int The offset within the buffer of the key offset, int the length of the key len)Implements org. |
| public int | |
| public boolean | |
| public Set | keySet()
Implements org. Set of the keys contained in this index.
|
| public boolean | put(V
The value and key v)Overrides org. Implements org. |
| public boolean | put(String
The key for the entry. Must be non null, but can be empty. s, V The value of the entry. Must be non null. v)Implements org. |
| public V | remove(String
The key for the entry s)Overrides org. Implements org. |
| public int | |
| public String |
| _growby | back to summary |
|---|---|
| private final int _growby | |
| _trie | back to summary |
|---|---|
| private ArrayTernaryTrie<V> _trie
Deprecated as a consequence of | |
| Growing | back to summary |
|---|---|
| public Growing(boolean insensitive, int capacity, int growby) | |
| clear | back to summary |
|---|---|
| public void clear() Implements org. Doc from org. Remove all entries from the index.
| |
| dump | back to summary |
|---|---|
| public void dump() | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| get | back to summary |
|---|---|
| public V get(String s) Overrides org. Implements org. Doc from org. Get an exact match from a String key | |
| get | back to summary |
|---|---|
| public V get(ByteBuffer b) Overrides org. Implements org. Doc from org. Get an exact match from a segment of a ByteBuffer as key
| |
| get | back to summary |
|---|---|
| public V get(String s, int offset, int len) Implements org. Doc from org. Get an exact match from a String key | |
| get | back to summary |
|---|---|
| public V get(ByteBuffer b, int offset, int len) Implements org. Doc from org. Get an exact match from a segment of a ByteBuffer as key
| |
| getBest | back to summary |
|---|---|
| public V getBest(byte[] b, int offset, int len) Overrides org. Implements org. Doc from org. Get the best match from key in a byte array. The key is assumed to by ISO_8859_1 characters.
| |
| getBest | back to summary |
|---|---|
| public V getBest(String s) Overrides org. Implements org. Doc from org. Get the best match from key in a String, which may be a prefix match or an exact match. | |
| getBest | back to summary |
|---|---|
| public V getBest(String s, int offset, int length) Implements org. Doc from org. Get the best match from key in a String. | |
| getBest | back to summary |
|---|---|
| public V getBest(ByteBuffer b, int offset, int len) Implements org. Doc from org. Get the best match from key in a byte buffer. The key is assumed to by ISO_8859_1 characters.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements org. Doc from org. Check if the index contains any entry.
| |
| keySet | back to summary |
|---|---|
| public Set Implements org. Doc from org. Get a | |
| put | back to summary |
|---|---|
| public boolean put(V v) Overrides org. Implements org. Doc from org. Put a value as both a key and a value.
| |
| put | back to summary |
|---|---|
| public boolean put(String s, V v) Implements org. Doc from org. Put an entry into the index. | |
| remove | back to summary |
|---|---|
| public V remove(String s) Overrides org. Implements org. Doc from org. Remove an entry from the index. | |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from org. Get the number of entries in the index.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |