Java Hash Calculate hashCapacityForSize(final int size)

Here you can find the source of hashCapacityForSize(final int size)

Description

Returns the minimal capacity of hash-based structures (e.g.

License

Apache License

Parameter

Parameter Description
size size to calculate the minimal capacity

Return

the minimal capacity of hash-based structures for the specified size

Declaration

public static int hashCapacityForSize(final int size) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w w w.j a  va 2 s.c om*/
     * Returns the minimal capacity of hash-based structures (e.g. {@link HashSet} or {@link HashMap}) calculated from the specified size (number of elements)
     * and the default load factor (which is 0.75).
     * 
     * @param size size to calculate the minimal capacity
     * @return the minimal capacity of hash-based structures for the specified size
     */
    public static int hashCapacityForSize(final int size) {
        return size * 4 / 3 + 1;
    }
}

Related

  1. hashArray(Object[] array)
  2. hashArray(Object[] objs)
  3. hashBerkeleyDB64(byte[] str)
  4. hashByteArray(byte[] array, int startInclusive, int endExclusive)
  5. hashBytes(int seed, byte[] data, int offset, int len)
  6. hashCharArray(int seed, char... charArray)
  7. hashClassName(Class clazz)
  8. hashCombine(int seed, int hash)
  9. hashCombine(int seed, int hash)