Class Tools

java.lang.Object
com.semedy.reasoner.utils.Tools

public class Tools extends Object
Author:
angele
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    arraySize(int expected, float f)
    Returns the least power of two smaller than or equal to 230 and larger than or equal to Math.ceil( expected / f ).
    static long
    Return the least power of two greater than or equal to the specified value.
    static long
    phiMix(long x)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Tools

      public Tools()
  • Method Details

    • nextPowerOfTwo

      public static long nextPowerOfTwo(long x)
      Return the least power of two greater than or equal to the specified value.

      Note that this function will return 1 when the argument is 0.

      Parameters:
      x - a long integer smaller than or equal to 262.
      Returns:
      the least power of two greater than or equal to the specified value.
    • arraySize

      public static int arraySize(int expected, float f)
      Returns the least power of two smaller than or equal to 230 and larger than or equal to Math.ceil( expected / f ).
      Parameters:
      expected - the expected number of elements in a hash table.
      f - the load factor.
      Returns:
      the minimum possible size for a backing array.
      Throws:
      IllegalArgumentException - if the necessary size is larger than 230.
    • phiMix

      public static long phiMix(long x)