/** * Grows the given array to the maximum between the given length and the current * length increased by 50%, provided that the given length is larger than the * current length. * * <p> * If you want complete control on the array growth, you should probably use * {@code ensureCapacity()} instead. * * @param array * an array. * @param length * the new minimum length for this array. * @return {@code array}, if it can contain {@code length} entries; otherwise, * an array with max({@code length},{@code array.length}/φ) entries * whose first {@code array.length} entries are the same as those of * {@code array}. */ public static float[] grow(final float[] array, final int length) { return grow(array, length, array.length); } /**
@Override public void enqueue(float x) { if (size == heap.length) heap = FloatArrays.grow(heap, size + 1); heap[size++] = x; FloatHeaps.upHeap(heap, size, size - 1, c); } @Override
@Override public void enqueue(float x) { if (size == array.length) array = FloatArrays.grow(array, size + 1); if (firstIndexValid) { if (c == null) { if ((Float.compare((x), (array[firstIndex])) < 0)) firstIndex = size; } else if (c.compare(x, array[firstIndex]) < 0) firstIndex = size; } else firstIndexValid = false; array[size++] = x; } @Override
/** * Unwraps an iterator, returning an array, with a limit on the number of * elements. * * <p> * This method iterates over the given type-specific iterator and returns an * array containing the elements returned by the iterator. At most {@code max} * elements will be returned. * * @param i * a type-specific iterator. * @param max * the maximum number of elements to be unwrapped. * @return an array containing the elements returned by the iterator (at most * {@code max}). */ public static float[] unwrap(final FloatIterator i, int max) { if (max < 0) throw new IllegalArgumentException("The maximum number of elements (" + max + ") is negative"); float array[] = new float[16]; int j = 0; while (max-- != 0 && i.hasNext()) { if (j == array.length) array = FloatArrays.grow(array, j + 1); array[j++] = i.nextFloat(); } return FloatArrays.trim(array, j); } /**