package jeranvier.math.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MathExtension {
	
	public static int min(int... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static short min(short... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static byte min(byte... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static double min(double... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static long min(long... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static float min(float... candidates){
		Arrays.sort(candidates);
		return candidates[0];
	}
	
	public static int max(int... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
	public static short max(short... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
	public static byte max(byte... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
	public static double max(double... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
	public static long max(long... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
	public static float max(float... candidates){
		Arrays.sort(candidates);
		return candidates[candidates.length-1];
	}
	
}

@@ -23,16 +23,46 @@
 .util;%0A%0A
+import java.util.AbstractMap;%0A
 import j
@@ -207,16 +207,90 @@
 til.Map;
+%0Aimport java.util.Map.Entry;%0A%0Aimport jeranvier.math.timeseries.Timeseries;
 %0A%0Apublic
@@ -1646,10 +1646,684 @@
 %5D;%0A%09%7D%0A%09%0A
+%09public static Entry%3CLong, Double%3E max(Timeseries ts)%7B%0A%09%09Entry%3CLong, Double%3E max = new AbstractMap.SimpleEntry%3CLong, Double%3E(-1l, Double.NEGATIVE_INFINITY);%0A%09%09for(Entry%3CLong, Double%3E entry : ts.entrySet())%7B%0A%09%09%09if(entry.getValue() %3E max.getValue())%7B%0A%09%09%09%09max = new AbstractMap.SimpleEntry%3CLong, Double%3E(entry);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return max;%0A%09%7D%0A%09%0A%09public static Entry%3CLong, Double%3E min(Timeseries ts)%7B%0A%09%09Entry%3CLong, Double%3E min = new AbstractMap.SimpleEntry%3CLong, Double%3E(-1l, Double.POSITIVE_INFINITY);%0A%09%09for(Entry%3CLong, Double%3E entry : ts.entrySet())%7B%0A%09%09%09if(entry.getValue() %3C min.getValue())%7B%0A%09%09%09%09min = new AbstractMap.SimpleEntry%3CLong, Double%3E(entry);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return min;%0A%09%7D%0A%09%0A
 %7D%0A

add timeseries useful operations