Interface AddressSet<A extends Address<A>>
- Type Parameters:
A
- address type
- All Superinterfaces:
Iterable<A>
Discrete set interface of zero to Family.max()
Address
es.
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.
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 Summary
Modifier and TypeMethodDescriptiondefault boolean
Tests ifRange.contains(Address)
is true for any of the constituentranges()
.boolean
int
hashCode()
Range
Contract:first().hashCode() * 31 + last().hashCode()
ranges()
ConstituentRange
s.default BigInteger
size()
Number of uniqueAddress
es.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
equals
Range
Contract: other isRange
instance andRange.first()
&Range.last()
are equal.General
AddressSet
Contract: returns true if instance ofAddressSet
and all constituentranges()
are identical. -
hashCode
int hashCode()Range
Contract:first().hashCode() * 31 + last().hashCode()
General
AddressSet
Contract:ranges().mapToInt(Object::hashCode).reduce(0, (n, r) -> n * 31 + r)
-
ranges
Constituent
Range
s.Adjacent or overlapping ranges MUST be combined into a single
Range
. Elements MUST be produced from leastAddress
to greatest.A
Stream
ofAddress
values can be obtained withranges().flatMap(Range::stream)
. AStream
ofBlock
s can be obtained withranges().flatMap(Range::blocks)
.- Returns:
- constituent ranges
-
contains
Tests ifRange.contains(Address)
is true for any of the constituentranges()
.- Parameters:
address
- candidate- Returns:
- true if the given address is present
-
size
Number of uniqueAddress
es. The cardinality of the set.- Returns:
- count
-