Class Tools

java.lang.Object
org.graph4j.util.Tools

public class Tools extends Object
Utility methods.
Author:
Cristian Frăsinaru
  • Constructor Details

    • Tools

      public Tools()
  • Method Details

    • formatTimestamp

      public static String formatTimestamp(Date date)
    • 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

      public static String padLeft(String str, int length)
      Parameters:
      str - a string.
      length - a length.
      Returns:
      the string padded with spaces to the left such that it has the specified length.
    • padRight

      public static String padRight(String str, int length)
      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.