Package org.graph4j.util
Class Tools
java.lang.Object
org.graph4j.util.Tools
Utility methods.
- Author:
- Cristian Frăsinaru
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tcoalesce(T... values) Returns the first non-null value.static StringformatTimestamp(Date date) static doublelog2(double x) static doublemaxValue(double[][] matrix) static intmaxValue(int[][] matrix) static Stringstatic Stringstatic voidprintMatrix(double[][] matrix, int decimals) static voidprintMatrix(int[][] matrix) static doubleround(double d, int decimalPlace) static <T> voidshuffle(T[] array) Shuffles the values in the specified array.
-
Constructor Details
-
Tools
public Tools()
-
-
Method Details
-
formatTimestamp
-
round
public static double round(double d, int decimalPlace) - Parameters:
d- a value.decimalPlace- the decimal position to round the number.- Returns:
- the rounded value.
-
maxValue
public static int maxValue(int[][] matrix) - Parameters:
matrix- a matrix of integers.- Returns:
- the maximum value in the matrix.
-
maxValue
public static double maxValue(double[][] matrix) - Parameters:
matrix- a matrix of doubles.- Returns:
- the maximum value in the matrix.
-
printMatrix
public static void printMatrix(int[][] matrix) - Parameters:
matrix- a matrix of integers.
-
printMatrix
public static void printMatrix(double[][] matrix, int decimals) - Parameters:
matrix- a matrix of doubles.decimals- how many decimals to use for rounding.
-
log2
public static double log2(double x) - Parameters:
x- a value.- Returns:
- the base 2 logarithm of the value.
-
padLeft
- Parameters:
str- a string.length- a length.- Returns:
- the string padded with spaces to the left such that it has the specified length.
-
padRight
- Parameters:
str- a string.length- a length.- Returns:
- the string padded with spaces to the right such that it has the specified length.
-
coalesce
public static <T> T coalesce(T... values) Returns the first non-null value.- Type Parameters:
T- a generic type.- Parameters:
values- an array of values.- Returns:
- the first value that is not
null.
-
shuffle
public static <T> void shuffle(T[] array) Shuffles the values in the specified array.- Type Parameters:
T- a generic type.- Parameters:
array- an array of values.
-