java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.collect.CFBytesTrie<T> |
A trie map specialized to handle context-free (CF) binary strings. Context-free here means that the binary strings stored as keys cannot be such that, given a binary string A, there exists a longer binary string B whose prefix is A.
Characteristics/limitations:
- Support for insertion and retrieval only (no removal).
- The null key and the empty key are illegal.
- Null values are illegal.
This class is not thread-safe. This class does not override equals/hashCode/toString.
Implementation notes: the is serializable (at the condition that the stored objects T are also
serializable). In order to serialize this class efficiently, both in terms of space and time, a
key extractor
should be set.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | CFBytesTrie.IKeyExtractor<T> | The key extractor provides the bytes (to be used in the trie) for an element to be stored in the trie. | |||||||||
class | CFBytesTrie.Node | A node in the trie. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CFBytesTrie() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | clear() | ||||||||||
String | formatInternalState() | ||||||||||
T |
get(byte[] key, boolean exactKey)
Retrieve a value in the trie.
| ||||||||||
T |
get(byte[] keyarray, int start, int max, boolean exactKey)
Retrieve a value in the trie.
| ||||||||||
List<Couple<byte[], T>> |
getItems()
Generate the list of items (key, value) stored in this trie.
| ||||||||||
IKeyExtractor<T> | getKeyExtractor() | ||||||||||
List<T> |
getValues()
Generate a list of all values stored in this trie.
| ||||||||||
boolean | isEmpty() | ||||||||||
T |
put(byte[] keyarray, int start, int end, T object)
Add a new entry to the trie.
| ||||||||||
void |
put(T object)
Add a new entry to the trie.
| ||||||||||
void |
put(byte[] key, T object)
Add a new entry to the trie.
| ||||||||||
boolean |
putSafe(byte[] keyarray, int start, int end, T object, T[] aprev)
Add a new entry to the trie.
| ||||||||||
void | setKeyExtractor(IKeyExtractor<T> keyExtractor) | ||||||||||
int | size() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Retrieve a value in the trie.
key | key |
---|
Retrieve a value in the trie.
keyarray | key array |
---|---|
start | key start index |
max | key end index (exclusive) |
exactKey | if false, more potential key bytes may be provided, and the object whose key matches the beginning of the sequence of bytes will be returned |
Generate the list of items (key, value) stored in this trie. This method is potentially expensive.
Generate a list of all values stored in this trie. This method is potentially expensive.
Add a new entry to the trie. This method throws an IllegalStateException on prefix collision.
keyarray | key array |
---|---|
start | key start position in the array |
end | key end position (exclusive) |
object | value |
Add a new entry to the trie. This method throws an IllegalStateException on prefix collision.
object | value (the value's key is derived using the key extractor) |
---|
Add a new entry to the trie. This method throws an IllegalStateException on prefix collision.
key | key |
---|---|
object | value |
Add a new entry to the trie. This method does not throw if a prefix collision is detected; instead, false is returned.
keyarray | key array |
---|---|
start | key start position in the array |
end | key end position (exclusive) |
object | value |
aprev | if non-null, a one-element array that will receive the previous entry at key, or null if none |