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

Comparing jsr166/src/main/java/util/ArrayList.java (file contents):
Revision 1.57 by jsr166, Wed Mar 28 02:50:41 2018 UTC vs.
Revision 1.58 by jsr166, Sat May 5 18:29:53 2018 UTC

# Line 1122 | Line 1122 | public class ArrayList<E> extends Abstra
1122              return true;
1123          }
1124  
1125 +        public void replaceAll(UnaryOperator<E> operator) {
1126 +            root.replaceAllRange(operator, offset, offset + size);
1127 +        }
1128 +
1129          public boolean removeAll(Collection<?> c) {
1130              return batchRemove(c, false);
1131          }
# Line 1591 | Line 1595 | public class ArrayList<E> extends Abstra
1595  
1596      @Override
1597      public void replaceAll(UnaryOperator<E> operator) {
1598 +        replaceAllRange(operator, 0, size);
1599 +    }
1600 +
1601 +    private void replaceAllRange(UnaryOperator<E> operator, int from, int to) {
1602          Objects.requireNonNull(operator);
1603          final int expectedModCount = modCount;
1604          final Object[] es = elementData;
1605 <        final int size = this.size;
1598 <        for (int i = 0; modCount == expectedModCount && i < size; i++)
1605 >        for (int i = from; modCount == expectedModCount && i < to; i++)
1606              es[i] = operator.apply(elementAt(es, i));
1607          if (modCount != expectedModCount)
1608              throw new ConcurrentModificationException();
1602        modCount++;
1609          // checkInvariants();
1610      }
1611  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines