Interface AddressSet<A extends Address<A>>

Type Parameters:
A - address type
All Superinterfaces:
Iterable<A>
All Known Subinterfaces:
Block<A>, Range<A>

public interface AddressSet<A extends Address<A>> extends Iterable<A>

Discrete set interface of zero to Family.max() Addresses.

AddressSet is tightly coupled to Range and Block. Implementations MUST be immutable. Iterable.iterator() MUST produce values from least to greatest. This type is always a sorted set.

AddressSet Contracts
Interface Must Be Implemented When Set...
Block ...forms a valid RFC4632 CIDR block.
Range ...is contiguous range.
AddressSet ...is made up of non-contiguous ranges or is the empty set.
  • Method Details

    • equals

      boolean equals(Object other)

      Range Contract: other is Range instance and Range.first() & Range.last() are equal.

      General AddressSet Contract: returns true if instance of AddressSet and all constituent ranges() are identical.

      Overrides:
      equals in class Object
      Parameters:
      other - other
      Returns:
      true if equal
    • hashCode

      int hashCode()

      Range Contract: first().hashCode() * 31 + last().hashCode()

      General AddressSet Contract: ranges().mapToInt(Object::hashCode).reduce(0, (n, r) -> n * 31 + r)

      Overrides:
      hashCode in class Object
      Returns:
      size hash
    • ranges

      Stream<Range<A>> ranges()

      Constituent Ranges.

      Adjacent or overlapping ranges MUST be combined into a single Range. Elements MUST be produced from least Address to greatest.

      A Stream of Address values can be obtained with ranges().flatMap(Range::stream). A Stream of Blocks can be obtained with ranges().flatMap(Range::blocks).

      Returns:
      constituent ranges
    • contains

      default boolean contains(Address<?> address)
      Tests if Range.contains(Address) is true for any of the constituent ranges().
      Parameters:
      address - candidate
      Returns:
      true if the given address is present
    • size

      default BigInteger size()
      Number of unique Addresses. The cardinality of the set.
      Returns:
      count