Class IntegerInterval.Set

  • Enclosing class:
    IntegerInterval

    public static class IntegerInterval.Set
    extends java.lang.Object
    A mutable set of closed integer intervals, stored in normalized form (i.e. where overlapping intervals are converted to a single interval covering both). Thread-safe.
    • Constructor Summary

      Constructors 
      Constructor Description
      Set()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int start, int end)
      Adds an interval to the set, performing the necessary normalization.
      boolean covers​(int start, int end)
      Returns true if the set completely covers the given interval.
      boolean covers​(IntegerInterval iv)
      Returns true if the set completely covers the given interval.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      java.util.Collection<IntegerInterval> intervals()  
      int lowerBound()
      Returns a lower bound for the whole set.
      java.lang.String toString()  
      int upperBound()
      Returns an upper bound for the whole set.
      • Methods inherited from class java.lang.Object

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

      • Set

        public Set()
    • Method Detail

      • add

        public void add​(int start,
                        int end)
        Adds an interval to the set, performing the necessary normalization.
      • covers

        public boolean covers​(IntegerInterval iv)
        Returns true if the set completely covers the given interval.
      • covers

        public boolean covers​(int start,
                              int end)
        Returns true if the set completely covers the given interval.
      • lowerBound

        public int lowerBound()
        Returns a lower bound for the whole set. Will throw if set is not empty.
      • upperBound

        public int upperBound()
        Returns an upper bound for the whole set. Will throw if set is not empty.
      • 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
      • toString

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