Module inet.ipaddr

Class AddressTrieSet<E extends Address>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
inet.ipaddr.format.util.AddressTrieSet<E>
Type Parameters:
E - the address type
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, NavigableSet<E>, SequencedCollection<E>, SequencedSet<E>, Set<E>, SortedSet<E>

public class AddressTrieSet<E extends Address> extends AbstractSet<E> implements NavigableSet<E>, Cloneable, Serializable
Wraps a AddressTrie to view it as a Java Collections Framework set, implementing the Set, SortedSet and NavigableSet interfaces.

Like TreeSet, this set is backed by a binary tree and implements the same interfaces that TreeSet does. But there are some significant differences between the two binary tree implementations. See AddressTrieMap for a description of some of the differences. TreeMap is backed by a TreeSet and AddressTrieMap is backed by an AddressTrie just like AddressTrie, so all of the same implementation comparisons apply equally between the map implementations and the set implementations.

With the trie set, 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 collection, address instances that are not individual address or prefix block subnets, you can use TreeSet or any other Java collections framework set to store addresses of any type, or addresses of different versions or types in the same set, 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.

Author:
scfoley
See Also: