Module inet.ipaddr

Class AssociativeAddressTrie<K extends Address,V>

java.lang.Object
inet.ipaddr.format.util.AddressTrie<K>
inet.ipaddr.format.util.AssociativeAddressTrie<K,V>
Type Parameters:
K - the type of the address keys
V - the type of the associated values
All Implemented Interfaces:
AddressTrieOps<K>, AddressTrieOps.AddressTrieAddOps<K>, AddressTrieOps.AssociativeAddressTrieOps<K,V>, AddressTrieOps.AssociativeAddressTriePutOps<K,V>, TreeOps<K>, Serializable, Cloneable, Iterable<K>
Direct Known Subclasses:
IPv4AddressAssociativeTrie, IPv6AddressAssociativeTrie, MACAddressAssociativeTrie

public abstract class AssociativeAddressTrie<K extends Address,V> extends AddressTrie<K> implements AddressTrieOps.AssociativeAddressTriePutOps<K,V>
An address trie in which each node is associated with a value.

The trie can also be used as the backing data structure for a AddressTrieMap which is a NavigableMap. Unlike TreeMap this data structure provides access to the nodes and the associated sub-trie with each node as the sub-trie root, which corresponds with their associated CIDR prefix block subnets.

Use one of the put methods to add nodes with values or to change the values of existing nodes. You can also add to the trie using AddressTrie.add(Address) and the associated value will be null.

Mapped tries are thread-safe when not being modified (ie mappings added or removed), but are not thread-safe when a thread is modifying the trie.

To make them thread-safe during addition and removal you could access them through the collection provided by Collections.synchronizedMap(java.util.Map<K, V>), applied to the map from asMap()

Author:
scfoley
See Also: