//
// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
return _blocks.compareAndSet(TAIL_OFFSET,current,update);
}
+ @SuppressWarnings("unchecked")
@Override
public T poll()
{
}
else
{
- Object element = currentHeadBlock.peek(head);
+ T element = currentHeadBlock.peek(head);
if (element == REMOVED_ELEMENT)
{
// Already removed, try next index
}
else
{
- return (T)element;
+ return element;
}
}
}
advance();
- if (element != REMOVED_ELEMENT)
- return (T)element;
+ if (element != REMOVED_ELEMENT) {
+ @SuppressWarnings("unchecked")
+ T e = (T)element;
+ return e;
+ }
}
}
elements = new AtomicReferenceArray<>(blockSize);
}
- public Object peek(int index)
+ @SuppressWarnings("unchecked")
+ public E peek(int index)
{
- return elements.get(index);
+ return (E)elements.get(index);
}
public boolean store(int index, E item)