Class MapRange

java.lang.Object
com.massifmaps.core.MapRange

public class MapRange extends Object
A container class that defines a half closed range of values using minimum and maximum values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a MapRange object.
    MapRange(float min, float max)
    Constructs a MapRange object from min and max values.
    If min > max, the values will be swapped internally.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this object is equal to the specified object.
    float
    Returns the max value of this map range.
    float
    Calculate the midrange value.
    float
    Returns the min value of this map range.
    int
    Returns the hash value of this object.
    boolean
    inRange(float value)
    Tests if a value is in this map range.
    float
    Calculates the length of this map range.
    Creates a string representation of this map range, useful for logging.

    Methods inherited from class java.lang.Object

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

    • MapRange

      public MapRange()
      Constructs a MapRange object. The minimum value will be set to positive infinity
      and the maximum value to negative infinity.
    • MapRange

      public MapRange(float min, float max)
      Constructs a MapRange object from min and max values.
      If min > max, the values will be swapped internally.
      Parameters:
      min - The min value.
      max - The max value.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getMin

      public float getMin()
      Returns the min value of this map range.
      Returns:
      The min value of this map range.
    • getMax

      public float getMax()
      Returns the max value of this map range.
      Returns:
      The max value of this map range.
    • inRange

      public boolean inRange(float value)
      Tests if a value is in this map range. Value is considered in range if min <= val < max.
      Parameters:
      value - The value to be tested.
      Returns:
      True if value is in this map range.
    • getMidrange

      public float getMidrange()
      Calculate the midrange value.
      Returns:
      The midrange value.
    • length

      public float length()
      Calculates the length of this map range. Defined as max - min.
      Returns:
      The length of this map range.
    • toString

      public String toString()
      Creates a string representation of this map range, useful for logging.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this map range.