--- jsr166/src/main/java/util/PriorityQueue.java 2013/01/19 18:18:10 1.85 +++ jsr166/src/main/java/util/PriorityQueue.java 2013/02/01 16:23:04 1.88 @@ -27,7 +27,7 @@ package java.util; import java.util.stream.Stream; import java.util.Spliterator; import java.util.stream.Streams; -import java.util.function.Block; +import java.util.function.Consumer; /** * An unbounded priority {@linkplain Queue queue} based on a priority heap. @@ -803,8 +803,7 @@ public class PriorityQueue extends Ab } /** Index-based split-by-two Spliterator */ - static final class PriorityQueueSpliterator - implements Spliterator, Iterator { + static final class PriorityQueueSpliterator implements Spliterator { private final PriorityQueue pq; private int index; // current index, modified on advance/split private final int fence; // one past last index @@ -821,10 +820,10 @@ public class PriorityQueue extends Ab int lo = index, mid = (lo + fence) >>> 1; return (lo >= mid) ? null : new PriorityQueueSpliterator(pq, lo, index = mid, - expectedModCount); + expectedModCount); } - public void forEach(Block block) { + public void forEach(Consumer block) { Object[] a; int i, hi; // hoist accesses and checks from loop if (block == null) throw new NullPointerException(); @@ -840,13 +839,13 @@ public class PriorityQueue extends Ab } } - public boolean tryAdvance(Block block) { + public boolean tryAdvance(Consumer block) { if (index >= 0 && index < fence) { - if (pq.modCount != expectedModCount) - throw new ConcurrentModificationException(); @SuppressWarnings("unchecked") E e = (E)pq.queue[index++]; block.accept(e); + if (pq.modCount != expectedModCount) + throw new ConcurrentModificationException(); return true; } return false; @@ -855,20 +854,5 @@ public class PriorityQueue extends Ab public long estimateSize() { return (long)(fence - index); } public boolean hasExactSize() { return true; } public boolean hasExactSplits() { return true; } - - // Iterator support - public Iterator iterator() { return this; } - public void remove() { throw new UnsupportedOperationException(); } - public boolean hasNext() { return index >= 0 && index < fence; } - - public E next() { - if (index < 0 || index >= fence) - throw new NoSuchElementException(); - if (pq.modCount != expectedModCount) - throw new ConcurrentModificationException(); - @SuppressWarnings("unchecked") E e = - (E) pq.queue[index++]; - return e; - } } }