Package info.monitorenter.util
Class Range
java.lang.Object
info.monitorenter.util.Range
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprotected double
The upper bound of this range.protected double
The lower bound of this range.static final Range
The unbounded range. -
Constructor Summary
ConstructorsConstructorDescriptionRange
(double min, double max) Constructs a new Range that covers the given bounds. -
Method Summary
Modifier and TypeMethodDescriptionboolean
ensureContained
(double contain) Force this Range to cover the given value.boolean
double
Returns the extent of this range.double
getMax()
Returns the upper bound of this range.double
getMin()
Returns the lower bound of this range.int
hashCode()
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.toString()
-
Field Details
-
RANGE_UNBOUNDED
The unbounded range. -
m_max
protected double m_maxThe upper bound of this range. -
m_min
protected double m_minThe 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
-
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() -
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
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
-