790 |
|
* Used by methods size and getWaitingConsumerCount. |
791 |
|
*/ |
792 |
|
private int countOfMode(boolean data) { |
793 |
< |
int count = 0; |
794 |
< |
for (Node p = head; p != null; ) { |
795 |
< |
if (!p.isMatched()) { |
796 |
< |
if (p.isData != data) |
797 |
< |
return 0; |
798 |
< |
if (++count == Integer.MAX_VALUE) // saturated |
799 |
< |
break; |
800 |
< |
} |
801 |
< |
Node n = p.next; |
802 |
< |
if (n != p) |
803 |
< |
p = n; |
804 |
< |
else { |
805 |
< |
count = 0; |
806 |
< |
p = head; |
793 |
> |
restartFromHead: for (;;) { |
794 |
> |
int count = 0; |
795 |
> |
for (Node p = head; p != null;) { |
796 |
> |
if (!p.isMatched()) { |
797 |
> |
if (p.isData != data) |
798 |
> |
return 0; |
799 |
> |
if (++count == Integer.MAX_VALUE) |
800 |
> |
break; // @see Collection.size() |
801 |
> |
} |
802 |
> |
Node next = p.next; |
803 |
> |
if (p == next) |
804 |
> |
continue restartFromHead; |
805 |
> |
p = next; |
806 |
|
} |
807 |
+ |
return count; |
808 |
|
} |
809 |
– |
return count; |
809 |
|
} |
810 |
|
|
811 |
|
final class Itr implements Iterator<E> { |