Moving in isEmpty and count into AbstractNodeQueue

This commit is contained in:
Viktor Klang 2013-04-03 20:05:20 +02:00
parent f7e0cdad9f
commit 68dfada8bc
3 changed files with 20 additions and 13 deletions

View file

@ -31,6 +31,17 @@ public abstract class AbstractNodeQueue<T> extends AtomicReference<AbstractNodeQ
getAndSet(n).setNext(n);
}
public final boolean isEmpty() {
return peek() == null;
}
public final int count() {
int count = 0;
for(Node<T> n = peek();n != null; n = n.next())
++count;
return count;
}
@SuppressWarnings("unchecked")
public final T poll() {
final Node<T> next = peek();