ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jdk8/java/util/ArrayList.java
(Generate patch)

Comparing jsr166/src/jdk8/java/util/ArrayList.java (file contents):
Revision 1.2 by jsr166, Wed Nov 16 19:46:20 2016 UTC vs.
Revision 1.3 by jsr166, Mon May 7 23:38:48 2018 UTC

# Line 417 | Line 417 | public class ArrayList<E> extends Abstra
417          return (E) elementData[index];
418      }
419  
420 +    @SuppressWarnings("unchecked")
421 +    static <E> E elementAt(Object[] es, int index) {
422 +        return (E) es[index];
423 +    }
424 +
425      /**
426       * Returns the element at the specified position in this list.
427       *
# Line 1435 | Line 1440 | public class ArrayList<E> extends Abstra
1440      }
1441  
1442      @Override
1438    @SuppressWarnings("unchecked")
1443      public void replaceAll(UnaryOperator<E> operator) {
1444 +        replaceAllRange(operator, 0, size);
1445 +    }
1446 +
1447 +    private void replaceAllRange(UnaryOperator<E> operator, int i, int end) {
1448          Objects.requireNonNull(operator);
1449          final int expectedModCount = modCount;
1450 <        final int size = this.size;
1451 <        for (int i=0; modCount == expectedModCount && i < size; i++) {
1452 <            elementData[i] = operator.apply((E) elementData[i]);
1453 <        }
1446 <        if (modCount != expectedModCount) {
1450 >        final Object[] es = elementData;
1451 >        for (; modCount == expectedModCount && i < end; i++)
1452 >            es[i] = operator.apply(elementAt(es, i));
1453 >        if (modCount != expectedModCount)
1454              throw new ConcurrentModificationException();
1455 <        }
1449 <        modCount++;
1455 >        // checkInvariants();
1456      }
1457  
1458      @Override

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines