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.51 by jsr166, Wed Feb 20 12:39:06 2013 UTC vs.
Revision 1.56 by jsr166, Thu Jul 18 17:48:28 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 613 | 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> {
617        /*
618         * This class is nearly a mirror-image of DeqIterator, using
619         * tail instead of head for initial cursor, and head instead of
620         * tail for fence.
621         */
621          private int cursor = tail;
622          private int fence = head;
623          private int lastRet = -1;
# Line 811 | Line 810 | public class ArrayDeque<E> extends Abstr
810      /**
811       * Saves this deque to a stream (that is, serializes it).
812       *
813 +     * @param s the stream
814       * @serialData The current size ({@code int}) of the deque,
815       * followed by all of its elements (each an object reference) in
816       * first-to-last order.
# Line 830 | Line 830 | public class ArrayDeque<E> extends Abstr
830  
831      /**
832       * Reconstitutes this deque from a stream (that is, deserializes it).
833 +     * @param s the stream
834       */
835      private void readObject(java.io.ObjectInputStream s)
836              throws java.io.IOException, ClassNotFoundException {
# Line 846 | Line 847 | public class ArrayDeque<E> extends Abstr
847              elements[i] = s.readObject();
848      }
849  
850 <    Spliterator<E> spliterator() {
850 >    public Spliterator<E> spliterator() {
851          return new DeqSpliterator<E>(this, -1, -1);
852      }
853  
853    public Stream<E> stream() {
854        return Streams.stream(spliterator());
855    }
856
857    public Stream<E> parallelStream() {
858        return Streams.parallelStream(spliterator());
859    }
860
854      static final class DeqSpliterator<E> implements Spliterator<E> {
855          private final ArrayDeque<E> deq;
856          private int fence;  // -1 until first use
# Line 879 | Line 872 | public class ArrayDeque<E> extends Abstr
872              return t;
873          }
874  
875 <        public DeqSpliterator<E> trySplit() {
875 >        public Spliterator<E> trySplit() {
876              int t = getFence(), h = index, n = deq.elements.length;
877              if (h != t && ((h + 1) & (n - 1)) != t) {
878                  if (h > t)
# Line 890 | Line 883 | public class ArrayDeque<E> extends Abstr
883              return null;
884          }
885  
886 <        public void forEach(Consumer<? super E> consumer) {
886 >        public void forEachRemaining(Consumer<? super E> consumer) {
887              if (consumer == null)
888                  throw new NullPointerException();
889              Object[] a = deq.elements;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines