Class IntervalSet<T extends java.lang.Comparable<T>>


  • public class IntervalSet<T extends java.lang.Comparable<T>>
    extends java.lang.Object
    An immutable set of closed intervals, stored in normalized form (i.e. where overlapping intervals are converted to a single interval covering both). The set is stored as a sorted map from interval starts to the corresponding end. The map satisfies curr().getKey() <= curr().getValue() < next().getKey()
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IntervalSet.Builder<T extends java.lang.Comparable<T>>
      Builder of interval sets, applying the necessary normalization while adding ranges.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntervalSet​(T start, T end)
      Construct new set containing the interval with the given start and end position.
    • Constructor Detail

      • IntervalSet

        public IntervalSet​(T start,
                           T end)
        Construct new set containing the interval with the given start and end position.
    • Method Detail

      • empty

        public static <T extends java.lang.Comparable<T>> IntervalSet<T> empty()
      • contains

        public boolean contains​(T position)
      • isEmpty

        public boolean isEmpty()
      • lowerBound

        public java.util.Optional<T> lowerBound()
      • upperBound

        public java.util.Optional<T> upperBound()
      • starts

        public java.util.Collection<T> starts()
      • ends

        public java.util.Collection<T> ends()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object