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

Method remove

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

469 * when {@code location < 0 || >= size()}
470 */
471 @Override
472 public E remove(int location) {
473 E result;
474 if (location < 0 || location >= size) {
475 throw new IndexOutOfBoundsException("Index out of bounds");
476 }
477 if (location == 0) {
478 result = array[firstIndex];
479 array[firstIndex++] = null;
480 } else if (location == size - 1) {
481 int lastIndex = firstIndex + size - 1;
482 result = array[lastIndex];
483 array[lastIndex] = null;
484 } else {
485 int elementIndex = firstIndex + location;
486 result = array[elementIndex];
487 if (location < size / 2) {
488 System.arraycopy(array, firstIndex, array, firstIndex + 1,
489 location);
490 array[firstIndex++] = null;
491 } else {
492 System.arraycopy(array, elementIndex + 1, array,
493 elementIndex, size - location - 1);
494 array[firstIndex+size-1] = null;
495 }
496 }
497 size--;
498
499 // REVIEW: we can move this to the first if case since it
500 // can only occur when size==1
501 if (size == 0) {
502 firstIndex = 0;
503 }
504
505 modCount++;
506 return result;
507 }
508
509 @Override
510 public boolean remove(Object object) {

Callers 12

getBarCommandsMethod · 0.95
getChildrenAsListMethod · 0.95
setSameWidthMethod · 0.95
setSameHeightMethod · 0.95
getValidLabelsMethod · 0.95
removeErrorListenerMethod · 0.95
createBorderMethod · 0.95
runMethod · 0.95
_mainMethod · 0.95
pushHistoryMethod · 0.95
floodFillMethod · 0.95
normalizeMethod · 0.95

Calls 2

arraycopyMethod · 0.95
indexOfMethod · 0.95

Tested by 1

pushHistoryMethod · 0.76