1 |
|
/* |
2 |
< |
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 |
> |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 |
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
|
* |
5 |
|
* This code is free software; you can redistribute it and/or modify it |
895 |
|
return Spliterator.SIZED | Spliterator.SUBSIZED | Spliterator.NONNULL; |
896 |
|
} |
897 |
|
} |
898 |
+ |
|
899 |
+ |
/** |
900 |
+ |
* @throws NullPointerException {@inheritDoc} |
901 |
+ |
*/ |
902 |
+ |
@SuppressWarnings("unchecked") |
903 |
+ |
public void forEach(Consumer<? super E> action) { |
904 |
+ |
Objects.requireNonNull(action); |
905 |
+ |
final int expectedModCount = modCount; |
906 |
+ |
final Object[] es = queue; |
907 |
+ |
for (int i = 0, n = size; i < n; i++) |
908 |
+ |
action.accept((E) es[i]); |
909 |
+ |
if (expectedModCount != modCount) |
910 |
+ |
throw new ConcurrentModificationException(); |
911 |
+ |
} |
912 |
|
} |