| Modifier and Type | Field and Description |
|---|---|
protected int |
length
The number of slots in the table (always a power of two).
|
protected int |
mask
length − 1. |
protected ZFastTrie.InternalNode<U>[] |
node
The node table.
|
protected long[] |
signature
The signature of the handle of the corresponding entry
node. |
protected int |
size
The number of elements in the table.
|
protected TransformationStrategy<? super U> |
transform
The transformation strategy.
|
| Constructor and Description |
|---|
ZFastTrie.Handle2NodeMap(int size,
TransformationStrategy<? super U> transform)
Creates a new handle-to-node map using a given transformation strategy and expected number of elements.
|
ZFastTrie.Handle2NodeMap(TransformationStrategy<? super U> transform)
Creates a new handle-to-node map using a given transformation strategy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNew(ZFastTrie.InternalNode<U> v)
Adds a new entry to the table.
|
void |
addNew(ZFastTrie.InternalNode<U> n,
long s)
Adds a new entry to the table.
|
protected void |
assertTable() |
void |
clear() |
protected int |
findExactPos(BitVector v,
long handleLength,
long s)
Find the position in the table of a given handle using handles.
|
protected int |
findPos(BitVector v,
long handleLength,
long s)
Find the position in the table of a given handle using signatures.
|
ZFastTrie.InternalNode<U> |
get(BitVector handle,
boolean exact)
Retrieves a node given its handle.
|
ZFastTrie.InternalNode<U> |
get(BitVector v,
long handleLength,
long s,
boolean exact)
Retrieves a node given its handle.
|
int |
getPos(BitVector v,
long handleLength,
long s,
boolean exact) |
protected int |
hash(long s)
Generates a hash table position starting from a signature.
|
ObjectSet<LongArrayBitVector> |
keySet() |
void |
removeExisting(ZFastTrie.InternalNode<U> n,
long s)
Removes an existing entry from the table.
|
void |
replaceExisting(ZFastTrie.InternalNode<U> oldNode,
ZFastTrie.InternalNode<U> newNode,
long s)
Replaces an entry with a given node.
|
int |
size() |
String |
toString() |
ObjectSet<ZFastTrie.Node<U>> |
values() |
protected final TransformationStrategy<? super U> transform
protected ZFastTrie.InternalNode<U>[] node
protected long[] signature
node.protected int size
protected int length
protected int mask
length − 1.public ZFastTrie.Handle2NodeMap(int size,
TransformationStrategy<? super U> transform)
size - the expected number of elements.transform - the transformation strategy used for this map.public ZFastTrie.Handle2NodeMap(TransformationStrategy<? super U> transform)
transform - the transformation strategy used for this map.protected void assertTable()
protected int hash(long s)
s - a signature.protected int findPos(BitVector v, long handleLength, long s)
Note that this function just compares signatures (except for duplicates, which are checked explicitly). Thus, it might return false positives when queried with keys that are not handles. Nonetheless, it will always return a correct result on a handle.
v - a bit vector.handleLength - the length of the prefix of v that will be used as a handle.s - the signature of the prefix of v of handleLength bits.null.protected int findExactPos(BitVector v, long handleLength, long s)
Note that this function compares handles. Thus, it always returns a correct value.
v - a bit vector.handleLength - the length of the prefix of v that will be used as a handle.s - the signature of the prefix of v of handleLength bits.null.public void clear()
public ObjectSet<LongArrayBitVector> keySet()
public ObjectSet<ZFastTrie.Node<U>> values()
public void replaceExisting(ZFastTrie.InternalNode<U> oldNode, ZFastTrie.InternalNode<U> newNode, long s)
oldNode - a node appearing in the table.newNode - a node with the same handle as oldNode.s - the signature of the handle of oldNode and newNode.public void removeExisting(ZFastTrie.InternalNode<U> n, long s)
n - the node to be removed.s - the signature of the handle of n.IllegalStateException - if n is not in the table.public void addNew(ZFastTrie.InternalNode<U> v)
v - a node.addNew(ZFastTrie.InternalNode, long)public void addNew(ZFastTrie.InternalNode<U> n, long s)
Note that as long as the handle of the given node is not in the table this function will always perform correctly. Otherwise, the table will end up containing two copies of the same key (i.e., handle).
n - a node.s - the signature of the handle of n.public int size()
public ZFastTrie.InternalNode<U> get(BitVector v, long handleLength, long s, boolean exact)
v - a bit vector.handleLength - the prefix of v that must be used as a handle.s - the signature of the specified handle.exact - whether the search should be exact; if false, and the given handle does not
appear in the table, it is possible that an unpredictable internal node is returned.null if there is no such node (if
exact is false, a false positive might be returned).public int getPos(BitVector v, long handleLength, long s, boolean exact)
public ZFastTrie.InternalNode<U> get(BitVector handle, boolean exact)
handle - a handle.exact - whether the search should be exact; if false, and the given handle does not
appear in the table, it is possible that an unpredictable internal node is returned.null if there is no such node (if
exact is false, a false positive might be returned).get(BitVector, long, long, boolean)