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

Comparing jsr166/src/main/java/util/concurrent/ConcurrentLinkedDeque.java (file contents):
Revision 1.50 by jsr166, Thu Aug 8 20:12:10 2013 UTC vs.
Revision 1.51 by jsr166, Tue Nov 11 04:39:30 2014 UTC

# Line 1103 | Line 1103 | public class ConcurrentLinkedDeque<E>
1103       * @return the number of elements in this deque
1104       */
1105      public int size() {
1106 <        int count = 0;
1107 <        for (Node<E> p = first(); p != null; p = succ(p))
1108 <            if (p.item != null)
1109 <                // Collection.size() spec says to max out
1110 <                if (++count == Integer.MAX_VALUE)
1111 <                    break;
1112 <        return count;
1106 >        restartFromHead: for (;;) {
1107 >            int count = 0;
1108 >            for (Node<E> p = first(); p != null;) {
1109 >                if (p.item != null)
1110 >                    if (++count == Integer.MAX_VALUE)
1111 >                        break;  // @see Collection.size()
1112 >                Node<E> next = p.next;
1113 >                if (p == next)
1114 >                    continue restartFromHead;
1115 >                p = next;
1116 >            }
1117 >            return count;
1118 >        }
1119      }
1120  
1121      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines