public abstract static class AssociativeAddressTrie.AssociativeTrieNode<K extends Address,V> extends AddressTrie.TrieNode<K> implements Map.Entry<K,V>, AddressTrieOps.AssociativeAddressTrieOps<K,V>
BinaryTreeNode.CachingIterator<N extends BinaryTreeNode<E>,E,C>AddressTrieOps.AddressTrieAddOps<E extends Address>, AddressTrieOps.AssociativeAddressTrieOps<K extends Address,V>, AddressTrieOps.AssociativeAddressTriePutOps<K extends Address,V>| Modifier and Type | Method and Description |
|---|---|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
allNodeIterator(boolean forward)
Iterates through all the nodes of the sub-tree with this node as the root, in forward or reverse tree order.
|
Spliterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
allNodeSpliterator(boolean forward)
Creates a
Spliterator over the nodes in forward or reverse natural tree order. |
AssociativeAddressTrie<K,V> |
asNewTrie()
Creates a new sub-trie, copying the nodes starting with this node as root.
|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
blockSizeAllNodeIterator(boolean lowerSubNodeFirst)
Iterates all the nodes, ordered by keys from largest prefix blocks to smallest and then to individual addresses,
in the sub-trie with this node as the root.
|
<C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> |
blockSizeCachingAllNodeIterator()
Iterates all nodes, ordered by keys from largest prefix blocks to smallest and then to individual addresses,
in the sub-trie with this node as the root.
|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
blockSizeNodeIterator(boolean lowerSubNodeFirst)
Iterates the added nodes, ordered by keys from largest prefix blocks to smallest and then to individual addresses,
in the sub-trie with this node as the root.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
ceilingAddedNode(K addr)
Returns the added node whose address is the lowest address greater than or equal to the given address.
|
void |
clearValue() |
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
clone()
Clones the node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
cloneTree()
Clones the subtrie starting with this node as root.
|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
containedFirstAllNodeIterator(boolean forwardSubNodeOrder)
Returns an iterator that does a post-order binary tree traversal.
|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
containedFirstIterator(boolean forwardSubNodeOrder)
Returns an iterator that does a post-order binary tree traversal of the added nodes.
|
<C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> |
containingFirstAllNodeIterator(boolean forwardSubNodeOrder)
Returns an iterator that does a pre-order binary tree traversal.
|
<C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> |
containingFirstIterator(boolean forwardSubNodeOrder)
Returns an iterator that does a pre-order binary tree traversal of the added nodes.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
elementsContainedBy(K addr)
Checks if a part of this trie is contained by the given prefix block subnet or individual address.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
elementsContaining(K addr)
Finds the added subnets and/or addresses in the trie that contain the given individual address or prefix block subnet.
|
boolean |
equals(Object o)
Returns whether the key and mapped value match those of the given node
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
firstAddedNode()
Returns the first (lowest valued) added node in the sub-tree originating from this node,
or null if there are no added entries in this tree or sub-tree
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
firstNode()
Returns the first (lowest valued) node in the sub-tree originating from this node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
floorAddedNode(K addr)
Returns the added node whose address is the highest address less than or equal to the given address.
|
V |
get(K addr)
Gets the specified value for the specified key in this mapped trie or subtrie.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
getAddedNode(K addr)
Gets trie nodes representing added elements.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
getLowerSubNode()
Returns the sub node whose address is smallest in value
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
getNode(K addr)
Gets the node corresponding to the given address, returns null if not such element exists.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
getParent()
Returns the node for the subnet block containing this node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
getUpperSubNode()
Returns the sub-node whose address is largest in value
|
V |
getValue() |
int |
hashCode()
The hash code is the same as that specified by
Map.Entry.hashCode() |
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
higherAddedNode(K addr)
Returns the added node whose address is the lowest address strictly greater than the given address.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
lastAddedNode()
Returns the last (highest valued) added node in the sub-tree originating from this node,
or null if there are no added entries in this tree or sub-tree
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
lastNode()
Returns the last (highest valued) node in the sub-tree originating from this node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
longestPrefixMatchNode(K addr)
Finds the containing subnet or address in the trie with the smallest subnet size,
which is equivalent to finding the subnet or address with the longest matching prefix.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
lowerAddedNode(K addr)
Returns the added node whose address is the highest address strictly less than the given address.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
nextAddedNode()
Returns the next node in the tree that is an added node, following the tree order,
or null if there is no such node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
nextNode()
Returns the node that follows this node following the tree order
|
Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
nodeIterator(boolean forward)
Iterates through the added nodes of the sub-tree with this node as the root, in forward or reverse tree order.
|
Spliterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> |
nodeSpliterator(boolean forward)
Creates a
Spliterator over the added nodes in forward or reverse natural tree order. |
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
previousAddedNode()
Returns the previous node in the tree that is an added node, following the tree order in reverse,
or null if there is no such node.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
previousNode()
Returns the node that precedes this node following the tree order.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
removeElementsContainedBy(K addr)
Removes any single address or prefix block subnet from the trie that is contained in the given individual address or prefix block subnet.
|
V |
setValue(V value) |
String |
toString()
Returns a visual representation of this node including the key, with an open circle indicating this node is not an added node,
a closed circle indicating this node is an added node.
|
contains, descendingSpliterator, elementContains, longestPrefixMatch, remove, spliteratorclear, descendingIterator, getKey, isAdded, isEmpty, isLeaf, isRoot, iterator, nodeSize, remove, setAdded, size, toTreeString, treeEquals, treeHashCodecomparingByKey, comparingByKey, comparingByValue, comparingByValue, getKeycontains, elementContains, longestPrefixMatch, removedescendingIterator, descendingSpliterator, iterator, spliteratorpublic void clearValue()
public AssociativeAddressTrie.AssociativeTrieNode<K,V> getUpperSubNode()
AddressTrie.TrieNodegetUpperSubNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> getLowerSubNode()
AddressTrie.TrieNodegetLowerSubNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> getParent()
AddressTrie.TrieNodegetParent in class AddressTrie.TrieNode<K extends Address>public V get(K addr)
AddressTrieOps.AssociativeAddressTrieOpsIf the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
Returns the value for the given key. Returns null if the contains no mapping for that key or if the mapped value is null.
get in interface AddressTrieOps.AssociativeAddressTrieOps<K extends Address,V>public int hashCode()
Map.Entry.hashCode()public AssociativeAddressTrie<K,V> asNewTrie()
AddressTrie.TrieNodeasNewTrie in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> cloneTree()
cloneTree in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> clone()
clone in class AddressTrie.TrieNode<K extends Address>public boolean equals(Object o)
public Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> nodeIterator(boolean forward)
BinaryTreeNodenodeIterator in interface AddressTrieOps<K extends Address>nodeIterator in interface TreeOps<K extends Address>nodeIterator in class AddressTrie.TrieNode<K extends Address>forward - if true, goes in ascending order, otherwise descendingpublic Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> allNodeIterator(boolean forward)
BinaryTreeNodeallNodeIterator in interface AddressTrieOps<K extends Address>allNodeIterator in interface TreeOps<K extends Address>allNodeIterator in class AddressTrie.TrieNode<K extends Address>forward - if true, goes in ascending order, otherwise descendingpublic Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> blockSizeNodeIterator(boolean lowerSubNodeFirst)
AddressTrie.TrieNode
This iterator supports the Iterator.remove() operation.
blockSizeNodeIterator in class AddressTrie.TrieNode<K extends Address>lowerSubNodeFirst - if true, for blocks of equal size the lower is first, otherwise the reverse orderpublic Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> blockSizeAllNodeIterator(boolean lowerSubNodeFirst)
AddressTrie.TrieNode
This iterator supports the Iterator.remove() operation.
blockSizeAllNodeIterator in class AddressTrie.TrieNode<K extends Address>lowerSubNodeFirst - if true, for blocks of equal size the lower is first, otherwise the reverse orderpublic <C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> blockSizeCachingAllNodeIterator()
AddressTrie.TrieNodeblockSizeCachingAllNodeIterator in class AddressTrie.TrieNode<K extends Address>public <C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> containingFirstIterator(boolean forwardSubNodeOrder)
TreeOps
This iterator supports the Iterator.remove() operation.
Once a given node is visited, the iterator allows you to cache an object corresponding to the lower or upper sub-node that can be retrieved when you later visit that sub-node.
Objects are cached only with nodes to be visited. So for this iterator that means an object will be cached with the first added lower or upper sub-node, the next lower or upper sub-node to be visited, which is not necessarily the direct lower or upper sub-node of a given node.
The caching allows you to provide iteration context from a parent to its sub-nodes when iterating. The caching and retrieval is done in constant-time and linear space (proportional to tree size).
See TreeOps for more details on the ordering.
containingFirstIterator in interface AddressTrieOps<K extends Address>containingFirstIterator in interface TreeOps<K extends Address>containingFirstIterator in class AddressTrie.TrieNode<K extends Address>forwardSubNodeOrder - if true, a left sub-node will be visited before the right sub-node of the same parent node.public <C> BinaryTreeNode.CachingIterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>,K,C> containingFirstAllNodeIterator(boolean forwardSubNodeOrder)
TreeOps
This iterator supports the Iterator.remove() operation.
Once a given node is visited, the iterator allows you to cache an object corresponding to the lower or upper sub-node that can be retrieved when you later visit that sub-node. That allows you to provide iteration context from a parent to its sub-nodes when iterating. The caching and retrieval is done in constant-time and linear space (proportional to tree size).
Here is an example showing usage of the caching. Consider this recursive code doing a pre-order traversal:
IPv6AddressTrie ipv6Tree = ...;
visitRecursive(ipv6Tree.getRoot(), null);
static <E> void visitRecursive(BinaryTreeNode<E> node, String direction) {
if(direction == null) {
direction = "root";
}
System.out.println("visited " + direction + " " + node);
BinaryTreeNode<E> sub = node.getLowerSubNode();
if(sub != null) {
visitRecursive(sub, direction + " left");
}
sub = node.getUpperSubNode();
if(sub != null) {
visitRecursive(sub, direction + " right");
}
}
The following iterative code provides the same functionality:
visitIterative(ipv6Tree.getRoot());
static <E> void visitIterative(BinaryTreeNode<E> node) {
CachingIterator<? extends BinaryTreeNode<E>, E, String>iterator = node.containingFirstAllNodeIterator(true);
while(iterator.hasNext()) {
BinaryTreeNode<E> next = iterator.next();
String direction = iterator.getCached();
if(direction == null) {
direction = "root";
}
System.out.println("visited " + direction + " " + next);
iterator.cacheWithLowerSubNode(direction + " left");
iterator.cacheWithUpperSubNode(direction + " right");
}
}
See TreeOps for more details on the ordering.
containingFirstAllNodeIterator in interface AddressTrieOps<K extends Address>containingFirstAllNodeIterator in interface TreeOps<K extends Address>containingFirstAllNodeIterator in class AddressTrie.TrieNode<K extends Address>forwardSubNodeOrder - if true, a left sub-node will be visited before the right sub-node of the same parent node.public Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> containedFirstIterator(boolean forwardSubNodeOrder)
TreeOps
This iterator supports the Iterator.remove() operation.
See TreeOps for more details on the ordering.
containedFirstIterator in interface AddressTrieOps<K extends Address>containedFirstIterator in interface TreeOps<K extends Address>containedFirstIterator in class AddressTrie.TrieNode<K extends Address>forwardSubNodeOrder - if true, a left sub-node will be visited before the right sub-node of the same parent node.public Iterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> containedFirstAllNodeIterator(boolean forwardSubNodeOrder)
TreeOps
This iterator does not support the Iterator.remove() operation.
If Iterator.remove() is called it will throw UnsupportedOperationException.
See TreeOps for more details on the ordering.
containedFirstAllNodeIterator in interface AddressTrieOps<K extends Address>containedFirstAllNodeIterator in interface TreeOps<K extends Address>containedFirstAllNodeIterator in class AddressTrie.TrieNode<K extends Address>forwardSubNodeOrder - if true, a left sub-node will be visited before the right sub-node of the same parent node.public Spliterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> nodeSpliterator(boolean forward)
TreeOpsSpliterator over the added nodes in forward or reverse natural tree order.
See TreeOps for more details on the ordering.
nodeSpliterator in interface AddressTrieOps<K extends Address>nodeSpliterator in interface TreeOps<K extends Address>nodeSpliterator in class AddressTrie.TrieNode<K extends Address>forward - if true, goes in ascending order, otherwise descendingpublic Spliterator<? extends AssociativeAddressTrie.AssociativeTrieNode<K,V>> allNodeSpliterator(boolean forward)
TreeOpsSpliterator over the nodes in forward or reverse natural tree order.
See TreeOps for more details on the ordering.
allNodeSpliterator in interface AddressTrieOps<K extends Address>allNodeSpliterator in interface TreeOps<K extends Address>allNodeSpliterator in class AddressTrie.TrieNode<K extends Address>forward - if true, goes in ascending order, otherwise descendingpublic AssociativeAddressTrie.AssociativeTrieNode<K,V> previousAddedNode()
BinaryTreeNodepreviousAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> nextAddedNode()
BinaryTreeNodenextAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> nextNode()
BinaryTreeNodenextNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> previousNode()
BinaryTreeNodepreviousNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> firstNode()
BinaryTreeNodefirstNode in interface AddressTrieOps<K extends Address>firstNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> lastNode()
BinaryTreeNodelastNode in interface AddressTrieOps<K extends Address>lastNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> firstAddedNode()
BinaryTreeNodefirstAddedNode in interface AddressTrieOps<K extends Address>firstAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> lastAddedNode()
BinaryTreeNodelastAddedNode in interface AddressTrieOps<K extends Address>lastAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> lowerAddedNode(K addr)
AddressTrieOpslowerAddedNode in interface AddressTrieOps<K extends Address>lowerAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> floorAddedNode(K addr)
AddressTrieOpsfloorAddedNode in interface AddressTrieOps<K extends Address>floorAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> higherAddedNode(K addr)
AddressTrieOpshigherAddedNode in interface AddressTrieOps<K extends Address>higherAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> ceilingAddedNode(K addr)
AddressTrieOpsceilingAddedNode in interface AddressTrieOps<K extends Address>ceilingAddedNode in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> getAddedNode(K addr)
AddressTrieOps
Use AddressTrieOps.contains(Address) to check for the existence of a given address in the trie,
as well as AddressTrieOps.getNode(Address) to search for all nodes including those not-added but also auto-generated nodes for subnet blocks.
getAddedNode in interface AddressTrieOps<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> getNode(K addr)
AddressTrieOpsIf added is true, returns only nodes representing added elements, otherwise returns any node, including a prefix block that was not added.
If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
getNode in interface AddressTrieOps<K extends Address>getNode in class AddressTrie.TrieNode<K extends Address>AddressTrieOps.contains(Address)public AssociativeAddressTrie.AssociativeTrieNode<K,V> removeElementsContainedBy(K addr)
AddressTrieOps
Goes further than AddressTrieOps.remove(Address), not requiring a match to an inserted node, and also removing all the sub-nodes of any removed node or sub-node.
For example, after inserting 1.2.3.0 and 1.2.3.1, passing 1.2.3.0/31 to AddressTrieOps.removeElementsContainedBy(Address) will remove them both,
while AddressTrieOps.remove(Address) will remove nothing.
After inserting 1.2.3.0/31, then #remove(Address) will remove 1.2.3.0/31, but will leave 1.2.3.0 and 1.2.3.1 in the trie.
It cannot partially delete a node, such as deleting a single address from a prefix block represented by a node. It can only delete the whole node if the whole address or block represented by that node is contained in the given address or block.
If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
Returns the root node of the subtrie that was removed from the trie, or null if nothing was removed.
removeElementsContainedBy in interface AddressTrieOps<K extends Address>removeElementsContainedBy in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> elementsContainedBy(K addr)
AddressTrieOpsIf the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
Returns the root node of the contained subtrie, or null if no subtrie is contained.
The node returned need not be an "added" node, see BinaryTreeNode.isAdded() for more details on added nodes.
The returned subtrie is backed by this trie, so changes in this trie are reflected in those nodes and vice-versa.
elementsContainedBy in interface AddressTrieOps<K extends Address>elementsContainedBy in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> elementsContaining(K addr)
AddressTrieOpsIf the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
Returns a list of the nodes for prefix block subnets and addresses from the trie that contain the address or block.
The list consists only of added nodes, see BinaryTreeNode.isAdded() for more details on added nodes.
The list is constructed as a trie in which each parent node has only one sub-node.
Use AddressTrieOps.elementContains(Address) to check for the existence of a containing address.
elementsContaining in interface AddressTrieOps<K extends Address>elementsContaining in class AddressTrie.TrieNode<K extends Address>public AssociativeAddressTrie.AssociativeTrieNode<K,V> longestPrefixMatchNode(K addr)
AddressTrieOpsIf the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.
Returns null if no added subnet or address contains the given argument.
Use AddressTrieOps.elementContains(Address) to check for the existence of a containing address.
To get all the containing addresses, use AddressTrieOps.elementsContaining(Address).
Use AddressTrieOps.longestPrefixMatch(Address) to get the address corresponding to the result of this method.
longestPrefixMatchNode in interface AddressTrieOps<K extends Address>longestPrefixMatchNode in class AddressTrie.TrieNode<K extends Address>public String toString()
BinaryTreeNodetoString in class BinaryTreeNode<K extends Address>