Class IPv4AddressAssociativeTrie<V>
- Type Parameters:
V- the type of the associated values
- All Implemented Interfaces:
AddressTrieOps<IPv4Address>, AddressTrieOps.AddressTrieAddOps<IPv4Address>, AddressTrieOps.AssociativeAddressTrieOps<IPv4Address, V>, AddressTrieOps.AssociativeAddressTriePutOps<IPv4Address, V>, TreeOps<IPv4Address>, Serializable, Cloneable, Iterable<IPv4Address>
AssociativeAddressTrie for more details.- Author:
- scfoley
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNested classes/interfaces inherited from class AssociativeAddressTrie
AssociativeAddressTrie.AssociativeTrieNode<K,V> Nested classes/interfaces inherited from class AddressTrie
AddressTrie.AddressComparator<E>, AddressTrie.TrieComparator<E>, AddressTrie.TrieNode<E>Nested classes/interfaces inherited from interface AddressTrieOps
AddressTrieOps.AddressTrieAddOps<E>, AddressTrieOps.AssociativeAddressTrieOps<K,V>, AddressTrieOps.AssociativeAddressTriePutOps<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddNode(IPv4Address addr) Adds the given single address or prefix block subnet to the trie, if not already there.Adds nodes matching the given sub-root node and all of its sub-nodes to the trie, if not already there.allNodeIterator(boolean forward) Iterates through the nodes (not just the added nodes) in forward or reverse tree order.allNodeSpliterator(boolean forward) Creates aSpliteratorover the nodes in forward or reverse natural tree order.blockSizeAllNodeIterator(boolean lowerSubNodeFirst) Iterates all nodes in the trie, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.<C> BinaryTreeNode.CachingIterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>, IPv4Address, C> Iterates all nodes, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.blockSizeNodeIterator(boolean lowerSubNodeFirst) Iterates the added nodes in the trie, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.ceilingAddedNode(IPv4Address addr) Returns the added node whose address is the lowest address greater than or equal to the given address.clone()Copies the trie, but not the keys or values.Provides an associative trie in which the root and each added node are mapped to a list of their respective direct added nodes.containedFirstAllNodeIterator(boolean forwardSubNodeOrder) Returns an iterator that does a post-order binary tree traversal.containedFirstIterator(boolean forwardSubNodeOrder) Returns an iterator that does a post-order binary tree traversal of the added nodes.<C> BinaryTreeNode.CachingIterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>, IPv4Address, C> containingFirstAllNodeIterator(boolean forwardSubNodeOrder) Returns an iterator that does a pre-order binary tree traversal.containingFirstIterator(boolean forwardSubNodeOrder) Returns an iterator that does a pre-order binary tree traversal of the added nodes.Traverses the added node keys in reverse natural tree order.Checks if a part of this trie is contained by the given prefix block subnet or individual address.Finds the added subnets and/or addresses in the trie that contain the given individual address or prefix block subnet.booleanReturns whether the given argument is a trie with a set of nodes that equal the set of nodes in this trieReturns the added node with the first (lowest valued) key, or null if there are no added entries in this trie or subtrieReturns the node with the first (lowest valued) key, whether the node is added or notfloorAddedNode(IPv4Address addr) Returns the added node whose address is the highest address less than or equal to the given address.getAddedNode(IPv4Address addr) Gets trie nodes representing added elements.getNode(IPv4Address addr) Gets the node corresponding to the given address, returns null if not such element exists.getRoot()Returns the root of this trieinthashCode()higherAddedNode(IPv4Address addr) Returns the added node whose address is the lowest address strictly greater than the given address.iterator()Traverses the added node keys in natural tree order.Returns the added node with the last (highest valued) key, or null if there are no added elements in this trie or subtrielastNode()Returns the node with the last (highest valued) key, whether the node is added or notFinds 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.lowerAddedNode(IPv4Address addr) Returns the added node whose address is the highest address strictly less than the given address.nodeIterator(boolean forward) Iterates through the added nodes in forward or reverse natural tree order.nodeSpliterator(boolean forward) Creates aSpliteratorover the added nodes in forward or reverse natural tree order.putNode(IPv4Address addr, V value) Associates the specified value with the specified key in this map.Adds nodes matching the given sub-root node and all of its sub-nodes to the trie, if not already there.remap(IPv4Address addr, Function<? super V, ? extends V> remapper) Remaps node values in the trie.remapIfAbsent(IPv4Address addr, Supplier<? extends V> remapper, boolean insertNull) Remaps node values in the trie, but only for nodes that do not exist or are mapped to null.Removes any single address or prefix block subnet from the trie that is contained in the given individual address or prefix block subnet.Provides a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary.Methods inherited from class AssociativeAddressTrie
asMap, get, put, putNew, shortestPrefixMatchNodeMethods inherited from class AddressTrie
add, asSet, ceiling, clear, contains, decrement, descendingSpliterator, elementContains, floor, getComparator, higher, increment, isEmpty, longestPrefixMatch, lower, nodeSize, remove, shortestPrefixMatch, size, spliterator, toString, toString, toStringMethods inherited from interface AddressTrieOps
ceiling, contains, elementContains, floor, higher, longestPrefixMatch, lower, remove, shortestPrefixMatchMethods inherited from interface TreeOps
descendingIterator, descendingSpliterator, iterator, spliterator
-
Constructor Details
-
IPv4AddressAssociativeTrie
public IPv4AddressAssociativeTrie()
-
-
Method Details
-
getRoot
Returns the root of this trie- Overrides:
getRootin classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
removeElementsContainedBy
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> removeElementsContainedBy(IPv4Address addr) Description copied from interface:AddressTrieOpsRemoves any single address or prefix block subnet from the trie that is contained in the given individual address or prefix block subnet.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, whileAddressTrieOps.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.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.
- Specified by:
removeElementsContainedByin interfaceAddressTrieOps<V>- Overrides:
removeElementsContainedByin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
elementsContainedBy
Description copied from interface:AddressTrieOpsChecks if a part of this trie is contained by the given prefix block subnet or individual address.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.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.- Specified by:
elementsContainedByin interfaceAddressTrieOps<V>- Overrides:
elementsContainedByin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
elementsContaining
Description copied from interface:AddressTrieOpsFinds the added subnets and/or addresses in the trie that contain the given individual address or prefix block subnet.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.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.- Specified by:
elementsContainingin interfaceAddressTrieOps<V>- Overrides:
elementsContainingin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
longestPrefixMatchNode
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> longestPrefixMatchNode(IPv4Address addr) Description copied from interface:AddressTrieOpsFinds 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. Returns the node corresponding to that subnet.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.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, useAddressTrieOps.elementsContaining(Address).
UseAddressTrieOps.longestPrefixMatch(Address)to get the address corresponding to the result of this method.- Specified by:
longestPrefixMatchNodein interfaceAddressTrieOps<V>- Overrides:
longestPrefixMatchNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
getAddedNode
Description copied from interface:AddressTrieOpsGets trie nodes representing added elements.Use
AddressTrieOps.contains(Address)to check for the existence of a given address in the trie, as well asAddressTrieOps.getNode(Address)to search for all nodes including those not-added but also auto-generated nodes for subnet blocks.- Specified by:
getAddedNodein interfaceAddressTrieOps<V>- Overrides:
getAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
getNode
Description copied from interface:AddressTrieOpsGets the node corresponding to the given address, returns null if not such element exists.If 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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.AddressTrieAddOps.add(Address)for more details.- Specified by:
getNodein interfaceAddressTrieOps<V>- Overrides:
getNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
- See Also:
-
addNode
Description copied from interface:AddressTrieOps.AddressTrieAddOpsAdds the given single address or prefix block subnet to the trie, if not already there.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.AddressTrieAddOps.add(Address)for more details.Returns the node for the added address, whether it was already in the trie or not.
If you wish to know whether the node was already there when adding, use
AddressTrieOps.AddressTrieAddOps.add(Address), or before adding you can useAddressTrieOps.getAddedNode(Address)- Specified by:
addNodein interfaceAddressTrieOps.AddressTrieAddOps<V>- Overrides:
addNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
addTrie
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> addTrie(AddressTrie.TrieNode<IPv4Address> trie) Description copied from interface:AddressTrieOps.AddressTrieAddOpsAdds nodes matching the given sub-root node and all of its sub-nodes to the trie, if not already there.For each added in the given node that does not exist in the trie, a copy of each node will be made that matches the trie type (associative or not), and the copy will be inserted into the trie.
The node type need not match the node type of the trie, although the address type/version E must match. You can add associative nodes to tries with this method but associated values will all be null. If you want to preserve the values, use
AddressTrieOps.AssociativeAddressTriePutOps.putTrie(AssociativeTrieNode)instead.When adding one trie to another, this method is more efficient than adding each node of the first trie individually. When using this method, searching for the location to add sub-nodes starts from the inserted parent node.
Returns the node corresponding to the given sub-root node, whether it was already in the trie or not.
- Specified by:
addTriein interfaceAddressTrieOps.AddressTrieAddOps<V>- Overrides:
addTriein classAddressTrie<IPv4Address>- Parameters:
trie-- Returns:
-
nodeIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> nodeIterator(boolean forward) Description copied from interface:TreeOpsIterates through the added nodes in forward or reverse natural tree order.This iterator supports the
Iterator.remove()operation.See
TreeOpsfor more details on the ordering.- Specified by:
nodeIteratorin interfaceAddressTrieOps<V>- Specified by:
nodeIteratorin interfaceTreeOps<V>- Overrides:
nodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forward- if true, goes in ascending order, otherwise descending- Returns:
-
allNodeIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> allNodeIterator(boolean forward) Description copied from interface:TreeOpsIterates through the nodes (not just the added nodes) in forward or reverse tree order.See
TreeOpsfor more details on the ordering. This iterator supports theIterator.remove()operation.- Specified by:
allNodeIteratorin interfaceAddressTrieOps<V>- Specified by:
allNodeIteratorin interfaceTreeOps<V>- Overrides:
allNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forward- if true, goes in ascending order, otherwise descending- Returns:
-
blockSizeNodeIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> blockSizeNodeIterator(boolean lowerSubNodeFirst) Description copied from class:AddressTrieIterates the added nodes in the trie, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.This iterator supports the
Iterator.remove()operation.- Overrides:
blockSizeNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
lowerSubNodeFirst- if true, for blocks of equal size the lower is first, otherwise the reverse order- Returns:
-
blockSizeAllNodeIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> blockSizeAllNodeIterator(boolean lowerSubNodeFirst) Description copied from class:AddressTrieIterates all nodes in the trie, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.This iterator supports the
Iterator.remove()operation.- Overrides:
blockSizeAllNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
lowerSubNodeFirst- if true, for blocks of equal size the lower is first, otherwise the reverse order- Returns:
-
blockSizeCachingAllNodeIterator
public <C> BinaryTreeNode.CachingIterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>, IPv4Address, C> blockSizeCachingAllNodeIterator()Description copied from class:AddressTrieIterates all nodes, ordered by keys from largest prefix blocks to smallest, and then to individual addresses.This iterator supports the
Iterator.remove()operation.- Overrides:
blockSizeCachingAllNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
containingFirstIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> containingFirstIterator(boolean forwardSubNodeOrder) Description copied from interface:TreeOpsReturns an iterator that does a pre-order binary tree traversal of the added nodes. All added nodes will be visited before their added sub-nodes. For an address trie this means added containing subnet blocks will be visited before their added contained addresses and subnet blocks.This iterator supports the
Iterator.remove()operation.See the docs for
TreeOpsfor more details on the ordering.- Specified by:
containingFirstIteratorin interfaceAddressTrieOps<V>- Specified by:
containingFirstIteratorin interfaceTreeOps<V>- Overrides:
containingFirstIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forwardSubNodeOrder- if true, a left sub-node will be visited before the right sub-node of the same parent node.- Returns:
-
containingFirstAllNodeIterator
public <C> BinaryTreeNode.CachingIterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>, IPv4Address, C> containingFirstAllNodeIterator(boolean forwardSubNodeOrder) Description copied from interface:TreeOpsReturns an iterator that does a pre-order binary tree traversal. All nodes will be visited before their sub-nodes. For an address trie this means containing subnet blocks will be visited before their contained addresses and subnet blocks.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:
The following iterative code provides the same functionality: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"); } }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
TreeOpsfor more details on the ordering.- Specified by:
containingFirstAllNodeIteratorin interfaceAddressTrieOps<V>- Specified by:
containingFirstAllNodeIteratorin interfaceTreeOps<V>- Overrides:
containingFirstAllNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forwardSubNodeOrder- if true, a left sub-node will be visited before the right sub-node of the same parent node.- Returns:
-
containedFirstIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> containedFirstIterator(boolean forwardSubNodeOrder) Description copied from interface:TreeOpsReturns an iterator that does a post-order binary tree traversal of the added nodes. All added sub-nodes will be visited before their parent nodes. For an address trie this means contained addresses and subnets will be visited before their containing subnet blocks.This iterator supports the
Iterator.remove()operation.See
TreeOpsfor more details on the ordering.- Specified by:
containedFirstIteratorin interfaceAddressTrieOps<V>- Specified by:
containedFirstIteratorin interfaceTreeOps<V>- Overrides:
containedFirstIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forwardSubNodeOrder- if true, a left sub-node will be visited before the right sub-node of the same parent node.- Returns:
-
containedFirstAllNodeIterator
public Iterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> containedFirstAllNodeIterator(boolean forwardSubNodeOrder) Description copied from interface:TreeOpsReturns an iterator that does a post-order binary tree traversal. All sub-nodes will be visited before their parent nodes. For an address trie this means contained addresses and subnets will be visited before their containing subnet blocks.This iterator does not support the
Iterator.remove()operation. IfIterator.remove()is called it will throwUnsupportedOperationException.See
TreeOpsfor more details on the ordering.- Specified by:
containedFirstAllNodeIteratorin interfaceAddressTrieOps<V>- Specified by:
containedFirstAllNodeIteratorin interfaceTreeOps<V>- Overrides:
containedFirstAllNodeIteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forwardSubNodeOrder- if true, a left sub-node will be visited before the right sub-node of the same parent node.- Returns:
-
nodeSpliterator
public Spliterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> nodeSpliterator(boolean forward) Description copied from interface:TreeOpsCreates aSpliteratorover the added nodes in forward or reverse natural tree order.See
TreeOpsfor more details on the ordering.- Specified by:
nodeSpliteratorin interfaceAddressTrieOps<V>- Specified by:
nodeSpliteratorin interfaceTreeOps<V>- Overrides:
nodeSpliteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forward- if true, goes in ascending order, otherwise descending- Returns:
-
allNodeSpliterator
public Spliterator<IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V>> allNodeSpliterator(boolean forward) Description copied from interface:TreeOpsCreates aSpliteratorover the nodes in forward or reverse natural tree order.See
TreeOpsfor more details on the ordering.- Specified by:
allNodeSpliteratorin interfaceAddressTrieOps<V>- Specified by:
allNodeSpliteratorin interfaceTreeOps<V>- Overrides:
allNodeSpliteratorin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
forward- if true, goes in ascending order, otherwise descending- Returns:
-
lowerAddedNode
Description copied from interface:AddressTrieOpsReturns the added node whose address is the highest address strictly less than the given address.- Specified by:
lowerAddedNodein interfaceAddressTrieOps<V>- Overrides:
lowerAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
floorAddedNode
Description copied from interface:AddressTrieOpsReturns the added node whose address is the highest address less than or equal to the given address.- Specified by:
floorAddedNodein interfaceAddressTrieOps<V>- Overrides:
floorAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
higherAddedNode
Description copied from interface:AddressTrieOpsReturns the added node whose address is the lowest address strictly greater than the given address.- Specified by:
higherAddedNodein interfaceAddressTrieOps<V>- Overrides:
higherAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
ceilingAddedNode
Description copied from interface:AddressTrieOpsReturns the added node whose address is the lowest address greater than or equal to the given address.- Specified by:
ceilingAddedNodein interfaceAddressTrieOps<V>- Overrides:
ceilingAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
firstNode
Description copied from interface:AddressTrieOpsReturns the node with the first (lowest valued) key, whether the node is added or not- Specified by:
firstNodein interfaceAddressTrieOps<V>- Overrides:
firstNodein classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
lastNode
Description copied from interface:AddressTrieOpsReturns the node with the last (highest valued) key, whether the node is added or not- Specified by:
lastNodein interfaceAddressTrieOps<V>- Overrides:
lastNodein classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
firstAddedNode
Description copied from interface:AddressTrieOpsReturns the added node with the first (lowest valued) key, or null if there are no added entries in this trie or subtrie- Specified by:
firstAddedNodein interfaceAddressTrieOps<V>- Overrides:
firstAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
lastAddedNode
Description copied from interface:AddressTrieOpsReturns the added node with the last (highest valued) key, or null if there are no added elements in this trie or subtrie- Specified by:
lastAddedNodein interfaceAddressTrieOps<V>- Overrides:
lastAddedNodein classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
putNode
Description copied from interface:AddressTrieOps.AssociativeAddressTriePutOpsAssociates the specified value with the specified key in this map.Unlike
AddressTrieOps.AssociativeAddressTriePutOps.put(Address, Object),AddressTrieOps.AssociativeAddressTriePutOps.put(Address, Object)can distinguish between cases where the call results in a new entry, and cases where the call matched a previous entry that was mapped to null.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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.AddressTrieAddOps.add(Address)for more details.Returns the node for the added address, whether it was already in the tree or not.
If you wish to know whether the node was already there when adding, use
AddressTrieOps.AssociativeAddressTriePutOps.putNew(Address, Object), or before adding you can useAddressTrieOps.getAddedNode(Address)- Specified by:
putNodein interfaceAddressTrieOps.AssociativeAddressTriePutOps<IPv4Address, V>- Overrides:
putNodein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-- Returns:
-
putTrie
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> putTrie(AssociativeAddressTrie.AssociativeTrieNode<IPv4Address, V> trie) Description copied from interface:AddressTrieOps.AssociativeAddressTriePutOpsAdds nodes matching the given sub-root node and all of its sub-nodes to the trie, if not already there.For each added in the given node that does not exist in the trie, a copy of each node will be made that matches the trie type (associative or not), the copy including the associated value, and the copy will be inserted into the trie.
The node type need not match the node type of the trie, although the address type/version E must match. So this means you can add non-associative nodes with this method, in which case, the new nodes will be associative but will be mapped to null.
When adding one trie to another, this method is more efficient than adding each node of the first trie individually. When using this method, searching for the location to add sub-nodes starts from the inserted parent node.
Returns the node corresponding to the given sub-root node, whether it was already in the trie or not.
- Specified by:
putTriein interfaceAddressTrieOps.AssociativeAddressTriePutOps<IPv4Address, V>- Overrides:
putTriein classAssociativeAddressTrie<IPv4Address, V>- Parameters:
trie-- Returns:
-
remap
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> remap(IPv4Address addr, Function<? super V, ? extends V> remapper) Description copied from interface:AddressTrieOps.AssociativeAddressTriePutOpsRemaps node values in the trie.This will lookup the node corresponding to the given key. It will call the remapping function with the key as the first argument, regardless of whether the node is found or not.
If the node is not found, the value argument will be null. If the node is found, the value argument will be the node's value, which can also be null.
If the remapping function returns null, then the matched node will be removed, if any. If it returns a non-null value, then it will either set the existing node to have that value, or if there was no matched node, it will create a new node with that value.
The method will return the node involved, which is either the matched node, or the newly created node, or null if there was no matched node nor newly created node.
If the remapping function modifies the trie during its computation, and the returned value specifies changes to be made, then the trie will not be changed and ConcurrentModificationException will be thrown instead.
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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.AddressTrieAddOps.add(Address)for more details.- Specified by:
remapin interfaceAddressTrieOps.AssociativeAddressTriePutOps<IPv4Address, V>- Overrides:
remapin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-remapper-- Returns:
-
remapIfAbsent
public IPv4AddressAssociativeTrie.IPv4AssociativeTrieNode<V> remapIfAbsent(IPv4Address addr, Supplier<? extends V> remapper, boolean insertNull) Description copied from interface:AddressTrieOps.AssociativeAddressTriePutOpsRemaps node values in the trie, but only for nodes that do not exist or are mapped to null.This will look up the node corresponding to the given key. If the node is not found or mapped to null, this will call the remapping function.
If the remapping function returns a non-null value, then it will either set the existing node to have that value, or if there was no matched node, it will create a new node with that value. If the remapping function returns null, then it will do the same if insertNull is true, otherwise it will do nothing.
The method will return the node involved, which is either the matched node, or the newly created node, or null if there was no matched node nor newly created node.
If the remapping function modifies the trie during its computation, and the returned value specifies changes to be made, then the trie will not be changed and ConcurrentModificationException will be thrown instead.
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
Partitionclass can be used to convert the address before calling this method. SeeAddressTrieOps.AddressTrieAddOps.add(Address)for more details.- Specified by:
remapIfAbsentin interfaceAddressTrieOps.AssociativeAddressTriePutOps<IPv4Address, V>- Overrides:
remapIfAbsentin classAssociativeAddressTrie<IPv4Address, V>- Parameters:
addr-remapper-insertNull- whether null values returned from remapper should be inserted into the map, or whether null values indicate no remapping- Returns:
-
equals
Description copied from class:AddressTrieReturns whether the given argument is a trie with a set of nodes that equal the set of nodes in this trie- Overrides:
equalsin classAssociativeAddressTrie<IPv4Address, V>
-
clone
Copies the trie, but not the keys or values.- Overrides:
clonein classAssociativeAddressTrie<IPv4Address, V>
-
constructAddedNodesTree
Description copied from class:AddressTrieProvides an associative trie in which the root and each added node are mapped to a list of their respective direct added nodes. This trie provides an alternative non-binary tree structure of the added nodes. It is used byAddressTrie.toAddedNodesTreeString()to produce a string showing the alternative structure. If there are no non-added nodes in this trie, then the alternative tree structure provided by this method is the same as the original trie.- Specified by:
constructAddedNodesTreein classAssociativeAddressTrie<IPv4Address, V>- Returns:
-
toAddedNodesTreeString
Description copied from class:AddressTrieProvides a flattened version of the trie showing only the contained added nodes and their containment structure, which is non-binary. The root node is included, which may or may not be added.- Specified by:
toAddedNodesTreeStringin classAddressTrie<IPv4Address>- Returns:
-
iterator
Description copied from interface:TreeOpsTraverses the added node keys in natural tree order.This iterator supports the
Iterator.remove()operation.See
TreeOpsfor more details on the ordering. -
descendingIterator
Description copied from interface:TreeOpsTraverses the added node keys in reverse natural tree order.This iterator supports the
Iterator.remove()operation.See
TreeOpsfor more details on the ordering.- Specified by:
descendingIteratorin interfaceTreeOps<E extends Address>- Returns:
-
hashCode
-