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

Method remove

lib/java/util/ArrayList.java:485–525  ·  view source on GitHub ↗

Removes the object at the specified location from this list. @param location the index of the object to remove. @return the removed object. @throws IndexOutOfBoundsException when location < 0 || >= size()

(int location)

Source from the content-addressed store, hash-verified

483 * when {@code location < 0 || >= size()}
484 */
485 @Override
486 public E remove(int location) {
487 E result;
488 if (location < 0 || location >= size) {
489 throw new IndexOutOfBoundsException(
490 // luni.0A=Index: {0}, Size: {1}
491 Messages.getString("luni.0A", //$NON-NLS-1$
492 Integer.valueOf(location),
493 Integer.valueOf(size)));
494 }
495 if (location == 0) {
496 result = array[firstIndex];
497 array[firstIndex++] = null;
498 } else if (location == size - 1) {
499 int lastIndex = firstIndex + size - 1;
500 result = array[lastIndex];
501 array[lastIndex] = null;
502 } else {
503 int elementIndex = firstIndex + location;
504 result = array[elementIndex];
505 if (location < size / 2) {
506 System.arraycopy(array, firstIndex, array, firstIndex + 1,
507 location);
508 array[firstIndex++] = null;
509 } else {
510 System.arraycopy(array, elementIndex + 1, array,
511 elementIndex, size - location - 1);
512 array[firstIndex+size-1] = null;
513 }
514 }
515 size--;
516
517 // REVIEW: we can move this to the first if case since it
518 // can only occur when size==1
519 if (size == 0) {
520 firstIndex = 0;
521 }
522
523 modCount++;
524 return result;
525 }
526
527 @Override
528 public boolean remove(Object object) {

Callers

nothing calls this directly

Calls 4

getStringMethod · 0.95
valueOfMethod · 0.95
arraycopyMethod · 0.95
indexOfMethod · 0.95

Tested by

no test coverage detected