Java Utililty Methods Array Size Get

List of utility methods to do Array Size Get

Description

The list of methods to do Array Size Get are organized into topic(s).

Method

intarraySize(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;
intarraySize(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;
longarraySizeOf(int[] array)
array Size Of
if (array == null)
    return 0;
return calArraySize(array.length, SIZE_OF_INT);