there is a java code:
private static final int tableSizeFor(int c) {
int n = c - 1;
n |= n >>> 1;
n |= n >>> 2;
n |= n >>> 4;
n |= n >>> 8;
n |= n >>> 16;
return (n < 0) ? 1 : (n >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : n + 1;
}
the result is: min(times of 2 and >=c)
for example, if c is 5,the result will be 8,if c is 16,the result will be 16.
I have calculated as the algorithm shows but I don't know how to understand this algorithm,anyone can explain this clearly,thanks.