com.darwinsys.util.MiniMax Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of darwinsys-api Show documentation
Show all versions of darwinsys-api Show documentation
Ian Darwin's assorted Java stuff,
assembled as an API.
package com.darwinsys.util;
import java.util.List;
/**
* Polymorphic forms of some standard Math functions.
* See http://www.diasparsoftware.com/weblog/archives/00000100.html.
*/
public class MiniMax {
public static int max(int[] data) {
int v = Integer.MIN_VALUE;
for (int i : data) {
if (i > v) {
v = i;
}
}
return v;
}
public static Integer max(List data) {
Integer v = Integer.MIN_VALUE;
for (Integer i : data) {
if (i > v) {
v = i;
}
}
return v;
}
public static Integer max(Integer[] data) {
Integer v = Integer.MIN_VALUE;
for (Integer i : data) {
if (i > v) {
v = i;
}
}
return v;
}
}