Package com.massifmaps.core
Class MapRange
java.lang.Object
com.massifmaps.core.MapRange
A container class that defines a half closed range of values using minimum and maximum values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object is equal to the specified object.floatgetMax()Returns the max value of this map range.floatCalculate the midrange value.floatgetMin()Returns the min value of this map range.inthashCode()Returns the hash value of this object.booleaninRange(float value) Tests if a value is in this map range.floatlength()Calculates the length of this map range.toString()Creates a string representation of this map range, useful for logging.
-
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
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()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
Creates a string representation of this map range, useful for logging.
-