K - the address typeV - the type of the mapped valuespublic class AddressTrieMap<K extends Address,V> extends AbstractMap<K,V> implements NavigableMap<K,V>, Cloneable, Serializable
AssociativeAddressTrie to view it as a Java Collections Framework map,
implementing the Map, SortedMap, and NavigableMap interfaces.
Like TreeMap, this map is backed by a binary tree and implements the same interfaces that TreeMap does.
But there are some significant differences between the two binary tree implementations.
A trie is naturally balanced and can only reach a depth corresponding to the number of bits in the keys, which is 32 for IPv4 and 128 for IPv6 tries. The TreeMap is balanced using red-black balancing.
The AssociativeAddressTrie allows you to modify the map entries using Map.Entry.setValue(Object),
while TreeMap does not. The entries provided by the TreeMap are copies of the original nodes,
so that the original nodes can be re-purposed. The nodes are not exposed.
In the AssociativeAddressTrie nodes are not re-purposed, and in fact they are also exposed.
This enables navigation through the nodes.
The node hierarchy has a special meaning, there is only one hierarchy for any given set of addresses,
since it is determined by prefix block subnet containment. The hierarchy enables certain address-specific containment-based operations,
such as subnet deletion or containment checks.
In the trie map, when doing lookups and some other operations, only parts of the address keys are examined at each node in the binary tree search,
rather than comparisons of the whole key, as with TreeMap.
The trie map supports only the one comparison representing subnet containment, which is based on bit values and prefix length.
The TreeMap is a general-purpose map supporting any natural ordering or Comparator.
With the trie map, only addresses that are either individual address or prefix block subnets of the same type and version can be added to the trie,
see AddressTrie.AddressComparator for a comparator for the ordering.
Should you wish to store, in a map, address instances that are not individual address or prefix block subnets,
you can use TreeMap or any other Java collections framework map to store addresses of any type,
or addresses of different versions or types in the same map,
since all address items in this library are comparable with a natural ordering.
There are additional orderings provided by this library as well, see AddressComparator.
| Modifier and Type | Class and Description |
|---|---|
static class |
AddressTrieMap.EntrySet<K extends Address,V> |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
AddressTrieMap(AssociativeAddressTrie<K,V> trie) |
AddressTrieMap(AssociativeAddressTrie<K,V> trie,
Map<? extends K,? extends V> map) |
| Modifier and Type | Method and Description |
|---|---|
AssociativeAddressTrie<K,V> |
asTrie()
Return a trie representing this map.
|
Map.Entry<K,V> |
ceilingEntry(K key)
Returns a key-value mapping associated with the least key
greater than or equal to the given key, or
null if
there is no such key. |
K |
ceilingKey(K key)
Returns the least key greater than or equal to the given key,
or
null if there is no such key. |
void |
clear()
Removes all of the mappings from this map (optional operation).
|
AddressTrieMap<K,V> |
clone()
Clones the map along with the backing trie.
|
Comparator<K> |
comparator()
Returns the comparator used to order the keys in this map, or
null if this map uses the natural ordering of its keys. |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current
mapped value (or
null if there is no current mapping). |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> remappingFunction)
If the specified key is not already associated with a value (or is mapped
to
null), attempts to compute its value using the given mapping
function and enters it into this map unless null. |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null, attempts to
compute a new mapping given the key and its current mapped value.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the
specified value.
|
AddressTrieSet<K> |
descendingKeySet()
Returns a reverse order
NavigableSet view of the keys contained in this map. |
AddressTrieMap<K,V> |
descendingMap()
Returns a reverse order view of the mappings contained in this map.
|
AddressTrieMap.EntrySet<K,V> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
boolean |
equals(Object o)
Compares the specified object with this map for equality.
|
Map.Entry<K,V> |
firstEntry()
Returns a key-value mapping associated with the least
key in this map, or
null if the map is empty. |
K |
firstKey()
Returns the first (lowest) key currently in this map.
|
Map.Entry<K,V> |
floorEntry(K key)
Returns a key-value mapping associated with the greatest key
less than or equal to the given key, or
null if there
is no such key. |
K |
floorKey(K key)
Returns the greatest key less than or equal to the given key,
or
null if there is no such key. |
void |
forEach(BiConsumer<? super K,? super V> action)
Performs the given action for each entry in this map until all entries
have been processed or the action throws an exception.
|
V |
get(Object key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
V |
getOrDefault(Object key,
V defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key. |
AddressTrieSet.Range<K> |
getRange()
Returns the range if this map has a restricted range, see
hasRestrictedRange(). |
int |
hashCode()
Returns the hash code value for this map.
|
boolean |
hasRestrictedRange()
Returns whether this map is the result of a call to
headMap(Address), tailMap(Address),
subMap(Address, Address) or any of the other methods with the same names. |
AddressTrieMap<K,V> |
headMap(K toKey)
Returns a view of the portion of this map whose keys are
strictly less than
toKey. |
AddressTrieMap<K,V> |
headMap(K toKey,
boolean inclusive)
Returns a view of the portion of this map whose keys are less than (or
equal to, if
inclusive is true) toKey. |
Map.Entry<K,V> |
higherEntry(K key)
Returns a key-value mapping associated with the least key
strictly greater than the given key, or
null if there
is no such key. |
K |
higherKey(K key)
Returns the least key strictly greater than the given key, or
null if there is no such key. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
boolean |
keyContains(K addr)
Returns true if a subnet or address key in the map contains the given subnet or address.
|
AddressTrieSet<K> |
keySet()
Returns a
Set view of the keys contained in this map. |
Map.Entry<K,V> |
lastEntry()
Returns a key-value mapping associated with the greatest
key in this map, or
null if the map is empty. |
K |
lastKey()
Returns the last (highest) key currently in this map.
|
Map.Entry<K,V> |
longestPrefixMatchEntry(K addr)
Returns the map entry corresponding to the key with the longest prefix match with the given address.
|
Map.Entry<K,V> |
lowerEntry(K key)
Returns a key-value mapping associated with the greatest key
strictly less than the given key, or
null if there is
no such key. |
K |
lowerKey(K key)
Returns the greatest key strictly less than the given key, or
null if there is no such key. |
V |
merge(K key,
V suppliedValue,
BiFunction<? super V,? super V,? extends V> remappingFunction)
If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value.
|
AddressTrieSet<K> |
navigableKeySet()
Returns a
NavigableSet view of the keys contained in this map. |
Map.Entry<K,V> |
pollFirstEntry()
Removes and returns a key-value mapping associated with
the least key in this map, or
null if the map is empty. |
Map.Entry<K,V> |
pollLastEntry()
Removes and returns a key-value mapping associated with
the greatest key in this map, or
null if the map is empty. |
V |
put(K key,
V value)
Maps the given single address or prefix block subnet to the given value in the map.
|
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value (or is mapped
to
null) associates it with the given value and returns
null, else returns the current value. |
V |
remove(Object key)
Removes the mapping for a key from this map if it is present
(optional operation).
|
boolean |
remove(Object key,
Object value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
V |
replace(K key,
V value)
Replaces the entry for the specified key only if it is
currently mapped to some value.
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently
mapped to the specified value.
|
void |
replaceAll(BiFunction<? super K,? super V,? extends V> function)
Replaces each entry's value with the result of invoking the given
function on that entry until all entries have been processed or the
function throws an exception.
|
int |
size()
Returns the number of mappings in this map.
|
AddressTrieMap<K,V> |
subMap(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
Returns a view of the portion of this map whose keys range from
fromKey to toKey. |
AddressTrieMap<K,V> |
subMap(K fromKey,
K toKey)
Returns a view of the portion of this map whose keys range from
fromKey, inclusive, to toKey, exclusive. |
AddressTrieMap<K,V> |
subMapFromKeysContainedBy(K addr)
Returns a sub-map consisting of the mappings in the map with address keys contained by the given address
The sub-map will have a restricted range matching the range of the given subnet or address.
|
AddressTrieMap<K,V> |
subMapFromKeysContaining(K addr)
Returns a sub-map consisting of the mappings in the map with address keys that contain the given address.
|
AddressTrieMap<K,V> |
tailMap(K fromKey)
Returns a view of the portion of this map whose keys are
greater than or equal to
fromKey. |
AddressTrieMap<K,V> |
tailMap(K fromKey,
boolean inclusive)
Returns a view of the portion of this map whose keys are greater than (or
equal to, if
inclusive is true) fromKey. |
String |
toTrieString() |
putAll, toString, valuespublic AddressTrieMap(AssociativeAddressTrie<K,V> trie)
public AddressTrieMap<K,V> descendingMap()
java.util.NavigableMapremove
operation), the results of the iteration are undefined.
The returned map has an ordering equivalent to
Collections.reverseOrder(comparator()).
The expression m.descendingMap().descendingMap() returns a
view of m essentially equivalent to m.
descendingMap in interface NavigableMap<K extends Address,V>public AddressTrieSet<K> descendingKeySet()
java.util.NavigableMapNavigableSet view of the keys contained in this map.
The set's iterator returns the keys in descending order.
The set is backed by the map, so changes to the map are reflected in
the set, and vice-versa. If the map is modified while an iteration
over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear operations.
It does not support the add or addAll operations.descendingKeySet in interface NavigableMap<K extends Address,V>public AssociativeAddressTrie<K,V> asTrie()
If this map has a restricted range, see hasRestrictedRange(),
this generates a new trie corresponding to the map with only the nodes pertaining to the restricted range sub-map.
Otherwise this returns the original backing trie for this map.
When a new trie is generated, the original backing trie for this map remains the same, it is not changed to the new trie.
The returned trie will always have the same natural trie ordering, even if this map has the reverse ordering.
public boolean hasRestrictedRange()
headMap(Address), tailMap(Address),
subMap(Address, Address) or any of the other methods with the same names.public AddressTrieSet.Range<K> getRange()
hasRestrictedRange(). Otherwise returns null.public AddressTrieSet<K> keySet()
java.util.AbstractMapSet view of the keys contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. If the map is modified
while an iteration over the set is in progress (except through
the iterator's own remove operation), the results of
the iteration are undefined. The set supports element removal,
which removes the corresponding mapping from the map, via the
Iterator.remove, Set.remove,
removeAll, retainAll, and clear
operations. It does not support the add or addAll
operations.public AddressTrieSet<K> navigableKeySet()
java.util.NavigableMapNavigableSet view of the keys contained in this map.
The set's iterator returns the keys in ascending order.
The set is backed by the map, so changes to the map are reflected in
the set, and vice-versa. If the map is modified while an iteration
over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear operations.
It does not support the add or addAll operations.navigableKeySet in interface NavigableMap<K extends Address,V>public AddressTrieMap.EntrySet<K,V> entrySet()
java.util.MapSet view of the mappings contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. If the map is modified
while an iteration over the set is in progress (except through
the iterator's own remove operation, or through the
setValue operation on a map entry returned by the
iterator) the results of the iteration are undefined. The set
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Set.remove, removeAll, retainAll and
clear operations. It does not support the
add or addAll operations.public V merge(K key, V suppliedValue, BiFunction<? super V,? super V,? extends V> remappingFunction)
java.util.Mapnull. This
method may be of use when combining multiple mapped values for a key.
For example, to either create or append a String msg to a
value mapping:
map.merge(key, msg, String::concat)
If the function returns null the mapping is removed. If the
function itself throws an (unchecked) exception, the exception is
rethrown, and the current mapping is left unchanged.
merge in interface Map<K extends Address,V>key - key with which the resulting value is to be associatedsuppliedValue - the non-null value to be merged with the existing value
associated with the key or, if no existing value or a null value
is associated with the key, to be associated with the keyremappingFunction - the function to recompute a value if presentpublic V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
java.util.Mapnull if there is no current mapping). For
example, to either create or append a String msg to a value
mapping:
map.compute(key, (k, v) -> (v == null) ? msg : v.concat(msg))
(Method merge() is often simpler to use for such purposes.)
If the function returns null, the mapping is removed (or
remains absent if initially absent). If the function itself throws an
(unchecked) exception, the exception is rethrown, and the current mapping
is left unchanged.
public V computeIfAbsent(K key, Function<? super K,? extends V> remappingFunction)
java.util.Mapnull), attempts to compute its value using the given mapping
function and enters it into this map unless null.
If the function returns null no mapping is recorded. If
the function itself throws an (unchecked) exception, the
exception is rethrown, and no mapping is recorded. The most
common usage is to construct a new object serving as an initial
mapped value or memoized result, as in:
map.computeIfAbsent(key, k -> new Value(f(k)));
Or to implement a multi-value map, Map<K,Collection<V>>,
supporting multiple values per key:
map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
computeIfAbsent in interface Map<K extends Address,V>key - key with which the specified value is to be associatedremappingFunction - the function to compute a valuepublic V putIfAbsent(K key, V value)
java.util.Mapnull) associates it with the given value and returns
null, else returns the current value.putIfAbsent in interface Map<K extends Address,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keynull if there was no mapping for the key.
(A null return can also indicate that the map
previously associated null with the key,
if the implementation supports null values.)public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
java.util.MapIf the function returns null, the mapping is removed. If the
function itself throws an (unchecked) exception, the exception is
rethrown, and the current mapping is left unchanged.
computeIfPresent in interface Map<K extends Address,V>key - key with which the specified value is to be associatedremappingFunction - the function to compute a valuepublic boolean containsKey(Object key)
java.util.AbstractMapcontainsKey in interface Map<K extends Address,V>containsKey in class AbstractMap<K extends Address,V>key - key whose presence in this map is to be testedpublic boolean containsValue(Object value)
java.util.AbstractMapcontainsValue in interface Map<K extends Address,V>containsValue in class AbstractMap<K extends Address,V>value - value whose presence in this map is to be testedpublic V get(Object key)
java.util.AbstractMapnull if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key
k to a value v such that (key==null ? k==null :
key.equals(k)), then this method returns v; otherwise
it returns null. (There can be at most one such mapping.)
If this map permits null values, then a return value of
null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that the map
explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
public V put(K key, V value)
If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.
put in interface Map<K extends Address,V>put in class AbstractMap<K extends Address,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic V remove(Object key)
java.util.AbstractMap(key==null ? k==null : key.equals(k)), that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
public V getOrDefault(Object key, V defaultValue)
java.util.MapdefaultValue if this map contains no mapping for the key.getOrDefault in interface Map<K extends Address,V>key - the key whose associated value is to be returneddefaultValue - the default mapping of the keydefaultValue if this map contains no mapping for the keypublic void forEach(BiConsumer<? super K,? super V> action)
java.util.Mappublic void replaceAll(BiFunction<? super K,? super V,? extends V> function)
java.util.MapreplaceAll in interface Map<K extends Address,V>function - the function to apply to each entrypublic boolean remove(Object key, Object value)
java.util.Mappublic boolean replace(K key, V oldValue, V newValue)
java.util.Mappublic V replace(K key, V value)
java.util.Mapreplace in interface Map<K extends Address,V>key - key with which the specified value is associatedvalue - value to be associated with the specified keynull if there was no mapping for the key.
(A null return can also indicate that the map
previously associated null with the key,
if the implementation supports null values.)public int size()
hasRestrictedRange(),
in which case it is a linear time operation proportional to the number of mappings.public boolean isEmpty()
java.util.AbstractMappublic void clear()
java.util.AbstractMappublic int hashCode()
java.util.AbstractMapObject.hashCode().hashCode in interface Map<K extends Address,V>hashCode in class AbstractMap<K extends Address,V>Map.Entry.hashCode(),
Object.equals(Object),
Set.equals(Object)public AddressTrieMap<K,V> subMap(K fromKey, K toKey)
java.util.NavigableMapfromKey, inclusive, to toKey, exclusive. (If
fromKey and toKey are equal, the returned map
is empty.) The returned map is backed by this map, so changes
in the returned map are reflected in this map, and vice-versa.
The returned map supports all optional map operations that this
map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
Equivalent to subMap(fromKey, true, toKey, false).
subMap in interface NavigableMap<K extends Address,V>subMap in interface SortedMap<K extends Address,V>fromKey - low endpoint (inclusive) of the keys in the returned maptoKey - high endpoint (exclusive) of the keys in the returned mapfromKey, inclusive, to toKey, exclusivepublic AddressTrieMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
java.util.NavigableMapfromKey to toKey. If fromKey and
toKey are equal, the returned map is empty unless
fromInclusive and toInclusive are both true. The
returned map is backed by this map, so changes in the returned map are
reflected in this map, and vice-versa. The returned map supports all
optional map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside of its range, or to construct a
submap either of whose endpoints lie outside its range.
subMap in interface NavigableMap<K extends Address,V>fromKey - low endpoint of the keys in the returned mapfromInclusive - true if the low endpoint
is to be included in the returned viewtoKey - high endpoint of the keys in the returned maptoInclusive - true if the high endpoint
is to be included in the returned viewfromKey to toKeypublic AddressTrieMap<K,V> headMap(K toKey)
java.util.NavigableMaptoKey. The returned map is backed
by this map, so changes in the returned map are reflected in
this map, and vice-versa. The returned map supports all
optional map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
Equivalent to headMap(toKey, false).
public AddressTrieMap<K,V> headMap(K toKey, boolean inclusive)
java.util.NavigableMapinclusive is true) toKey. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
headMap in interface NavigableMap<K extends Address,V>toKey - high endpoint of the keys in the returned mapinclusive - true if the high endpoint
is to be included in the returned viewinclusive is true) toKeypublic AddressTrieMap<K,V> tailMap(K fromKey)
java.util.NavigableMapfromKey. The returned map is
backed by this map, so changes in the returned map are
reflected in this map, and vice-versa. The returned map
supports all optional map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
Equivalent to tailMap(fromKey, true).
tailMap in interface NavigableMap<K extends Address,V>tailMap in interface SortedMap<K extends Address,V>fromKey - low endpoint (inclusive) of the keys in the returned mapfromKeypublic AddressTrieMap<K,V> tailMap(K fromKey, boolean inclusive)
java.util.NavigableMapinclusive is true) fromKey. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
tailMap in interface NavigableMap<K extends Address,V>fromKey - low endpoint of the keys in the returned mapinclusive - true if the low endpoint
is to be included in the returned viewinclusive is true) fromKeypublic Map.Entry<K,V> firstEntry()
java.util.NavigableMapnull if the map is empty.firstEntry in interface NavigableMap<K extends Address,V>null if this map is emptypublic K firstKey()
java.util.SortedMappublic Map.Entry<K,V> lastEntry()
java.util.NavigableMapnull if the map is empty.lastEntry in interface NavigableMap<K extends Address,V>null if this map is emptypublic K lastKey()
java.util.SortedMappublic Map.Entry<K,V> lowerEntry(K key)
java.util.NavigableMapnull if there is
no such key.lowerEntry in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic K lowerKey(K key)
java.util.NavigableMapnull if there is no such key.lowerKey in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic Map.Entry<K,V> floorEntry(K key)
java.util.NavigableMapnull if there
is no such key.floorEntry in interface NavigableMap<K extends Address,V>key - the keykey, or null if there is no such keypublic K floorKey(K key)
java.util.NavigableMapnull if there is no such key.floorKey in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic Map.Entry<K,V> ceilingEntry(K key)
java.util.NavigableMapnull if
there is no such key.ceilingEntry in interface NavigableMap<K extends Address,V>key - the keykey, or null if there is no such keypublic K ceilingKey(K key)
java.util.NavigableMapnull if there is no such key.ceilingKey in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic Map.Entry<K,V> higherEntry(K key)
java.util.NavigableMapnull if there
is no such key.higherEntry in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic K higherKey(K key)
java.util.NavigableMapnull if there is no such key.higherKey in interface NavigableMap<K extends Address,V>key - the keykey,
or null if there is no such keypublic Map.Entry<K,V> pollFirstEntry()
java.util.NavigableMapnull if the map is empty.pollFirstEntry in interface NavigableMap<K extends Address,V>null if this map is emptypublic Map.Entry<K,V> pollLastEntry()
java.util.NavigableMapnull if the map is empty.pollLastEntry in interface NavigableMap<K extends Address,V>null if this map is emptypublic boolean equals(Object o)
java.util.AbstractMappublic AddressTrieMap<K,V> clone()
public Comparator<K> comparator()
java.util.SortedMapnull if this map uses the natural ordering of its keys.comparator in interface SortedMap<K extends Address,V>null if this map uses the natural ordering
of its keyspublic String toTrieString()
public AddressTrieMap<K,V> subMapFromKeysContainedBy(K addr)
If the sub-map would be the same size as this map, then this map is returned. The sub-map will the same backing trie as this map.
addr - public AddressTrieMap<K,V> subMapFromKeysContaining(K addr)
If the sub-map would be the same size as this map, then this map is returned. Otherwise, the sub-map is backed by a new trie.
addr - public boolean keyContains(K addr)
addr -