public class ZFastTrie<T> extends AbstractObjectSortedSet<T> implements Serializable
In rough terms, the z-fast trie uses time |x|/w (which is optimal) to actually look at the string content,
and log(max{|x|, |x-|, |x+|}) to perform the search. This is known to be (essentially) optimal.
String lengths are up to Integer.MAX_VALUE, and not limited to be a constant multiple of w for the bounds to hold.
The linear overhead of a z-fast trie is very low. For n keys we allocate 2n − 1 nodes containing six references and two longs, plus a dictionary containing n − 1 nodes (thus using around 2n references and 2n longs).
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ZFastTrie.ExitData<U> |
protected static class |
ZFastTrie.Handle2NodeMap<U>
A linear-probing hash map that compares keys using signatures as a first try.
|
protected static class |
ZFastTrie.InternalNode<U>
A internal node.
|
protected static class |
ZFastTrie.Leaf<U>
An external node, a.k.a.
|
protected static class |
ZFastTrie.Node<U>
A node of the trie.
|
protected static class |
ZFastTrie.ParexData<U> |
| Modifier and Type | Field and Description |
|---|---|
ZFastTrie.Handle2NodeMap<T> |
handle2Node
A dictionary mapping handles to the corresponding internal nodes.
|
static long |
serialVersionUID |
| Constructor and Description |
|---|
ZFastTrie(Iterable<? extends T> elements,
TransformationStrategy<? super T> transform)
Creates a new z-fast trie using the given elements and transformation strategy.
|
ZFastTrie(Iterator<? extends T> elements,
TransformationStrategy<? super T> transform)
Creates a new z-fast trie using the given elements and transformation strategy.
|
ZFastTrie(TransformationStrategy<? super T> transform)
Creates a new z-fast trie using the given transformation strategy.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T k) |
Comparator<? super T> |
comparator() |
boolean |
contains(Object o) |
T |
first() |
ZFastTrie.InternalNode<T> |
getGrandParentExitNode(LongArrayBitVector v,
long[] state,
ObjectArrayList<ZFastTrie.InternalNode<T>> stack)
Returns the grandparent of the exit node of a given bit vector.
|
ZFastTrie.ParexData<T> |
getParentExitNode(LongArrayBitVector v,
long[] state,
ObjectArrayList<ZFastTrie.InternalNode<T>> stack)
Returns the parent of the exit node of a given bit vector.
|
ObjectSortedSet<T> |
headSet(T arg0) |
ObjectBidirectionalIterator<T> |
iterator() |
ObjectBidirectionalIterator<T> |
iterator(T from) |
T |
last() |
static void |
main(String[] arg) |
T |
pred(Object o) |
boolean |
remove(Object k) |
int |
size() |
ObjectSortedSet<T> |
subSet(T arg0,
T arg1) |
T |
succ(Object o) |
ObjectSortedSet<T> |
tailSet(T arg0) |
static long |
twoFattest(long a,
long b)
Returns the 2-fattest number in an interval.
|
objectIteratorequals, hashCodeaddAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringclearclone, finalize, getClass, notify, notifyAll, wait, wait, waittoArraypublic static final long serialVersionUID
public transient ZFastTrie.Handle2NodeMap<T> handle2Node
public ZFastTrie(TransformationStrategy<? super T> transform)
transform - a transformation strategy that must turn distinct elements into distinct, prefix-free bit vectors.public ZFastTrie(Iterator<? extends T> elements, TransformationStrategy<? super T> transform)
elements - an iterator returning the elements to be inserted in the trie.transform - a transformation strategy that must turn distinct elements into distinct, prefix-free bit vectors.public ZFastTrie(Iterable<? extends T> elements, TransformationStrategy<? super T> transform)
elements - an iterator returning the elements to be inserted in the trie.transform - a transformation strategy that must turn distinct elements into distinct, prefix-free bit vectors.public int size()
size in interface Collection<T>size in interface Set<T>size in class AbstractCollection<T>public static final long twoFattest(long a,
long b)
Note that to get the length of the handle of a node you must call this function passing the length of the extent of the parent (one less than the node name) and the length of the extent of the node.
a - left extreme (excluded).b - right extreme (included).a..b].public boolean add(T k)
add in interface Collection<T>add in interface Set<T>add in class AbstractObjectCollection<T>public boolean remove(Object k)
public ZFastTrie.ParexData<T> getParentExitNode(LongArrayBitVector v, long[] state, ObjectArrayList<ZFastTrie.InternalNode<T>> stack)
v - a bit vector.state - the hash state of v precomputed by Hashes.preprocessMurmur(BitVector, long).stack - if not null, a stack that will be filled with the fat nodes along the path to the parent of the exit node.v, or null if the exit node is the root.public ZFastTrie.InternalNode<T> getGrandParentExitNode(LongArrayBitVector v, long[] state, ObjectArrayList<ZFastTrie.InternalNode<T>> stack)
v - a bit vector.stack - as filled by getParentExitNode(LongArrayBitVector, long[], ObjectArrayList).public boolean contains(Object o)
contains in interface Collection<T>contains in interface Set<T>contains in class AbstractCollection<T>public ObjectBidirectionalIterator<T> iterator()
iterator in interface ObjectCollection<T>iterator in interface ObjectIterable<T>iterator in interface ObjectSet<T>iterator in interface ObjectSortedSet<T>iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface Set<T>iterator in class AbstractObjectSortedSet<T>public ObjectBidirectionalIterator<T> iterator(T from)
iterator in interface ObjectSortedSet<T>public Comparator<? super T> comparator()
comparator in interface SortedSet<T>public ObjectSortedSet<T> headSet(T arg0)
public ObjectSortedSet<T> subSet(T arg0, T arg1)
public ObjectSortedSet<T> tailSet(T arg0)
public static void main(String[] arg) throws NoSuchMethodException, IOException, JSAPException