List of utility methods to do Array Capacity
byte[] | ensureCapacity(byte array[], int capacity) ensure Capacity if (capacity <= 0 || capacity - array.length <= 0) return array; int newCapacity = array.length * 2; if (newCapacity - capacity < 0) newCapacity = capacity; if (newCapacity < 0) { if (capacity < 0) throw new OutOfMemoryError(); ... |
byte[] | ensureCapacity(byte[] bytes, int capacity) Utility method used to ensure the capacity of byte array. if (bytes.length < capacity) { int newsize = Math.max(1, bytes.length) << 1; bytes = Arrays.copyOf(bytes, newsize); return bytes; |
double[] | ensureCapacity(final double[] array, final int minCapacity) ensure Capacity if (array.length < minCapacity) { return Arrays.copyOf(array, minCapacity); return array; |
T[] | ensureCapacity(final T[] oldElements, final int requiredLength) Ensure an array has the required capacity. T[] result = oldElements; if (oldElements.length < requiredLength) { result = Arrays.copyOf(oldElements, requiredLength); return result; |
Object[] | reduceCapacity(Object[] arrays) reduce Capacity if (arrays == null) { return null; int lastIndex = arrays.length - 1; int length = arrays.length; for (int i = lastIndex; i >= 0; i--) { if (arrays[i] == null) { length--; ... |