Package elki.math

Class IntegerMinMax


  • public class IntegerMinMax
    extends java.lang.Object
    Class to find the minimum and maximum int values in data.
    Since:
    0.5.5
    Author:
    Erich Schubert, Arthur Zimek
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int max
      Minimum and maximum.
      private int min
      Minimum and maximum.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntegerMinMax()
      Constructor without starting values.
      IntegerMinMax​(int min, int max)
      Constructor with predefined minimum and maximum values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] asIntArray()
      Return minimum and maximum as array.
      long getDiff()
      Return the difference between minimum and maximum.
      int getMax()
      Get the current maximum.
      int getMin()
      Get the current minimum.
      boolean isValid()
      Test whether the result is defined.
      static IntegerMinMax[] newArray​(int size)
      Generate a new array of initialized IntegerMinMax objects (with default constructor)
      void put​(int val)
      Process a single int value.
      void put​(int[] data)
      Process a whole array of int values.
      void put​(IntegerMinMax val)
      Process a MinMax pair.
      void reset()
      Reset statistics.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • min

        private int min
        Minimum and maximum.
      • max

        private int max
        Minimum and maximum.
    • Constructor Detail

      • IntegerMinMax

        public IntegerMinMax()
        Constructor without starting values. The minimum will be initialized to Integer.MAX_VALUE. The maximum will be initialized to Integer.MIN_VALUE. So that the first data added will replace both.
      • IntegerMinMax

        public IntegerMinMax​(int min,
                             int max)
        Constructor with predefined minimum and maximum values.
        Parameters:
        min - Minimum value
        max - Maximum value
    • Method Detail

      • put

        public void put​(int val)
        Process a single int value. If the new value is smaller than the current minimum, it will become the new minimum. If the new value is larger than the current maximum, it will become the new maximum.
        Parameters:
        val - New value
      • put

        public void put​(int[] data)
        Process a whole array of int values. If any of the values is smaller than the current minimum, it will become the new minimum. If any of the values is larger than the current maximum, it will become the new maximum.
        Parameters:
        data - Data to process
      • put

        public void put​(IntegerMinMax val)
        Process a MinMax pair.
        Parameters:
        val - New value
      • getMin

        public int getMin()
        Get the current minimum.
        Returns:
        current minimum.
      • getMax

        public int getMax()
        Get the current maximum.
        Returns:
        current maximum.
      • getDiff

        public long getDiff()
        Return the difference between minimum and maximum. Returns a long, as the difference may exceed integer bounds.
        Returns:
        Difference of current Minimum and Maximum.
      • isValid

        public boolean isValid()
        Test whether the result is defined.
        Returns:
        true when at least one value has been added
      • asIntArray

        public int[] asIntArray()
        Return minimum and maximum as array.
        Returns:
        Minimum, Maximum
      • newArray

        public static IntegerMinMax[] newArray​(int size)
        Generate a new array of initialized IntegerMinMax objects (with default constructor)
        Parameters:
        size - Array size
        Returns:
        initialized array
      • reset

        public void reset()
        Reset statistics.