de.lmu.ifi.dbs.elki.math
Class MinMax<T extends Comparable<? super T>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.utilities.pairs.Pair<T,T>
      extended by de.lmu.ifi.dbs.elki.math.MinMax<T>
Type Parameters:
T - Data type
All Implemented Interfaces:
PairInterface<T,T>

public class MinMax<T extends Comparable<? super T>>
extends Pair<T,T>

Class to find the minimum and maximum double values in data.


Field Summary
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.pairs.Pair
first, second
 
Constructor Summary
MinMax()
          Constructor without starting values.
MinMax(T min, T max)
          Constructor with predefined minimum and maximum values.
 
Method Summary
 Object[] asArray()
          Return minimum and maximum as array.
 T getMax()
          Get the current maximum.
 T getMin()
          Get the current minimum.
 boolean isValid()
          Test if we have seen any data (and thus have a useful minimum and maximum).
static
<N extends Comparable<N>>
MinMax<N>[]
newArray(int size)
          New array of MinMax objects for a given type.
 void put(Iterable<T> data)
          Process a whole collection of values.
 void put(SortedSet<T> data)
          Process a whole collection of values.
 void put(T data)
          Process a single value.
 void put(T[] data)
          Process a whole array of values.
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.pairs.Pair
equals, getFirst, getSecond, hashCode, newPairArray, setFirst, setSecond, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MinMax

public MinMax()
Constructor without starting values. The minimum will be initialized to null. The maximum will be initialized to null.


MinMax

public MinMax(T min,
              T max)
Constructor with predefined minimum and maximum values.

Parameters:
min - Minimum value
max - Maximum value
Method Detail

put

public void put(T data)
Process a single 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:
data - New value

put

public void put(T[] data)
Process a whole array of 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(Iterable<T> data)
Process a whole collection of 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(SortedSet<T> data)
Process a whole collection of 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

getMin

public T getMin()
Get the current minimum.

Returns:
current minimum.

getMax

public T getMax()
Get the current maximum.

Returns:
current maximum.

isValid

public boolean isValid()
Test if we have seen any data (and thus have a useful minimum and maximum).

Returns:
true iff min != null and max != null.

asArray

public Object[] asArray()
Return minimum and maximum as array.

Returns:
Minimum, Maximum

newArray

public static <N extends Comparable<N>> MinMax<N>[] newArray(int size)
New array of MinMax objects for a given type.

Type Parameters:
N - Number type.
Parameters:
size - Size.
Returns:
Initialized array.

Release 0.4.0 (2011-09-20_1324)