|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
E - the type of elements held in this collectionpublic interface BlockingDeque<E>
A Deque that additionally supports operations that wait for
the deque to become non-empty when retrieving an element, and wait
for space to become available in the deque when storing an
element. These methods are summarized in the following table:
| First Element (Head) | Last Element (Tail) | |||
| Block | Time out | Block | Time out | |
| Insert | putFirst(e) |
offerFirst(e, time, unit) |
putLast(e) |
offerLast(e, time, unit) |
| Remove | takeFirst() |
pollFirst(time, unit) |
takeLast() |
pollLast(time, unit) |
Like any BlockingQueue, a BlockingDeque is
thread safe and may (or may not) be capacity-constrained. A
BlockingDeque implementation may be used directly as a
FIFO BlockingQueue. The blocking methods inherited from
the BlockingQueue interface are precisely equivalent to
BlockingDeque methods as indicated in the following table:
| BlockingQueue Method | Equivalent BlockingDeque Method |
put(e) |
putLast(e) |
take() |
takeFirst() |
offer(e, time. unit) |
offerLast(e, time, unit) |
poll(time, unit) |
pollFirst(time, unit) |
This interface is a member of the Java Collections Framework.
| Method Summary | |
|---|---|
boolean |
offer(E o,
long timeout,
TimeUnit unit)
Inserts the specified element as the lest element of this deque, if possible. |
boolean |
offerFirst(E o,
long timeout,
TimeUnit unit)
Inserts the specified element as the first element of this deque, waiting if necessary up to the specified wait time for space to become available. |
boolean |
offerLast(E o,
long timeout,
TimeUnit unit)
Inserts the specified element as the last element of this deque, waiting if necessary up to the specified wait time for space to become available. |
E |
poll(long timeout,
TimeUnit unit)
Retrieves and removes the first element of this deque, waiting if necessary up to the specified wait time if no elements are present on this deque. |
E |
pollFirst(long timeout,
TimeUnit unit)
Retrieves and removes the first element of this deque, waiting if necessary up to the specified wait time if no elements are present on this deque. |
E |
pollLast(long timeout,
TimeUnit unit)
Retrieves and removes the last element of this deque, waiting if necessary up to the specified wait time if no elements are present on this deque. |
void |
put(E o)
Adds the specified element as the last element of this deque, waiting if necessary for space to become available. |
void |
putFirst(E o)
Adds the specified element as the first element of this deque, waiting if necessary for space to become available. |
void |
putLast(E o)
Adds the specified element as the last element of this deque, waiting if necessary for space to become available. |
E |
take()
Retrieves and removes the first element of this deque, waiting if no elements are present on this deque. |
E |
takeFirst()
Retrieves and removes the first element of this deque, waiting if no elements are present on this deque. |
E |
takeLast()
Retrieves and removes the last element of this deque, waiting if no elements are present on this deque. |
| Methods inherited from interface net.sf.beanlib.util.Deque |
|---|
add, addFirst, addLast, contains, descendingIterator, element, getFirst, getLast, iterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size |
| Methods inherited from interface java.util.Collection |
|---|
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface java.util.concurrent.BlockingQueue |
|---|
add, drainTo, drainTo, offer, remainingCapacity |
| Methods inherited from interface java.util.Collection |
|---|
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
| Method Detail |
|---|
void putFirst(E o)
throws InterruptedException
o - the element to add
InterruptedException - if interrupted while waiting.
NullPointerException - if the specified element is null.
void putLast(E o)
throws InterruptedException
o - the element to add
InterruptedException - if interrupted while waiting.
NullPointerException - if the specified element is null.
E takeFirst()
throws InterruptedException
InterruptedException - if interrupted while waiting.
E takeLast()
throws InterruptedException
InterruptedException - if interrupted while waiting.
boolean offerFirst(E o,
long timeout,
TimeUnit unit)
throws InterruptedException
o - the element to addtimeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
InterruptedException - if interrupted while waiting.
NullPointerException - if the specified element is null.
boolean offerLast(E o,
long timeout,
TimeUnit unit)
throws InterruptedException
o - the element to addtimeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
InterruptedException - if interrupted while waiting.
NullPointerException - if the specified element is null.
E pollFirst(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
InterruptedException - if interrupted while waiting.
E pollLast(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
InterruptedException - if interrupted while waiting.
void put(E o)
throws InterruptedException
put in interface BlockingQueue<E>o - the element to add
InterruptedException - if interrupted while waiting.
NullPointerException - if the specified element is null.
boolean offer(E o,
long timeout,
TimeUnit unit)
throws InterruptedException
Collection.add(E), which can fail to insert an element only by
throwing an exception. This method is equivalent to to
offerLast
offer in interface BlockingQueue<E>o - the element to add.
NullPointerException - if the specified element is null
InterruptedException
E take()
throws InterruptedException
take in interface BlockingQueue<E>InterruptedException - if interrupted while waiting.
E poll(long timeout,
TimeUnit unit)
throws InterruptedException
poll in interface BlockingQueue<E>timeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
InterruptedException - if interrupted while waiting.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||