14 |
|
import java.util.Comparator; |
15 |
|
import java.util.Iterator; |
16 |
|
import java.util.NoSuchElementException; |
17 |
+ |
import java.util.Objects; |
18 |
|
import java.util.PriorityQueue; |
19 |
|
import java.util.Queue; |
20 |
|
import java.util.SortedSet; |
702 |
|
* @throws IllegalArgumentException {@inheritDoc} |
703 |
|
*/ |
704 |
|
public int drainTo(Collection<? super E> c, int maxElements) { |
705 |
< |
if (c == null) |
705 |
< |
throw new NullPointerException(); |
705 |
> |
Objects.requireNonNull(c); |
706 |
|
if (c == this) |
707 |
|
throw new IllegalArgumentException(); |
708 |
|
if (maxElements <= 0) |
931 |
|
|
932 |
|
@SuppressWarnings("unchecked") |
933 |
|
public void forEachRemaining(Consumer<? super E> action) { |
934 |
+ |
Objects.requireNonNull(action); |
935 |
|
Object[] a; int i, hi; // hoist accesses and checks from loop |
935 |
– |
if (action == null) |
936 |
– |
throw new NullPointerException(); |
936 |
|
if ((a = array) == null) |
937 |
|
fence = (a = toArray()).length; |
938 |
|
if ((hi = fence) <= a.length && |
942 |
|
} |
943 |
|
|
944 |
|
public boolean tryAdvance(Consumer<? super E> action) { |
945 |
< |
if (action == null) |
947 |
< |
throw new NullPointerException(); |
945 |
> |
Objects.requireNonNull(action); |
946 |
|
if (getFence() > index && index >= 0) { |
947 |
|
@SuppressWarnings("unchecked") E e = (E) array[index++]; |
948 |
|
action.accept(e); |