/** * Ensures that this array list can contain the given number of entries without * resizing. * * @param capacity * the new minimum capacity for this array list. */ public void ensureCapacity(final int capacity) { if (capacity <= a.length || a == BooleanArrays.DEFAULT_EMPTY_ARRAY) return; a = BooleanArrays.ensureCapacity(a, capacity, size); assert size <= a.length; } /**
/** * Ensures that an array can contain the given number of entries. * * <p> * If you cannot foresee whether this array will need again to be enlarged, you * should probably use {@code grow()} instead. * * @param array * an array. * @param length * the new minimum length for this array. * @return {@code array}, if it contains {@code length} entries or more; * otherwise, an array with {@code length} entries whose first * {@code array.length} entries are the same as those of {@code array}. */ public static boolean[] ensureCapacity(final boolean[] array, final int length) { return ensureCapacity(array, length, array.length); } /**
/** Sets the length of the given array. * * @param array an array. * @param length the new length for the array. * @return <code>array</code>, if it contains exactly <code>length</code> * entries; otherwise, if it contains <em>more</em> than * <code>length</code> entries, an array with <code>length</code> entries * whose entries are the same as the first <code>length</code> entries of * <code>array</code>; otherwise, an array with <code>length</code> entries * whose first <code>array.length</code> entries are the same as those of * <code>array</code>. * */ public static boolean[] setLength( final boolean[] array, final int length ) { if ( length == array.length ) return array; if ( length < array.length ) return trim( array, length ); return ensureCapacity( array, length ); } /** Returns a copy of a portion of an array.
/** * Sets the length of the given array. * * @param array * an array. * @param length * the new length for the array. * @return {@code array}, if it contains exactly {@code length} entries; * otherwise, if it contains <em>more</em> than {@code length} entries, * an array with {@code length} entries whose entries are the same as * the first {@code length} entries of {@code array}; otherwise, an * array with {@code length} entries whose first {@code array.length} * entries are the same as those of {@code array}. * */ public static boolean[] setLength(final boolean[] array, final int length) { if (length == array.length) return array; if (length < array.length) return trim(array, length); return ensureCapacity(array, length); } /**