[cvs] / jsr166 / src / main / java / util / Vector.java Repository:
ViewVC logotype

Diff of /jsr166/src/main/java/util/Vector.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33, Sun Nov 13 02:10:09 2016 UTC revision 1.34, Sun Nov 13 19:58:47 2016 UTC
# Line 1269  Line 1269 
1269                  if (i >= size) {                  if (i >= size) {
1270                      return;                      return;
1271                  }                  }
1272          @SuppressWarnings("unchecked")                  final Object[] es = elementData;
1273                  final E[] elementData = (E[]) Vector.this.elementData;                  if (i >= es.length)
                 if (i >= elementData.length) {  
1274                      throw new ConcurrentModificationException();                      throw new ConcurrentModificationException();
1275                  }                  while (i < size && modCount == expectedModCount)
1276                  while (i != size && modCount == expectedModCount) {                      action.accept(elementAt(es, i++));
                     action.accept(elementData[i++]);  
                 }  
1277                  // update once at end of iteration to reduce heap write traffic                  // update once at end of iteration to reduce heap write traffic
1278                  cursor = i;                  cursor = i;
1279                  lastRet = i - 1;                  lastRet = i - 1;
# Line 1347  Line 1344 
1344      public synchronized void forEach(Consumer<? super E> action) {      public synchronized void forEach(Consumer<? super E> action) {
1345          Objects.requireNonNull(action);          Objects.requireNonNull(action);
1346          final int expectedModCount = modCount;          final int expectedModCount = modCount;
1347          @SuppressWarnings("unchecked")          final Object[] es = elementData;
1348          final E[] elementData = (E[]) this.elementData;          final int size = elementCount;
1349          final int elementCount = this.elementCount;          for (int i = 0; modCount == expectedModCount && i < size; i++)
1350          for (int i=0; modCount == expectedModCount && i < elementCount; i++) {              action.accept(elementAt(es, i));
1351              action.accept(elementData[i]);          if (modCount != expectedModCount)
         }  
         if (modCount != expectedModCount) {  
1352              throw new ConcurrentModificationException();              throw new ConcurrentModificationException();
1353          }          }
     }  
1354    
1355      @Override      @Override
     @SuppressWarnings("unchecked")  
1356      public synchronized void replaceAll(UnaryOperator<E> operator) {      public synchronized void replaceAll(UnaryOperator<E> operator) {
1357          Objects.requireNonNull(operator);          Objects.requireNonNull(operator);
1358          final int expectedModCount = modCount;          final int expectedModCount = modCount;
1359            final Object[] es = elementData;
1360          final int size = elementCount;          final int size = elementCount;
1361          for (int i=0; modCount == expectedModCount && i < size; i++) {          for (int i = 0; modCount == expectedModCount && i < size; i++)
1362              elementData[i] = operator.apply((E) elementData[i]);              es[i] = operator.apply(elementAt(es, i));
1363          }          if (modCount != expectedModCount)
         if (modCount != expectedModCount) {  
1364              throw new ConcurrentModificationException();              throw new ConcurrentModificationException();
         }  
1365          modCount++;          modCount++;
1366      }      }
1367    

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8