< prev index next >

src/java.base/share/classes/java/util/Vector.java

Print this page
8223245: Miscellaneous changes imported from jsr166 CVS 2019-06
Reviewed-by: martin


1352         final int size = elementCount;
1353         for (int i = 0; modCount == expectedModCount && i < size; i++)
1354             action.accept(elementAt(es, i));
1355         if (modCount != expectedModCount)
1356             throw new ConcurrentModificationException();
1357     }
1358 
1359     /**
1360      * @throws NullPointerException {@inheritDoc}
1361      */
1362     @Override
1363     public synchronized void replaceAll(UnaryOperator<E> operator) {
1364         Objects.requireNonNull(operator);
1365         final int expectedModCount = modCount;
1366         final Object[] es = elementData;
1367         final int size = elementCount;
1368         for (int i = 0; modCount == expectedModCount && i < size; i++)
1369             es[i] = operator.apply(elementAt(es, i));
1370         if (modCount != expectedModCount)
1371             throw new ConcurrentModificationException();

1372         modCount++;
1373     }
1374 
1375     @SuppressWarnings("unchecked")
1376     @Override
1377     public synchronized void sort(Comparator<? super E> c) {
1378         final int expectedModCount = modCount;
1379         Arrays.sort((E[]) elementData, 0, elementCount, c);
1380         if (modCount != expectedModCount)
1381             throw new ConcurrentModificationException();
1382         modCount++;
1383     }
1384 
1385     /**
1386      * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
1387      * and <em>fail-fast</em> {@link Spliterator} over the elements in this
1388      * list.
1389      *
1390      * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
1391      * {@link Spliterator#SUBSIZED}, and {@link Spliterator#ORDERED}.




1352         final int size = elementCount;
1353         for (int i = 0; modCount == expectedModCount && i < size; i++)
1354             action.accept(elementAt(es, i));
1355         if (modCount != expectedModCount)
1356             throw new ConcurrentModificationException();
1357     }
1358 
1359     /**
1360      * @throws NullPointerException {@inheritDoc}
1361      */
1362     @Override
1363     public synchronized void replaceAll(UnaryOperator<E> operator) {
1364         Objects.requireNonNull(operator);
1365         final int expectedModCount = modCount;
1366         final Object[] es = elementData;
1367         final int size = elementCount;
1368         for (int i = 0; modCount == expectedModCount && i < size; i++)
1369             es[i] = operator.apply(elementAt(es, i));
1370         if (modCount != expectedModCount)
1371             throw new ConcurrentModificationException();
1372         // TODO(8203662): remove increment of modCount from ...
1373         modCount++;
1374     }
1375 
1376     @SuppressWarnings("unchecked")
1377     @Override
1378     public synchronized void sort(Comparator<? super E> c) {
1379         final int expectedModCount = modCount;
1380         Arrays.sort((E[]) elementData, 0, elementCount, c);
1381         if (modCount != expectedModCount)
1382             throw new ConcurrentModificationException();
1383         modCount++;
1384     }
1385 
1386     /**
1387      * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
1388      * and <em>fail-fast</em> {@link Spliterator} over the elements in this
1389      * list.
1390      *
1391      * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
1392      * {@link Spliterator#SUBSIZED}, and {@link Spliterator#ORDERED}.


< prev index next >