Class Arrays.MinMaxInfo

java.lang.Object
net.algart.arrays.Arrays.MinMaxInfo
Enclosing class:
Arrays

public static final class Arrays.MinMaxInfo extends Object

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 and index 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 executing Arrays.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

    Constructors
    Constructor
    Description
    Creates new uninitialized instance of this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the array is PFloatingArray and all its elements are NaN.
    boolean
    Indicates whether some other instance of this class is equal to this instance.
    int
    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 to Arrays.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.
    Returns the values of both minimal and maximal array element stored in this object.
    Returns a brief string description of this object.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • isInitialized

      public boolean isInitialized()
      Returns true if and only this object is initialized, that is if it was passed to Arrays.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 not initialized 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 not initialized 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 not initialized 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 not initialized yet.
    • range

      public Range 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 by allNaN() method.

      Returns:
      the values of both minimal and maximal array element stored in this object.
      Throws:
      IllegalStateException - if this instance is not initialized yet.
    • allNaN

      public boolean allNaN()
      Returns true if the array is PFloatingArray 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

      public String 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.

      Overrides:
      toString in class Object
      Returns:
      a brief string description of this object.
    • hashCode

      public int hashCode()
      Returns the hash code of this range.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this range.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other instance of this class is equal to this instance. Returns true if and only if obj instanceof MinMaxInfo and the information, stored in both instances, is fully identical.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared for equality with this instance.
      Returns:
      true if the specified object is equal to this one.