Skip to content

Instantly share code, notes, and snippets.

@Elix-x
Created July 1, 2015 08:08
Show Gist options
  • Save Elix-x/4058bf72841d6a9f0f30 to your computer and use it in GitHub Desktop.
Save Elix-x/4058bf72841d6a9f0f30 to your computer and use it in GitHub Desktop.
Weird particles: SpecialArrayUtils.class
public class SpecialArrayUtils {
public static double min(double... doubles) {
boolean init = false;
double i = 0;
for(double j : doubles){
if(!init){
init = true;
i = j;
} else {
i = Math.min(i, j);
}
}
return i;
}
public static double max(double... doubles) {
boolean init = false;
double i = 0;
for(double j : doubles){
if(!init){
init = true;
i = j;
} else {
i = Math.max(i, j);
}
}
return i;
}
public static int min(int... ints) {
boolean init = false;
int i = 0;
for(int j : ints){
if(!init){
init = true;
i = j;
} else {
i = Math.min(i, j);
}
}
return i;
}
public static int max(int... ints) {
boolean init = false;
int i = 0;
for(int j : ints){
if(!init){
init = true;
i = j;
} else {
i = Math.max(i, j);
}
}
return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment