/** * Increase the capacity of the bag. * * @param newCapacity * new capacity to grow to * * @throws ArrayIndexOutOfBoundsException if new capacity is smaller than old */ private void grow(int newCapacity) throws ArrayIndexOutOfBoundsException { int[] newElements = new int[newCapacity]; for (int i = 0; i < size; i++) newElements[i] = get(i); elements = newElements; beginIndex = 0; }
/** * Increase the capacity of the bag. * * @param newCapacity * new capacity to grow to * * @throws ArrayIndexOutOfBoundsException if new capacity is smaller than old */ private void grow(int newCapacity) throws ArrayIndexOutOfBoundsException { int[] newElements = new int[newCapacity]; for (int i = 0; i < size; i++) newElements[i] = get(i); elements = newElements; beginIndex = 0; }