Created
July 1, 2015 08:08
-
-
Save Elix-x/4058bf72841d6a9f0f30 to your computer and use it in GitHub Desktop.
Weird particles: SpecialArrayUtils.class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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