Package generic
Interface Span<N,S extends Span<N,S>>
- Type Parameters:
N
- the type of endpointsS
- the type of spans (recursive)
- All Superinterfaces:
Comparable<S>
- All Known Subinterfaces:
Span.Empty<N,
,S> ULongSpan
- All Known Implementing Classes:
ULongSpan.Empty
,ULongSpan.Impl
A (closed) interval
An interval-like type may implement this interface in order to obtain a near out-of-box
implementation of a map and/or set of spans. Common operations, such as computing intersections
and bounds, are provided. Similarly, spans are automatically coalesced when present in sets and
maps. The main requirement is that the span define the domain of its endpoints. The domain can
impose behaviors and properties that aren't otherwise present on the type of endpoints. For
example, the domain may be Long
s, but using unsigned attributes. The domain also provides
a factory for new spans. While nominally, this only supports closed intervals, the domain can
define a custom endpoint type to obtain mixed intervals.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
The default implementation ofSpan.SpanMap
andSpan.MutableSpanMap
using an interval treestatic class
The default implementation ofSpan.SpanSet
andSpan.MutableSpanSet
using an interval treestatic interface
The (discrete) domain of endpoints for a spanstatic interface
A mix-in interface for empty spansstatic interface
An abstract interface for a mutableSpan.SpanMap
static interface
An abstract interface for a mutableSpan.SpanSet
static interface
An abstract interface for an immutable map of spans to valuesstatic class
A partial implementation ofRangeMapSetter
forSpan
s.static interface
An abstract interface for a set of spans -
Method Summary
Modifier and TypeMethodDescriptiondefault S
Compute the bound of this span and anotherdefault int
default boolean
Check if this span contains the given valuedomain()
Get the domain of this span's endpointsdefault String
Provides a defaultObject.toString()
implementationdefault boolean
Check if this span encloses a given spandefault S
Compute the intersection of this span and anotherdefault boolean
intersects
(S s) Check if this span intersects a given spandefault boolean
isEmpty()
Check if this span is emptymax()
Get the upper endpointdefault boolean
Check if the upper endpoint excludes the domain maximummin()
Get the lower enpdointdefault boolean
Check if the lower endpoint excludes the domain minimumSubtract a span from this span
-
Method Details
-
doToString
Provides a defaultObject.toString()
implementation- Returns:
- the string
-
domain
Span.Domain<N,S> domain()Get the domain of this span's endpoints- Returns:
- the domain
-
min
N min()Get the lower enpdoint- Returns:
- the lower endpoint
- Throws:
NoSuchElementException
- if the span is empty- See Also:
-
max
N max()Get the upper endpoint- Returns:
- the upper endpoint
- Throws:
NoSuchElementException
- if the span is empty- See Also:
-
minIsFinite
default boolean minIsFinite()Check if the lower endpoint excludes the domain minimum- Returns:
- true if min is not the domain min
-
maxIsFinite
default boolean maxIsFinite()Check if the upper endpoint excludes the domain maximum- Returns:
- true if max is not the domain max
-
isEmpty
default boolean isEmpty()Check if this span is empty- Returns:
- true if empty
-
contains
Check if this span contains the given value- Parameters:
n
- the value- Returns:
- true if n is contained in this span
-
intersect
Compute the intersection of this span and another- Parameters:
s
- another span- Returns:
- the intersection, possibly empty
- See Also:
-
intersects
Check if this span intersects a given span- Parameters:
s
- another span- Returns:
- true if they intersect
- See Also:
-
encloses
Check if this span encloses a given span- Parameters:
s
- another span- Returns:
- true if this encloses the given span
-
bound
Compute the bound of this span and another- Parameters:
s
- another span- Returns:
- the bound
- See Also:
-
subtract
Subtract a span from this span- Parameters:
s
- the span to subtract- Returns:
- 0, 1, or 2 spans resulting from the subtraction
-
compareTo
- Specified by:
compareTo
in interfaceComparable<N>
-