Removes the objects in the specified range from the start to the, but not including, end index. All elements with an index bigger than or equal to end have their index decreased by end - start. @param start the index at which to start removing. @param end the i
(int start, int end)
| 821 | * {@code end > size()}. |
| 822 | */ |
| 823 | @Override |
| 824 | protected void removeRange(int start, int end) { |
| 825 | if (start >= 0 && start <= end && end <= elementCount) { |
| 826 | if (start == end) { |
| 827 | return; |
| 828 | } |
| 829 | if (end != elementCount) { |
| 830 | System.arraycopy(elementData, end, elementData, start, |
| 831 | elementCount - end); |
| 832 | int newCount = elementCount - (end - start); |
| 833 | Arrays.fill(elementData, newCount, elementCount, null); |
| 834 | elementCount = newCount; |
| 835 | } else { |
| 836 | Arrays.fill(elementData, start, elementCount, null); |
| 837 | elementCount = start; |
| 838 | } |
| 839 | modCount++; |
| 840 | } else { |
| 841 | throw new IndexOutOfBoundsException(); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | /** |
| 846 | * Removes all objects from this vector that are not contained in the |