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.55 by jsr166, Thu May 2 06:02:17 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines