|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object aim4.util.Util
public class Util
This class provides helper methods that are used throughout the code.
Field Summary | |
---|---|
static Random |
random
The global random number generator |
static long |
randSeed
The random seed for all random number generators in the simulation |
Method Summary | |
---|---|
static String |
concatenate(List<String> strings,
String sep)
Concatenate a list of strings. |
static String |
concatenate(String[] strings,
String sep)
Concatenate an array of strings. |
static double |
constrain(double inputValue,
double minValue,
double maxValue)
Constrain a double value between a lower and upper bound. |
static boolean |
isDoubleEqual(double a,
double b)
Whether two floating-point numbers (doubles) are equal. |
static boolean |
isDoubleEqual(double a,
double b,
double precision)
Whether two floating-point numbers (doubles) are equal. |
static boolean |
isDoubleEqualOrGreater(double a,
double b)
Whether two floating-point numbers (doubles) are greater than or equal to another. |
static boolean |
isDoubleEqualOrLess(double a,
double b)
Whether two floating-point numbers (doubles) are less than or equal to another. |
static boolean |
isDoubleNotEqual(double a,
double b)
Whether two floating-point numbers (doubles) are not equal. |
static boolean |
isDoubleNotEqual(double a,
double b,
double precision)
Whether two floating-point numbers (doubles) are not equal. |
static boolean |
isDoubleNotZero(double a)
Whether a floating-point numbers (doubles) is not zero. |
static boolean |
isDoubleZero(double a)
Whether a floating-point numbers (doubles) is zero. |
static boolean |
nearlyEqual(double a,
double b,
double epsilon)
Check whether two double values are "nearly" equal. |
static int |
randomIndex(double[] distribution)
Choose a number according to a finite probability distribution. |
static int |
randomIndex(List<Double> distribution)
Choose a number according to a finite probability distribution. |
static List<String> |
readFileToStrArray(String inFileName)
Read the content of a file into a list of strings. |
static double |
recenter(double inputValue,
double minValue,
double maxValue)
Recenter a double value between a lower and upper bound. |
static double |
sum(double[] as)
The sum of an array of floating-point numbers |
static double |
sum(Iterable<Double> as)
The sum of a sequence of floating-point numbers |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static long randSeed
public static final Random random
Method Detail |
---|
public static boolean nearlyEqual(double a, double b, double epsilon)
a
- the first double valueb
- the second double valueepsilon
- the precision
public static boolean isDoubleZero(double a)
a
- a double value
public static boolean isDoubleNotZero(double a)
a
- a double value
public static boolean isDoubleEqual(double a, double b)
a
- a double valueb
- a double value
public static boolean isDoubleNotEqual(double a, double b)
a
- a double valueb
- a double value
public static boolean isDoubleEqual(double a, double b, double precision)
a
- a double valueb
- a double valueprecision
- the bound on of the difference between a and b that
is considered equal.
public static boolean isDoubleNotEqual(double a, double b, double precision)
a
- a double valueb
- a double valueprecision
- the bound on of the difference between a and b that
is considered equal.
public static boolean isDoubleEqualOrGreater(double a, double b)
a
- a double valueb
- a double value
public static boolean isDoubleEqualOrLess(double a, double b)
a
- a double valueb
- a double value
public static double constrain(double inputValue, double minValue, double maxValue)
inputValue
- the value to constrainminValue
- the lower boundmaxValue
- the upper bound
public static double recenter(double inputValue, double minValue, double maxValue)
inputValue
- the value to recenterminValue
- the lower boundmaxValue
- the upper bound
public static double sum(Iterable<Double> as)
as
- an iterable of double values
public static double sum(double[] as)
as
- an array of double values
public static int randomIndex(double[] distribution)
distribution
- the probability distribution
public static int randomIndex(List<Double> distribution)
distribution
- the probability distribution
public static String concatenate(List<String> strings, String sep)
strings
- a list of stringsep
- the separator
public static String concatenate(String[] strings, String sep)
strings
- an array of stringsep
- the separator
public static List<String> readFileToStrArray(String inFileName) throws IOException
inFileName
- the name of the file
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |