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

Comparing jsr166/src/main/java/util/concurrent/LinkedTransferQueue.java (file contents):
Revision 1.93 by jsr166, Sat Jun 13 22:33:38 2015 UTC vs.
Revision 1.94 by jsr166, Wed Jun 17 02:21:25 2015 UTC

# Line 989 | Line 989 | public class LinkedTransferQueue<E> exte
989      }
990  
991      /** A customized variant of Spliterators.IteratorSpliterator */
992 <    static final class LTQSpliterator<E> implements Spliterator<E> {
992 >    final class LTQSpliterator<E> implements Spliterator<E> {
993          static final int MAX_BATCH = 1 << 25;  // max batch array size;
994        final LinkedTransferQueue<E> queue;
994          Node current;       // current node; null until initialized
995          int batch;          // batch size for splits
996          boolean exhausted;  // true when no more nodes
997 <        LTQSpliterator(LinkedTransferQueue<E> queue) {
999 <            this.queue = queue;
1000 <        }
997 >        LTQSpliterator() {}
998  
999          public Spliterator<E> trySplit() {
1000              Node p;
1004            final LinkedTransferQueue<E> q = this.queue;
1001              int b = batch;
1002              int n = (b <= 0) ? 1 : (b >= MAX_BATCH) ? MAX_BATCH : b + 1;
1003              if (!exhausted &&
1004 <                ((p = current) != null || (p = q.firstDataNode()) != null) &&
1004 >                ((p = current) != null || (p = firstDataNode()) != null) &&
1005                  p.next != null) {
1006                  Object[] a = new Object[n];
1007                  int i = 0;
# Line 1014 | Line 1010 | public class LinkedTransferQueue<E> exte
1010                      if (e != p && (a[i] = e) != null)
1011                          ++i;
1012                      if (p == (p = p.next))
1013 <                        p = q.firstDataNode();
1013 >                        p = firstDataNode();
1014                  } while (p != null && i < n && p.isData);
1015                  if ((current = p) == null)
1016                      exhausted = true;
# Line 1033 | Line 1029 | public class LinkedTransferQueue<E> exte
1029          public void forEachRemaining(Consumer<? super E> action) {
1030              Node p;
1031              if (action == null) throw new NullPointerException();
1036            final LinkedTransferQueue<E> q = this.queue;
1032              if (!exhausted &&
1033 <                ((p = current) != null || (p = q.firstDataNode()) != null)) {
1033 >                ((p = current) != null || (p = firstDataNode()) != null)) {
1034                  exhausted = true;
1035                  do {
1036                      Object e = p.item;
1037                      if (e != null && e != p)
1038                          action.accept((E)e);
1039                      if (p == (p = p.next))
1040 <                        p = q.firstDataNode();
1040 >                        p = firstDataNode();
1041                  } while (p != null && p.isData);
1042              }
1043          }
# Line 1051 | Line 1046 | public class LinkedTransferQueue<E> exte
1046          public boolean tryAdvance(Consumer<? super E> action) {
1047              Node p;
1048              if (action == null) throw new NullPointerException();
1054            final LinkedTransferQueue<E> q = this.queue;
1049              if (!exhausted &&
1050 <                ((p = current) != null || (p = q.firstDataNode()) != null)) {
1050 >                ((p = current) != null || (p = firstDataNode()) != null)) {
1051                  Object e;
1052                  do {
1053                      if ((e = p.item) == p)
1054                          e = null;
1055                      if (p == (p = p.next))
1056 <                        p = q.firstDataNode();
1056 >                        p = firstDataNode();
1057                  } while (e == null && p != null && p.isData);
1058                  if ((current = p) == null)
1059                      exhausted = true;
# Line 1096 | Line 1090 | public class LinkedTransferQueue<E> exte
1090       * @since 1.8
1091       */
1092      public Spliterator<E> spliterator() {
1093 <        return new LTQSpliterator<E>(this);
1093 >        return new LTQSpliterator<E>();
1094      }
1095  
1096      /* -------------- Removal methods -------------- */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines