Class Range

java.lang.Object
info.monitorenter.util.Range
All Implemented Interfaces:
Serializable

public class Range extends Object implements Serializable
A simple data structure that defines a minimum and a maximum and knows, what lies within it and what not.

Author:
Achim Westermann
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
    The upper bound of this range.
    protected double
    The lower bound of this range.
    static final Range
    The unbounded range.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(double min, double max)
    Constructs a new Range that covers the given bounds.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    ensureContained(double contain)
    Force this Range to cover the given value.
    boolean
     
    double
    Returns the extent of this range.
    double
    Returns the upper bound of this range.
    double
    Returns the lower bound of this range.
    int
     
    boolean
    isContained(double contained)
    Returns true if the given value is covered by this range.
    void
    Mutator that shifts this range to the given one.
    final void
    setMax(double max)
    Sets the max value of this range.
    final void
    setMin(double min)
    Sets the min value of this range.
     

    Methods inherited from class java.lang.Object

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

    • RANGE_UNBOUNDED

      public static final Range RANGE_UNBOUNDED
      The unbounded range.
    • m_max

      protected double m_max
      The upper bound of this range.
    • m_min

      protected double m_min
      The lower bound of this range.
  • Constructor Details

    • Range

      public Range(double min, double max)
      Constructs a new Range that covers the given bounds.

      Parameters:
      min - the lower bound for the range.
      max - the upper bound for the range.
  • Method Details

    • ensureContained

      public boolean ensureContained(double contain)
      Force this Range to cover the given value.

      Parameters:
      contain - the value that has to be contained within this range.
      Returns:
      true, if an internal modification of one bound took place, false else.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • getExtent

      public double getExtent()
      Returns the extent of this range.

      Returns:
      the extent of this range.
    • getMax

      public double getMax()
      Returns the upper bound of this range.

      Returns:
      the upper bound of this range.
    • getMin

      public double getMin()
      Returns the lower bound of this range.

      Returns:
      the lower bound of this range.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • isContained

      public boolean isContained(double contained)
      Returns true if the given value is covered by this range.

      Parameters:
      contained - the value to test wether it is contained within this range.
      Returns:
      true if the given value is covered by this range.
    • mimic

      public void mimic(Range r)
      Mutator that shifts this range to the given one.

      This is support for "clone" without allocations in case range instances are reused.

      Parameters:
      r - the range to copy from.
    • setMax

      public final void setMax(double max)
      Sets the max value of this range.

      Parameters:
      max - the max to set.
    • setMin

      public final void setMin(double min)
      Sets the min value of this range.

      Parameters:
      min - the min to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also: