Package generic

# Interface Span<N,S extends Span<N,S>>

Type Parameters:
  `N` - the type of endpoints
  `S` - 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`

public interface Span<N,S extends Span<N,S>> extends Comparable<S>
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, as in `End`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `Span.DefaultSpanMap<N,S extends Span<N,S>,V>`
  The default implementation of `Span.SpanMap` and `Span.MutableSpanMap` using an interval tree
  `static class`
  `Span.DefaultSpanSet<N,S extends Span<N,S>>`
  The default implementation of `Span.SpanSet` and `Span.MutableSpanSet` using an interval tree
  `static interface`
  `Span.Domain<N,S extends Span<N,S>>`
  The (discrete) domain of endpoints for a span
  `static interface`
  `Span.Empty<N,S extends Span<N,S>>`
  A mix-in interface for empty spans
  `static interface`
  `Span.MutableSpanMap<N,S extends Span<N,S>,V>`
  An abstract interface for a mutable `Span.SpanMap`
  `static interface`
  `Span.MutableSpanSet<N,S extends Span<N,S>>`
  An abstract interface for a mutable `Span.SpanSet`
  `static interface`
  `Span.SpanMap<N,S extends Span<N,S>,V>`
  An abstract interface for an immutable map of spans to values
  `static class`
  `Span.SpanMapSetter<E,N,S extends Span<N,S>,V>`
  A partial implementation of `RangeMapSetter` for `Span`s.
  `static interface`
  `Span.SpanSet<N,S extends Span<N,S>>`
  An abstract interface for a set of spans

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default S`
  `bound(S s)`
  Compute the bound of this span and another
  `default int`
  `compareTo(S that)`
  `default boolean`
  `contains(N n)`
  Check if this span contains the given value
  `Span.Domain<N,S>`
  `domain()`
  Get the domain of this span's endpoints
  `default String`
  `doToString()`
  `default boolean`
  `encloses(S s)`
  Check if this span encloses a given span
  `default S`
  `intersect(S s)`
  Compute the intersection of this span and another
  `default boolean`
  `intersects(S s)`
  Check if this span intersects a given span
  `default boolean`
  `isEmpty()`
  Check if this span is empty
  `N`
  `max()`
  Get the upper endpoint
  `default boolean`
  `maxIsFinite()`
  Check if the upper endpoint excludes the domain maximum
  `N`
  `min()`
  Get the lower enpdoint
  `default boolean`
  `minIsFinite()`
  Check if the lower endpoint excludes the domain minimum
  `default List<S>`
  `subtract(S s)`
  Subtract a span from this span

- ## Method Details

  - ### doToString

    default String doToString()

  - ### 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:
      - `isEmpty()`

  - ### max

    N max()
    Get the upper endpoint
    Returns:
      the upper endpoint
    Throws:
      `NoSuchElementException` - if the span is empty
    See Also:
      - `isEmpty()`

  - ### 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

    default boolean contains(N n)
    Check if this span contains the given value
    Parameters:
      `n` - the value
    Returns:
      true if n is contained in this span

  - ### intersect

    default S intersect(S s)
    Compute the intersection of this span and another
    Parameters:
      `s` - another span
    Returns:
      the intersection, possibly empty
    See Also:
      - `Span.Domain.intersect(Span, Span)`

  - ### intersects

    default boolean intersects(S s)
    Check if this span intersects a given span
    Parameters:
      `s` - another span
    Returns:
      true if they intersect
    See Also:
      - `Span.Domain.intersects(Span, Span)`

  - ### encloses

    default boolean encloses(S s)
    Check if this span encloses a given span
    Parameters:
      `s` - another span
    Returns:
      true if this encloses the given span

  - ### bound

    default S bound(S s)
    Compute the bound of this span and another
    Parameters:
      `s` - another span
    Returns:
      the bound
    See Also:
      - `Span.Domain.bound(Span, Span)`

  - ### subtract

    default List<S> subtract(S s)
    Subtract a span from this span
    Parameters:
      `s` - the span to subtract
    Returns:
      0, 1, or 2 spans resulting from the subtraction

  - ### compareTo

    default int compareTo(S that)
    Specified by:
      `compareTo` in interface `Comparable<N>`