Package uk.ipfreely.sets
Interface Range<A extends Address<A>>
- Type Parameters:
A
- address type
- All Superinterfaces:
AddressSet<A>
,Iterable<A>
- All Known Subinterfaces:
Block<A>
AddressSet
interface that forms contiguous range of one or more Address
es.
See AddressSet
for implementation contract.
Implementations are always contiguous lists.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Tests if the last value in either range is one less than the first value of the other.blocks()
Streams arbitrary range as valid CIDR blocks.Combines two ranges into a single range using the least and greatest values from each.default boolean
default boolean
contiguous
(Range<A> r) Tests if this range can create a contiguous range with another.first()
Least element in the range.default boolean
intersects
(Range<A> r) Tests if there is any overlap in the address ranges.iterator()
All addresses in the range.last()
Greatest element in the range.ranges()
ConstituentRange
s.default BigInteger
size()
Number ofAddress
es in range.default Spliterator
<A> stream()
All addresses in the range.Methods inherited from interface uk.ipfreely.sets.AddressSet
equals, hashCode
-
Method Details
-
first
A first()Least element in the range.- Returns:
- first
-
last
A last()Greatest element in the range.- Returns:
- last
-
ranges
Description copied from interface:AddressSet
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)
.- Specified by:
ranges
in interfaceAddressSet<A extends Address<A>>
- Returns:
- constituent ranges
-
size
Number ofAddress
es in range. -
contains
- Specified by:
contains
in interfaceAddressSet<A extends Address<A>>
- Parameters:
address
- the address to test- Returns:
- true if this sequence contains the given IP address
-
iterator
All addresses in the range. -
spliterator
Default
Spliterator.characteristics()
:Spliterator.IMMUTABLE
;Spliterator.DISTINCT
;Spliterator.ORDERED
;Spliterator.SORTED
;Spliterator.NONNULL
.Spliterator.trySplit()
is implemented.- Specified by:
spliterator
in interfaceIterable<A extends Address<A>>
- Returns:
- instance
-
stream
All addresses in the range.- Returns:
- from first to last
-
blocks
Streams arbitrary range as valid CIDR blocks.- Returns:
- stream
-
contiguous
Tests if this range can create a contiguous range with another. That is, eitherintersects(Range)
oradjacent(Range)
are true.- Parameters:
r
- another range- Returns:
- true if contiguous
-
intersects
Tests if there is any overlap in the address ranges.- Parameters:
r
- another range- Returns:
- true on intersection
-
adjacent
Tests if the last value in either range is one less than the first value of the other.- Parameters:
r
- another range- Returns:
- true if adjacent
-
combine
Combines two ranges into a single range using the least and greatest values from each. The ranges do not have to be contiguous - this is not a union method.- Parameters:
other
- another range- Returns:
- new range
- See Also:
-