K
- V
- public static interface AddressTrieOps.AssociativeAddressTriePutOps<K extends Address,V> extends AddressTrieOps.AssociativeAddressTrieOps<K,V>
Operations which take an address as an argument require that the address is an individual address or prefix block.
AddressTrieOps.AddressTrieAddOps<E extends Address>, AddressTrieOps.AssociativeAddressTrieOps<K extends Address,V>, AddressTrieOps.AssociativeAddressTriePutOps<K extends Address,V>
Modifier and Type | Method and Description |
---|---|
V |
put(K addr,
V value)
Associates the specified value with the specified key in this map.
|
boolean |
putNew(K addr,
V value)
Associates the specified value with the specified key in this map.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
putNode(K addr,
V value)
Associates the specified value with the specified key in this map.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
putTrie(AssociativeAddressTrie.AssociativeTrieNode<K,V> trie)
Adds nodes matching the given sub-root node and all of its sub-nodes to the trie, if not already there.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
remap(K addr,
Function<? super V,? extends V> remapper)
Remaps node values in the trie.
|
AssociativeAddressTrie.AssociativeTrieNode<K,V> |
remapIfAbsent(K 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.
|
get
allNodeIterator, allNodeSpliterator, ceiling, ceilingAddedNode, containedFirstAllNodeIterator, containedFirstIterator, containingFirstAllNodeIterator, containingFirstIterator, contains, elementContains, elementsContainedBy, elementsContaining, firstAddedNode, firstNode, floor, floorAddedNode, getAddedNode, getNode, higher, higherAddedNode, lastAddedNode, lastNode, longestPrefixMatch, longestPrefixMatchNode, lower, lowerAddedNode, nodeIterator, nodeSpliterator, remove, removeElementsContainedBy, shortestPrefixMatch, shortestPrefixMatchNode
descendingIterator, descendingSpliterator, iterator, spliterator
V put(K addr, V value)
Unlike putNew(Address, Object)
, put(Address, Object)
can provide the value to which to key was previously mapped.
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.
If this map previously contained a mapping for a key, the old value is replaced by the specified value, and the old value is returned. If this map did not previously contain a mapping for the key, null is returned.
addr
- boolean putNew(K addr, V value)
Unlike put(Address, Object)
, 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 Partition
class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address)
for more details.
If this map previously contained a mapping for a key, the old value is replaced by the specified value, and false is returned. If this map did not previously contain a mapping for the key, true is returned.
addr
- AssociativeAddressTrie.AssociativeTrieNode<K,V> putNode(K addr, V value)
Unlike put(Address, Object)
, 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 Partition
class can be used to convert the address before calling this method.
See AddressTrieOps.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 putNew(Address, Object)
, or before adding you can use AddressTrieOps.getAddedNode(Address)
addr
- AssociativeAddressTrie.AssociativeTrieNode<K,V> remap(K addr, Function<? super V,? extends V> remapper)
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 Partition
class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address)
for more details.
addr
- remapper
- AssociativeAddressTrie.AssociativeTrieNode<K,V> remapIfAbsent(K addr, Supplier<? extends V> remapper, boolean insertNull)
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 Partition
class can be used to convert the address before calling this method.
See AddressTrieOps.AddressTrieAddOps.add(Address)
for more details.
addr
- remapper
- insertNull
- whether null values returned from remapper should be inserted into the map, or whether null values indicate no remappingAssociativeAddressTrie.AssociativeTrieNode<K,V> putTrie(AssociativeAddressTrie.AssociativeTrieNode<K,V> trie)
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.
trie
-