Skip to content

Commit

Permalink
fixes #58.
Browse files Browse the repository at this point in the history
Now chases nodes all the way from consumer node to producer node.
  • Loading branch information
nitsanw committed Apr 15, 2015
1 parent a587827 commit 9ba3c46
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ public final Iterator<E> iterator() {
*/
@Override
public final int size() {
LinkedQueueNode<E> temp = lvConsumerNode();
LinkedQueueNode<E> curr = lvConsumerNode();
int size = 0;
while ((temp = temp.lvNext()) != null && size < Integer.MAX_VALUE) {
// must chase the nodes all the way to the producer node
while (curr != lvProducerNode() && size < Integer.MAX_VALUE) {
LinkedQueueNode<E> next = curr.lvNext();
while((next = curr.lvNext()) == null);
curr = next;
size++;
}
return size;
Expand Down

0 comments on commit 9ba3c46

Please sign in to comment.