E - the type of element stored in the queuepublic class LockFreeLinkedBlockingDeque<E> extends AbstractLockFreeBlockingDeque<E>
BlockingDeque, backed by a ConcurrentLinkedDeque.
Unlike the ConcurrentLinkedDeque that backs it, this blocking deque provides an O(1)
implementation of size(). An AtomicInteger is used to track the size and to also
ensure that any configured capacity limit is enforced.
This class handles blocking operations (e.g. AbstractLockFreeBlockingDeque.takeFirst(), AbstractLockFreeBlockingDeque.putLast(Object),
etc.) with custom wait queues instead of using Locks and Conditions.
Use of Iterator.remove() is discouraged. If invoked and there are multiple, equal
values in the deque, the first one will be removed instead of the one last fetched by the
iterator. Similarly, calling remove() on a descendingIterator() when there are
multiple, equal values in the deque will result in the last one being removed, not the one last
fetched by the iterator.
| Constructor and Description |
|---|
LockFreeLinkedBlockingDeque() |
LockFreeLinkedBlockingDeque(int maxCapacity) |
| Modifier and Type | Method and Description |
|---|---|
Iterator<E> |
descendingIterator() |
Iterator<E> |
iterator() |
boolean |
offerFirst(E e) |
boolean |
offerLast(E e) |
E |
peekFirst() |
E |
peekLast() |
E |
pollFirst() |
E |
pollLast() |
int |
remainingCapacity() |
boolean |
removeFirstOccurrence(Object o) |
boolean |
removeLastOccurrence(Object o) |
int |
size() |
drainTo, drainTo, isTentativelyEmpty, offer, offerFirst, offerFirstInterruptibly, offerLast, offerLastInterruptibly, poll, pollFirst, pollFirstInterruptibly, pollLast, pollLastInterruptibly, put, putFirst, putLast, signalNotEmpty, signalNotFull, take, takeFirst, takeLast, tentativeRemainingCapacityadd, addFirst, addLast, element, getFirst, getLast, offer, peek, poll, pop, push, remove, remove, removeFirst, removeLastaddAll, clearcontains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, addFirst, addLast, contains, element, offer, peek, poll, push, remove, removegetFirst, getLast, pop, removeFirst, removeLastaddAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic LockFreeLinkedBlockingDeque()
public LockFreeLinkedBlockingDeque(int maxCapacity)
public E pollFirst()
public E pollLast()
public E peekFirst()
public E peekLast()
public boolean offerFirst(E e)
public boolean offerLast(E e)
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface BlockingDeque<E>iterator in interface Deque<E>iterator in class AbstractCollection<E>public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence in interface BlockingDeque<E>removeFirstOccurrence in interface Deque<E>removeFirstOccurrence in class AbstractDeque<E>public boolean removeLastOccurrence(Object o)
removeLastOccurrence in interface BlockingDeque<E>removeLastOccurrence in interface Deque<E>removeLastOccurrence in class AbstractDeque<E>public int remainingCapacity()
public int size()
size in interface Collection<E>size in interface BlockingDeque<E>size in interface Deque<E>size in class AbstractCollection<E>