ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/ArrayDeque.java
(Generate patch)

Comparing jsr166/src/main/java/util/ArrayDeque.java (file contents):
Revision 1.50 by jsr166, Wed Feb 20 12:32:01 2013 UTC vs.
Revision 1.54 by dl, Wed Mar 27 23:09:34 2013 UTC

# Line 19 | Line 19 | import java.util.stream.Streams;
19   * when used as a queue.
20   *
21   * <p>Most {@code ArrayDeque} operations run in amortized constant time.
22 < * Exceptions include {@link #remove(Object) remove}, {@link
23 < * #removeFirstOccurrence removeFirstOccurrence}, {@link #removeLastOccurrence
24 < * removeLastOccurrence}, {@link #contains contains}, {@link #iterator
25 < * iterator.remove()}, and the bulk operations, all of which run in linear
26 < * time.
22 > * Exceptions include
23 > * {@link #remove(Object) remove},
24 > * {@link #removeFirstOccurrence removeFirstOccurrence},
25 > * {@link #removeLastOccurrence removeLastOccurrence},
26 > * {@link #contains contains},
27 > * {@link #iterator iterator.remove()},
28 > * and the bulk operations, all of which run in linear time.
29   *
30 < * <p>The iterators returned by this class's {@code iterator} method are
31 < * <i>fail-fast</i>: If the deque is modified at any time after the iterator
32 < * is created, in any way except through the iterator's own {@code remove}
33 < * method, the iterator will generally throw a {@link
30 > * <p>The iterators returned by this class's {@link #iterator() iterator}
31 > * method are <em>fail-fast</em>: If the deque is modified at any time after
32 > * the iterator is created, in any way except through the iterator's own
33 > * {@code remove} method, the iterator will generally throw a {@link
34   * ConcurrentModificationException}.  Thus, in the face of concurrent
35   * modification, the iterator fails quickly and cleanly, rather than risking
36   * arbitrary, non-deterministic behavior at an undetermined time in the
# Line 611 | Line 613 | public class ArrayDeque<E> extends Abstr
613          }
614      }
615  
616 +    /**
617 +     * This class is nearly a mirror-image of DeqIterator, using tail
618 +     * instead of head for initial cursor, and head instead of tail
619 +     * for fence.
620 +     */
621      private class DescendingIterator implements Iterator<E> {
615        /*
616         * This class is nearly a mirror-image of DeqIterator, using
617         * tail instead of head for initial cursor, and head instead of
618         * tail for fence.
619         */
622          private int cursor = tail;
623          private int fence = head;
624          private int lastRet = -1;
# Line 844 | Line 846 | public class ArrayDeque<E> extends Abstr
846              elements[i] = s.readObject();
847      }
848  
849 <    Spliterator<E> spliterator() {
849 >    public Spliterator<E> spliterator() {
850          return new DeqSpliterator<E>(this, -1, -1);
851      }
852  
851    public Stream<E> stream() {
852        return Streams.stream(spliterator());
853    }
854
855    public Stream<E> parallelStream() {
856        return Streams.parallelStream(spliterator());
857    }
858
853      static final class DeqSpliterator<E> implements Spliterator<E> {
854          private final ArrayDeque<E> deq;
855          private int fence;  // -1 until first use
# Line 877 | Line 871 | public class ArrayDeque<E> extends Abstr
871              return t;
872          }
873  
874 <        public DeqSpliterator<E> trySplit() {
874 >        public Spliterator<E> trySplit() {
875              int t = getFence(), h = index, n = deq.elements.length;
876              if (h != t && ((h + 1) & (n - 1)) != t) {
877                  if (h > t)
# Line 888 | Line 882 | public class ArrayDeque<E> extends Abstr
882              return null;
883          }
884  
885 <        public void forEach(Consumer<? super E> consumer) {
885 >        public void forEachRemaining(Consumer<? super E> consumer) {
886              if (consumer == null)
887                  throw new NullPointerException();
888              Object[] a = deq.elements;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines