List of utility methods to do Array Size Get
int | arraySize(final int expected, final float f) array Size final long s = Math.max(2L, nextPowerOfTwo((long) Math.ceil((double) ((float) expected / f)))); if (s > 1073741824L) { throw new IllegalArgumentException( "Too large (" + expected + " expected elements with load factor " + f + ")"); } else { return (int) s; |
int | arraySize(final int expected, final float f) Returns the least power of two smaller than or equal to 230 and larger than or equal to Math.ceil( expected / f ) .
final long s = nextPowerOfTwo((long) Math.ceil(expected / f)); if (s > (1 << 30)) throw new IllegalArgumentException( "Too large (" + expected + " expected elements with load factor " + f + ")"); return (int) s; |
long | arraySizeOf(int[] array) array Size Of if (array == null) return 0; return calArraySize(array.length, SIZE_OF_INT); |