Interface AddressSet<A extends Addr<A>>

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

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

Discrete ordered set interface of zero to Family.max() Addres.

AddressSet is tightly coupled to Range and Block. Implementations MUST be immutable. Iteration methods MUST produce values from least to greatest.

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 Addr to greatest.

      A Stream of Addr 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(Addr<?> address)
      Tests if Range.contains(Addr) is true for any of the constituent ranges().
      Parameters:
      address - candidate (cannot be null)
      Returns:
      true if the given address is present
    • size

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

      default boolean isEmpty()
      Tests for the empty set.
      Returns:
      true if empty