/** * 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 == LongArrays.DEFAULT_EMPTY_ARRAY) return; a = LongArrays.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 long[] ensureCapacity(final long[] 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}, 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 long[] setLength(final long[] array, final int length) { if (length == array.length) return array; if (length < array.length) return trim(array, length); return ensureCapacity(array, length); } /**
@Override public long[] next() { int length, common; if (!hasNext()) throw new NoSuchElementException(); if (i % ratio == 0) { pos = p[i / ratio]; length = readInt(array, pos); s = LongArrays.ensureCapacity(s, length, 0); LongBigArrays.copyFromBig(array, pos + count(length), s, 0, length); pos += length + count(length); inSync = true; } else { if (inSync) { length = readInt(array, pos); common = readInt(array, pos + count(length)); s = LongArrays.ensureCapacity(s, length + common, common); LongBigArrays.copyFromBig(array, pos + count(length) + count(common), s, common, length); pos += count(length) + count(common) + length; length += common; } else { s = LongArrays.ensureCapacity(s, length = length(i), 0); extract(i, s, 0, length); } } i++; return LongArrays.copy(s, 0, length); } @Override
@Override public LongArrayBitVector length(final long newLength) { bits = LongArrays.ensureCapacity(bits, numWords(newLength), numWords(length)); final long oldLength = length; if (newLength < oldLength) fill(newLength, oldLength, false); length = newLength; return this; }
public LongArrayBitVector length( final long newLength ) { bits = LongArrays.ensureCapacity( bits, numWords( newLength ), numWords( length ) ); final long oldLength = length; if ( newLength < oldLength ) fill( newLength, oldLength, false ); length = newLength; return this; }
public LongArrayBitVector length( final long newLength ) { bits = LongArrays.ensureCapacity( bits, numWords( newLength ), numWords( length ) ); final long oldLength = length; if ( newLength < oldLength ) fill( newLength, oldLength, false ); length = newLength; return this; }