void (final int from, int shift) { if (shift == 0 || from > myMaxUsed) { return; } int newEnd = myMaxUsed + shift; if (newEnd >= myData.length) { int minCapacity = newEnd + 1; int newCapacity = myData.length; while (newCapacity < minCapacity) { newCapacity <<= 1; } myData = Arrays.copyOf(myData, newCapacity); } int effectiveFrom = from; while (myData[effectiveFrom] == null ) { if (++effectiveFrom >= myData.length) { return; } } System.arraycopy(myData, effectiveFrom, myData, effectiveFrom + shift, myMaxUsed - effectiveFrom + 1); if (shift > 0) { for (int i = effectiveFrom, max = effectiveFrom + shift; i < max; i++) { myData[i] = null; } } else { for (int i = myMaxUsed, min = myMaxUsed + shift; i > min; i--) { myData[i] = null; } } myMaxUsed += shift; }