Class HashUtil


  • public final class HashUtil
    extends Object
    • Method Detail

      • nextProbeLinear

        public static int nextProbeLinear​(int probeCount)
      • nextSumOfCount

        public static int nextSumOfCount​(int probeCount)
      • nextSumOfSquares

        public static int nextSumOfSquares​(int probeCount)
      • nextBucketId

        public static int nextBucketId​(int bucketId,
                                       int mask,
                                       int probe)
        Parameters:
        bucketId - - previous bucketId location
        mask - - mask being used (typically # of buckets-1; due to power-of-2 sized bucket arrays, handles wrap-around
        probe - - how many buckets to jump to find next bucket
        Returns:
        next bucketId, including any necessary wrap-around (again mask handles this)
      • calculateMaxFill

        public static int calculateMaxFill​(int bucketCount,
                                           float fillRatio)
      • computeBucketCount

        public static int computeBucketCount​(int expectedSize,
                                             float fillRatio)
        uses HashCommon.arraySize() which does this calculation. this is just a wrapper to name the use of this case
        Parameters:
        expectedSize - - expected number of elements to store in the hash
        fillRatio - - expected fill ratio of buckets by elemements
        Returns:
        nextPowerOfTwo(expectedSize / fillRatio)