MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / removeRange

Method removeRange

vm/JavaAPI/src/java/util/ArrayList.java:530–559  ·  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

528 * when {@code start < 0, start > end} or {@code end > size()}
529 */
530 @Override
531 protected void removeRange(int start, int end) {
532 // REVIEW: does RI call this from remove(location)
533 if (start < 0) {
534 throw new IndexOutOfBoundsException("Index out of bounds");
535 } else if (end > size) {
536 throw new IndexOutOfBoundsException("Index out of bounds");
537 } else if (start > end) {
538 throw new IndexOutOfBoundsException("Index out of bounds");
539 }
540
541 if (start == end) {
542 return;
543 }
544 if (end == size) {
545 Arrays.fill(array, firstIndex + start, firstIndex + size, null);
546 } else if (start == 0) {
547 Arrays.fill(array, firstIndex, firstIndex + end, null);
548 firstIndex += end;
549 } else {
550 // REVIEW: should this optimize to do the smallest copy?
551 System.arraycopy(array, firstIndex + end, array, firstIndex
552 + start, size - end);
553 int lastIndex = firstIndex + size;
554 int newLast = lastIndex + start - end;
555 Arrays.fill(array, newLast, lastIndex, null);
556 }
557 size -= end - start;
558 modCount++;
559 }
560
561 /**
562 * Replaces the element at the specified location in this {@code ArrayList}

Callers

nothing calls this directly

Calls 2

fillMethod · 0.95
arraycopyMethod · 0.95

Tested by

no test coverage detected