MCPcopy Index your code
hub / github.com/davidgiven/luje / removeRange

Method removeRange

lib/java/util/ArrayList.java:548–588  ·  view source on GitHub ↗

Removes the objects in the specified range from the start to the end, but not including the end index. @param start the index at which to start removing. @param end the index one after the end of the range to remove. @throws IndexOutOfBoundsException when {@code st

(int start, int end)

Source from the content-addressed store, hash-verified

546 * when {@code start < 0, start > end} or {@code end > size()}
547 */
548 @Override
549 protected void removeRange(int start, int end) {
550 // REVIEW: does RI call this from remove(location)
551 if (start < 0) {
552 // REVIEW: message should indicate which index is out of range
553 throw new IndexOutOfBoundsException(
554 // luni.0B=Array index out of range: {0}
555 Messages.getString("luni.0B", //$NON-NLS-1$
556 Integer.valueOf(start)));
557 } else if (end > size) {
558 // REVIEW: message should indicate which index is out of range
559 throw new IndexOutOfBoundsException(
560 // luni.0A=Index: {0}, Size: {1}
561 Messages.getString("luni.0A", //$NON-NLS-1$
562 Integer.valueOf(end), Integer.valueOf(size)));
563 } else if (start > end) {
564 throw new IndexOutOfBoundsException(
565 // luni.35=Start index ({0}) is greater than end index ({1})
566 Messages.getString("luni.35", //$NON-NLS-1$
567 Integer.valueOf(start), Integer.valueOf(end)));
568 }
569
570 if (start == end) {
571 return;
572 }
573 if (end == size) {
574 Arrays.fill(array, firstIndex + start, firstIndex + size, null);
575 } else if (start == 0) {
576 Arrays.fill(array, firstIndex, firstIndex + end, null);
577 firstIndex += end;
578 } else {
579 // REVIEW: should this optimize to do the smallest copy?
580 System.arraycopy(array, firstIndex + end, array, firstIndex
581 + start, size - end);
582 int lastIndex = firstIndex + size;
583 int newLast = lastIndex + start - end;
584 Arrays.fill(array, newLast, lastIndex, null);
585 }
586 size -= end - start;
587 modCount++;
588 }
589
590 /**
591 * Replaces the element at the specified location in this {@code ArrayList}

Callers

nothing calls this directly

Calls 4

getStringMethod · 0.95
valueOfMethod · 0.95
fillMethod · 0.95
arraycopyMethod · 0.95

Tested by

no test coverage detected