Class Arrays.MinMaxInfo
- Enclosing class:
Arrays
The helper class for Arrays.rangeOf(PArray, MinMaxInfo)
method, containing information
about the minimum and maximum in some AlgART array.
The instance of this class contains the following information:
index of minimal
andindex of maximal
elements in the AlgART array;- the range
range()
min..max}: the values of minimal and maximal elements; initialized
boolean flag, which is false after creating the instance by the constructor (when this object does not contain useful information) and which is set to true before filling this object by real information at the end of executingArrays.rangeOf(PArray, MinMaxInfo)
method;
The only way to create an instance of this class is the constructor without arguments,
that creates an uninitialized instance.
The only way to change the information stored in this instance is calling
Arrays.rangeOf(PArray, MinMaxInfo)
method, that fills the instance by the actual information
and changes its state to initialized.
This class is thread-safe: you may use the same instance of this class in several threads. The state of the instance is always consistent: all information, stored in it, including initialized flag, is always changed simultaneously in a synchronized block.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
allNaN()
Returns true if the array isPFloatingArray
and all its elements are NaN.boolean
Indicates whether some other instance of this class is equal to this instance.int
hashCode()
Returns the hash code of this range.long
Returns the index of the maximal array element stored in this object or −1 if an array is empty (array.length()==0).long
Returns the index of the minimal array element stored in this object or −1 if an array is empty (array.length()==0).boolean
Returns true if and only this object is initialized, that is if it was passed toArrays.rangeOf(PArray, MinMaxInfo)
method at least once and this method was successfully finished.double
max()
Returns the value of the maximal array element stored in this object.double
min()
Returns the value of the minimal array element stored in this object.range()
Returns the values of both minimal and maximal array element stored in this object.toString()
Returns a brief string description of this object.
-
Constructor Details
-
MinMaxInfo
public MinMaxInfo()Creates newuninitialized
instance of this class. You must callArrays.rangeOf(PArray, MinMaxInfo)
method for this instance before you will be able to use it.
-
-
Method Details
-
isInitialized
public boolean isInitialized()Returns true if and only this object is initialized, that is if it was passed toArrays.rangeOf(PArray, MinMaxInfo)
method at least once and this method was successfully finished. If the object is not initialized, then all its methods, excepting this one and methods of the basic Object class (toString, equals, etc.) throw IllegalStateException.- Returns:
- whether this object is initialized.
-
indexOfMin
public long indexOfMin()Returns the index of the minimal array element stored in this object or −1 if an array is empty (array.length()==0).- Returns:
- the index of the minimal array element stored in this object.
- Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
indexOfMax
public long indexOfMax()Returns the index of the maximal array element stored in this object or −1 if an array is empty (array.length()==0).- Returns:
- the index of the maximal array element stored in this object.
- Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
min
public double min()Returns the value of the minimal array element stored in this object.- Returns:
- the value of the minimal array element stored in this object.
- Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
max
public double max()Returns the value of the maximal array element stored in this object.- Returns:
- the value of the maximal array element stored in this object.
- Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
range
Returns the values of both minimal and maximal array element stored in this object.Note: for array of floating-points values, where all elements are NaN, this method returns special value Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY (because
Range
class cannot store NaN limits). You can check this situation byallNaN()
method.- Returns:
- the values of both minimal and maximal array element stored in this object.
- Throws:
IllegalStateException
- if this instance is notinitialized
yet.
-
allNaN
public boolean allNaN()Returns true if the array isPFloatingArray
and all its elements are NaN. In this case,range()
contains a special value Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY.- Returns:
- true if and only if the array is floating-point and is filled by NaN.
-
toString
Returns a brief string description of this object.The result of this method may depend on implementation and usually contains the indexes and values of the found minimum and maximum.
-
hashCode
public int hashCode()Returns the hash code of this range. -
equals
Indicates whether some other instance of this class is equal to this instance. Returns true if and only if obj instanceofMinMaxInfo
and the information, stored in both instances, is fully identical.
-