Interface Interval<T extends Comparable<T>>

All Known Implementing Classes:
FieldIntervalND, OrderedSetIntervalND, RingIntervalND

public interface Interval<T extends Comparable<T>>
Interface for N-dimensional intervals over ordered sets.

An interval represents a contiguous hyper-rectangular region in an ordered space. This is the base interface for intervals, requiring only that elements be comparable. More specialized intervals (over Rings, Fields) extend this interface with additional capabilities.

Supports various endpoint configurations:

  • [a,b] - closed (includes endpoints)
  • (a,b) - open (excludes endpoints)
  • [a,b) or (a,b] - half-open

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the smallest interval containing both this and another interval.
    boolean
    Checks if this interval contains another interval entirely.
    boolean
    contains(T[] point)
    Checks if a point is contained in this interval.
    int
    Returns the number of dimensions of this interval.
    getMax(int dimension)
    Returns the upper bound in the specified dimension.
    getMin(int dimension)
    Returns the lower bound in the specified dimension.
    Returns the intersection of this interval with another.
    default boolean
    Returns whether this interval is closed in all dimensions.
    boolean
    isClosedLeft(int dimension)
    Returns whether the lower endpoint is closed in the specified dimension.
    boolean
    isClosedRight(int dimension)
    Returns whether the upper endpoint is closed in the specified dimension.
    boolean
    Returns whether this interval is empty.
    default boolean
    Returns whether this interval is open in all dimensions.
    Returns the standard mathematical notation for this interval.
    boolean
    Checks if this interval overlaps with another.
  • Method Details

    • getDimension

      int getDimension()
      Returns the number of dimensions of this interval.
      Returns:
      the dimensionality (1 for 1D intervals, N for ND)
    • getMin

      T getMin(int dimension)
      Returns the lower bound in the specified dimension.
      Parameters:
      dimension - the dimension index (0-based)
      Returns:
      the minimum value in that dimension
      Throws:
      IndexOutOfBoundsException - if dimension is out of range
    • getMax

      T getMax(int dimension)
      Returns the upper bound in the specified dimension.
      Parameters:
      dimension - the dimension index (0-based)
      Returns:
      the maximum value in that dimension
      Throws:
      IndexOutOfBoundsException - if dimension is out of range
    • isClosedLeft

      boolean isClosedLeft(int dimension)
      Returns whether the lower endpoint is closed in the specified dimension.
      Parameters:
      dimension - the dimension index (0-based)
      Returns:
      true if the interval includes its minimum value in that dimension
    • isClosedRight

      boolean isClosedRight(int dimension)
      Returns whether the upper endpoint is closed in the specified dimension.
      Parameters:
      dimension - the dimension index (0-based)
      Returns:
      true if the interval includes its maximum value in that dimension
    • contains

      boolean contains(T[] point)
      Checks if a point is contained in this interval.
      Parameters:
      point - array of coordinates (must match dimensionality)
      Returns:
      true if the point is within the interval bounds
      Throws:
      IllegalArgumentException - if point dimensionality doesn't match
    • contains

      boolean contains(Interval<T> other)
      Checks if this interval contains another interval entirely.
      Parameters:
      other - the interval to check
      Returns:
      true if other is a subset of this interval
    • overlaps

      boolean overlaps(Interval<T> other)
      Checks if this interval overlaps with another.
      Parameters:
      other - the interval to check
      Returns:
      true if the intervals share at least one point
    • intersection

      Interval<T> intersection(Interval<T> other)
      Returns the intersection of this interval with another.
      Parameters:
      other - the interval to intersect with
      Returns:
      the intersection interval, or null if empty
    • boundingInterval

      Interval<T> boundingInterval(Interval<T> other)
      Returns the smallest interval containing both this and another interval.
      Parameters:
      other - the interval to union with
      Returns:
      the bounding interval
    • isEmpty

      boolean isEmpty()
      Returns whether this interval is empty.
      Returns:
      true if the interval contains no elements
    • isOpen

      default boolean isOpen()
      Returns whether this interval is open in all dimensions.
      Returns:
      true if all endpoints are open
    • isClosed

      default boolean isClosed()
      Returns whether this interval is closed in all dimensions.
      Returns:
      true if all endpoints are closed
    • notation

      String notation()
      Returns the standard mathematical notation for this interval.
      Returns:
      interval notation string (e.g., "[0,1] × (2,3]")