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 Lock
s and Condition
s.
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, tentativeRemainingCapacity
add, addFirst, addLast, element, getFirst, getLast, offer, peek, poll, pop, push, remove, remove, removeFirst, removeLast
addAll, clear
contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, addFirst, addLast, contains, element, offer, peek, poll, push, remove, remove
getFirst, getLast, pop, removeFirst, removeLast
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public 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>