Class IntegerInterval

java.lang.Object
org.episteme.core.mathematics.algebra.intervals.IntegerInterval

public final class IntegerInterval extends Object
Factory and convenience class for creating intervals over Integer numbers.

Integers include all whole numbers: ..., -3, -2, -1, 0, 1, 2, 3, ... Unlike real intervals, Integer intervals are discrete (countable), enabling:

  • Iteration over all elements
  • Exact element count
  • Successor/predecessor operations

This differs from NaturalInterval by supporting negative values.

* @author Silvere Martin-Michiellot
Since:
1.0
Author:
Gemini AI (Google DeepMind)
  • Method Details

    • closed

      public static RingIntervalND<Integer> closed(Integer min, Integer max)
      Creates a closed interval [min, max] over Integer numbers.
      Parameters:
      min - the minimum value (inclusive)
      max - the maximum value (inclusive)
      Returns:
      a closed interval containing all integers from min to max
      Throws:
      IllegalArgumentException - if min > max
    • closed

      public static RingIntervalND<Integer> closed(long min, long max)
      Creates a closed interval [min, max] from long values.
    • closedOpen

      public static RingIntervalND<Integer> closedOpen(Integer min, Integer max)
      Creates a half-open interval [min, max) over Integer numbers.
      Parameters:
      min - the minimum value (inclusive)
      max - the maximum value (exclusive)
      Returns:
      a half-open interval
    • closedOpen

      public static RingIntervalND<Integer> closedOpen(long min, long max)
      Creates a half-open interval [min, max) from long values.
    • open

      public static RingIntervalND<Integer> open(Integer min, Integer max)
      Creates an open interval (min, max) over Integer numbers.
    • open

      public static RingIntervalND<Integer> open(long min, long max)
      Creates an open interval (min, max) from long values.
    • iterator

      public static Iterator<Integer> iterator(Interval<Integer> interval)
      Returns an iterator over all Integer numbers in the interval.

      For closed intervals [a, b], iterates a, a+1, ..., b. For half-open [a, b), iterates a, a+1, ..., b-1.

      Parameters:
      interval - the interval to iterate
      Returns:
      an iterator over the Integer numbers in the interval
    • stream

      public static Stream<Integer> stream(Interval<Integer> interval)
      Returns a stream of all Integer numbers in the interval.
      Parameters:
      interval - the interval to stream
      Returns:
      a Stream of Integer numbers
    • size

      public static long size(Interval<Integer> interval)
      Returns the number of Integer numbers in the interval.
      Parameters:
      interval - the interval
      Returns:
      the count of elements (cardinality)
    • isEmpty

      public static boolean isEmpty(Interval<Integer> interval)
      Returns whether the interval is empty.
      Parameters:
      interval - the interval to check
      Returns:
      true if the interval contains no Integer numbers
    • singleton

      public static RingIntervalND<Integer> singleton(Integer value)
      Creates an interval containing a single Integer number.
      Parameters:
      value - the singleton value
      Returns:
      a closed interval [value, value]
    • singleton

      public static RingIntervalND<Integer> singleton(long value)
      Creates an interval containing a single Integer number from a long.
    • range

      public static RingIntervalND<Integer> range(long n)
      Creates a range from 0 to n-1 (useful for array indexing).
      Parameters:
      n - the exclusive upper bound
      Returns:
      a half-open interval [0, n)
    • range

      public static RingIntervalND<Integer> range(long start, long end)
      Creates a range from start to end-1 (Python-style range).
      Parameters:
      start - the inclusive lower bound
      end - the exclusive upper bound
      Returns:
      a half-open interval [start, end)