Class Range<T extends Comparable<T>>

java.lang.Object
gov.nasa.jpl.aerie.scheduler.Range<T>
All Implemented Interfaces:
Comparable<Range<T>>

public class Range<T extends Comparable<T>> extends Object implements Comparable<Range<T>>
represents an inclusive interval of partially ordered values the semantics of a range include both of its endpoints, as well as any value that compares greater than or equal to the minimum and less than or equal to the maximum ranges may have the same minimum and maximum value, in which case it admits only values that compare equal to those bounds
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(T singleton)
    creates a new range that reprsents only a single allowed value
    Range(T minimum, T maximum)
    creates a new range with given minimum and maximum bounds the range admits both endpoints and any value between them the minimum and maximum may be the same value
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    contains(Range<T> otherRange)
     
    boolean
    contains(T probe)
    determines if this range admits the queried value the range inclusively admits values equal to its upper and lower bounds as well as any value between the two
    envelop(Range<T> range1, Range<T> range2)
    return a range enveloping the two passed ranges
    boolean
     
    boolean
    equalsRange(Range<T> otherRange)
     
    fetch the inclusive upper bound of the range
    fetch the inclusive lower bound of the range
    int
     
    intersect(Range<T> otherRange)
    Returns new range from intersection with other range
    boolean
    isAdjacent(Range<T> otherRange)
     
    boolean
    isAfter(Range<T> otherRange)
     
    boolean
    isBefore(Range<T> otherRange)
     
    boolean
     
    static <T extends Comparable<T>>
    Range<T>
    of(T minimum, T maximum)
    factory creates a new range with given minimum and maximum bounds the range admits both endpoints and any value between them the minimum and maximum may be the same value
     
    subtract(Range<T> otherRange)
     
    gives a simple human-readable reprsentation of the closed interval range

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Range

      public Range(T singleton)
      creates a new range that reprsents only a single allowed value
      Parameters:
      singleton - IN the single value that is admitted by the new range
    • Range

      public Range(T minimum, T maximum)
      creates a new range with given minimum and maximum bounds the range admits both endpoints and any value between them the minimum and maximum may be the same value
      Parameters:
      minimum - IN the inclusive minimum bound of the new range
      maximum - IN the inclusive maximum bound of the new range
  • Method Details

    • isSingleton

      public boolean isSingleton()
    • of

      public static <T extends Comparable<T>> Range<T> of(T minimum, T maximum)
      factory creates a new range with given minimum and maximum bounds the range admits both endpoints and any value between them the minimum and maximum may be the same value
      Parameters:
      minimum - IN the inclusive minimum bound of the new range
      maximum - IN the inclusive maximum bound of the new range
    • getMinimum

      public T getMinimum()
      fetch the inclusive lower bound of the range
      Returns:
      the inclusive lower bound of the range
    • getMaximum

      public T getMaximum()
      fetch the inclusive upper bound of the range
      Returns:
      the inclusive upper bound of the range
    • contains

      public boolean contains(T probe)
      determines if this range admits the queried value the range inclusively admits values equal to its upper and lower bounds as well as any value between the two
      Parameters:
      probe - IN the value to test if it is in the range
      Returns:
      true iff the queried value is within the inclusive range, false otherwise
    • subsetFullyContained

      public List<Range<T>> subsetFullyContained(List<Range<T>> windows)
    • intersect

      public Range<T> intersect(Range<T> otherRange)
      Returns new range from intersection with other range
      Parameters:
      otherRange - range to be intersected with
      Returns:
      a new range from intersection with otherRange
    • subtract

      public List<Range<T>> subtract(Range<T> otherRange)
    • isBefore

      public boolean isBefore(Range<T> otherRange)
    • isAfter

      public boolean isAfter(Range<T> otherRange)
    • isAdjacent

      public boolean isAdjacent(Range<T> otherRange)
    • envelop

      public Range<T> envelop(Range<T> range1, Range<T> range2)
      return a range enveloping the two passed ranges
      Parameters:
      range1 - the first range to consider
      range2 - the second range to consider
      Returns:
      a range enveloping the two passed ranges
    • contains

      public boolean contains(Range<T> otherRange)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • equalsRange

      public boolean equalsRange(Range<T> otherRange)
    • toString

      public String toString()
      gives a simple human-readable reprsentation of the closed interval range
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Range<T> o)
      Specified by:
      compareTo in interface Comparable<T extends Comparable<T>>