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

Method removeRange

Ports/CLDC11/src/java/util/ArrayList.java:535–564  ·  view source on GitHub ↗
(int start, int end)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

fillMethod · 0.95
arraycopyMethod · 0.95

Tested by

no test coverage detected