Klasse HashUtil

java.lang.Object
speiger.src.collections.utils.HashUtil

public class HashUtil extends Object
Helper class that is used for HashMap functions reduce duplicated code
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final float
    Default HashMap Load Factor
    static final int
    Minimum HashMap Capacity
    static final int
    Minimum ConcurrentHashMap Concurrency
    static final float
    HashMap Load Factor with reduced hash collisions but more memory usage
    static final float
    HashMap Load Factor with minimal hash collisions but more memory usage
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static int
    arraySize(int size, float loadFactor)
    Helper function that creates the ideal array size for HashMap
    static int
    getRequiredBits(int value)
    Function that finds out how many bits are required to store the number Provided
    static int
    getRequiredBits(long value)
    Function that finds out how many bits are required to store the number Provided
    static int
    invMix(int x)
    The inverse of mix(int).
    static int
    mix(int x)
    Quickly mixes the bits of an integer.
    static int
    Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242
    static long
    Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242

    Von Klasse geerbte Methoden java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • DEFAULT_MIN_CAPACITY

      public static final int DEFAULT_MIN_CAPACITY
      Minimum HashMap Capacity
      Siehe auch:
    • DEFAULT_MIN_CONCURRENCY

      public static final int DEFAULT_MIN_CONCURRENCY
      Minimum ConcurrentHashMap Concurrency
      Siehe auch:
    • DEFAULT_LOAD_FACTOR

      public static final float DEFAULT_LOAD_FACTOR
      Default HashMap Load Factor
      Siehe auch:
    • FAST_LOAD_FACTOR

      public static final float FAST_LOAD_FACTOR
      HashMap Load Factor with reduced hash collisions but more memory usage
      Siehe auch:
    • FASTER_LOAD_FACTOR

      public static final float FASTER_LOAD_FACTOR
      HashMap Load Factor with minimal hash collisions but more memory usage
      Siehe auch:
  • Konstruktordetails

    • HashUtil

      public HashUtil()
  • Methodendetails

    • mix

      public static int mix(int x)
      Quickly mixes the bits of an integer.

      This method mixes the bits of the argument by multiplying by the golden ratio and xorshifting the result. It is borrowed from Koloboke,

      Parameter:
      x - an integer.
      Gibt zurück:
      a hash value obtained by mixing the bits of x.
      Siehe auch:
    • invMix

      public static int invMix(int x)
      The inverse of mix(int). This method is mainly useful to create unit tests.
      Parameter:
      x - an integer.
      Gibt zurück:
      a value that passed through mix(int) would give x.
    • nextPowerOfTwo

      public static int nextPowerOfTwo(int x)
      Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242
      Parameter:
      x - that should be converted to the next power of two
      Gibt zurück:
      the input number rounded up to the next power of two
    • nextPowerOfTwo

      public static long nextPowerOfTwo(long x)
      Function that rounds up to the closest power of 2 A modified version of https://stackoverflow.com/a/466242
      Parameter:
      x - that should be converted to the next power of two
      Gibt zurück:
      the input number rounded up to the next power of two
    • getRequiredBits

      public static int getRequiredBits(int value)
      Function that finds out how many bits are required to store the number Provided
      Parameter:
      value - to get the required bits to store.
      Gibt zurück:
      the required bits to store that number
      Note:
      Really useful for compression. Reducing data that is inserted into a GZIP algorithm.
    • getRequiredBits

      public static int getRequiredBits(long value)
      Function that finds out how many bits are required to store the number Provided
      Parameter:
      value - to get the required bits to store.
      Gibt zurück:
      the required bits to store that number
      Note:
      Really useful for compression. Reducing data that is inserted into a GZIP algorithm.
    • arraySize

      public static int arraySize(int size, float loadFactor)
      Helper function that creates the ideal array size for HashMap
      Parameter:
      size - the original array size
      loadFactor - the load factor
      Gibt zurück:
      the new array size