Class Interval

java.lang.Object
mpicbg.stitching.fusion.Interval

public class Interval extends Object
A range on the number line with a min() and max() point.
Author:
Mark Hiner hinerm at gmail.com
  • Constructor Summary

    Constructors
    Constructor
    Description
    Interval(int... points)
    Constructs a new Interval using the smallest and largest values in the provided points.
    Interval(Interval interval)
    Copying constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    contains(int point)
     
    boolean
    Check to see if another interval is the same as this interval.
    boolean
    Determines if this interval has an intersection with another interval.
    int
    max()
     
    int
    min()
     
    boolean
    setMax(int max)
    Update the end position of this interval.
    boolean
    setMin(int min)
    Update the start position of this interval.
     

    Methods inherited from class java.lang.Object

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

    • Interval

      public Interval(int... points)
      Constructs a new Interval using the smallest and largest values in the provided points.
    • Interval

      public Interval(Interval interval)
      Copying constructor
  • Method Details

    • setMin

      public boolean setMin(int min)
      Update the start position of this interval. If after this setting, min > max, sets max = min.
      Returns:
      true if the max was also modified during this call
    • setMax

      public boolean setMax(int max)
      Update the end position of this interval. If after this setting, max < min, sets min = max.
      Returns:
      true if the min was also modified during this call
    • min

      public int min()
      Returns:
      Start position for this interval
    • max

      public int max()
      Returns:
      End position for this interval
    • contains

      public int contains(int point)
      Returns:
      -1 if this interval is completely to the left of the point. 1 if this interval is completely to the right of the point. 0 if the interval intersects (contains) the point.
    • intersects

      public boolean intersects(Interval other)
      Determines if this interval has an intersection with another interval.
    • equalsInterval

      public boolean equalsInterval(Interval other)
      Check to see if another interval is the same as this interval.
    • toString

      public String toString()
      Overrides:
      toString in class Object