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 TypeMethodDescriptionboundingInterval(Interval<T> other) Returns the smallest interval containing both this and another interval.booleanChecks if this interval contains another interval entirely.booleanChecks if a point is contained in this interval.intReturns 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.intersection(Interval<T> other) Returns the intersection of this interval with another.default booleanisClosed()Returns whether this interval is closed in all dimensions.booleanisClosedLeft(int dimension) Returns whether the lower endpoint is closed in the specified dimension.booleanisClosedRight(int dimension) Returns whether the upper endpoint is closed in the specified dimension.booleanisEmpty()Returns whether this interval is empty.default booleanisOpen()Returns whether this interval is open in all dimensions.notation()Returns the standard mathematical notation for this interval.booleanChecks 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
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
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
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
-
overlaps
-
intersection
-
boundingInterval
-
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]")
-