Dela via


IBlockingDeque Interface

Definition

A Deque that additionally supports blocking 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.

[Android.Runtime.Register("java/util/concurrent/BlockingDeque", "", "Java.Util.Concurrent.IBlockingDequeInvoker")]
[Java.Interop.JavaTypeParameters(new System.String[] { "E" })]
public interface IBlockingDeque : IDisposable, Java.Interop.IJavaPeerable, Java.Util.Concurrent.IBlockingQueue, Java.Util.IDeque
[<Android.Runtime.Register("java/util/concurrent/BlockingDeque", "", "Java.Util.Concurrent.IBlockingDequeInvoker")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "E" })>]
type IBlockingDeque = interface
    interface IBlockingQueue
    interface IQueue
    interface ICollection
    interface IIterable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IDeque
Derived
Attributes
Implements

Remarks

A Deque that additionally supports blocking 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.

BlockingDeque methods come in four forms, with different ways of handling operations that cannot be satisfied immediately, but may be satisfied at some point in the future: one throws an exception, the second returns a special value (either null or false, depending on the operation), the third blocks the current thread indefinitely until the operation can succeed, and the fourth blocks for only a given maximum time limit before giving up. These methods are summarized in the following table:

<table class="plain"> <caption>Summary of BlockingDeque methods</caption> <tr> <th id="First" colspan="5"> First Element (Head)</th> </tr> <tr> <td></td> <th id="FThrow" style="font-weight:normal; font-style: italic">Throws exception</th> <th id="FValue" style="font-weight:normal; font-style: italic">Special value</th> <th id="FBlock" style="font-weight:normal; font-style: italic">Blocks</th> <th id="FTimes" style="font-weight:normal; font-style: italic">Times out</th> </tr> <tr> <th id="FInsert" style="text-align:left">Insert</th> <td headers="First FInsert FThrow">#addFirst(Object) addFirst(e)</td> <td headers="First FInsert FValue">#offerFirst(Object) offerFirst(e)</td> <td headers="First FInsert FBlock">#putFirst(Object) putFirst(e)</td> <td headers="First FInsert FTimes">#offerFirst(Object, long, TimeUnit) offerFirst(e, time, unit)</td> </tr> <tr> <th id="FRemove" style="text-align:left">Remove</th> <td headers="First FRemove FThrow">#removeFirst() removeFirst()</td> <td headers="First FRemove FValue">#pollFirst() pollFirst()</td> <td headers="First FRemove FBlock">#takeFirst() takeFirst()</td> <td headers="First FRemove FTimes">#pollFirst(long, TimeUnit) pollFirst(time, unit)</td> </tr> <tr> <th id="FExamine" style="text-align:left">Examine</th> <td headers="First FExamine FThrow">#getFirst() getFirst()</td> <td headers="First FExamine FValue">#peekFirst() peekFirst()</td> <td headers="First FExamine FBlock" style="font-style:italic">not applicable</td> <td headers="First FExamine FTimes" style="font-style:italic">not applicable</td> </tr> <tr> <th id="Last" colspan="5"> Last Element (Tail)</th> </tr> <tr> <td></td> <th id="LThrow" style="font-weight:normal; font-style: italic">Throws exception</th> <th id="LValue" style="font-weight:normal; font-style: italic">Special value</th> <th id="LBlock" style="font-weight:normal; font-style: italic">Blocks</th> <th id="LTimes" style="font-weight:normal; font-style: italic">Times out</th> </tr> <tr> <th id="LInsert" style="text-align:left">Insert</th> <td headers="Last LInsert LThrow">#addLast(Object) addLast(e)</td> <td headers="Last LInsert LValue">#offerLast(Object) offerLast(e)</td> <td headers="Last LInsert LBlock">#putLast(Object) putLast(e)</td> <td headers="Last LInsert LTimes">#offerLast(Object, long, TimeUnit) offerLast(e, time, unit)</td> </tr> <tr> <th id="LRemove" style="text-align:left">Remove</th> <td headers="Last LRemove LThrow">#removeLast() removeLast()</td> <td headers="Last LRemove LValue">#pollLast() pollLast()</td> <td headers="Last LRemove LBlock">#takeLast() takeLast()</td> <td headers="Last LRemove LTimes">#pollLast(long, TimeUnit) pollLast(time, unit)</td> </tr> <tr> <th id="LExamine" style="text-align:left">Examine</th> <td headers="Last LExamine LThrow">#getLast() getLast()</td> <td headers="Last LExamine LValue">#peekLast() peekLast()</td> <td headers="Last LExamine LBlock" style="font-style:italic">not applicable</td> <td headers="Last LExamine LTimes" style="font-style:italic">not applicable</td> </tr> </table>

Like any BlockingQueue, a BlockingDeque is thread safe, does not permit null elements, and may (or may not) be capacity-constrained.

A BlockingDeque implementation may be used directly as a FIFO BlockingQueue. The methods inherited from the BlockingQueue interface are precisely equivalent to BlockingDeque methods as indicated in the following table:

<table class="plain"> <caption>Comparison of BlockingQueue and BlockingDeque methods</caption> <tr> <td></td> <th id="BQueue"> BlockingQueue Method</th> <th id="BDeque"> Equivalent BlockingDeque Method</th> </tr> <tr> <th id="Insert" rowspan="4" style="text-align:left; vertical-align:top">Insert</th> <th id="add" style="font-weight:normal; text-align:left">#add(Object) add(e)</th> <td headers="Insert BDeque add">#addLast(Object) addLast(e)</td> </tr> <tr> <th id="offer1" style="font-weight:normal; text-align:left">#offer(Object) offer(e)</th> <td headers="Insert BDeque offer1">#offerLast(Object) offerLast(e)</td> </tr> <tr> <th id="put" style="font-weight:normal; text-align:left">#put(Object) put(e)</th> <td headers="Insert BDeque put">#putLast(Object) putLast(e)</td> </tr> <tr> <th id="offer2" style="font-weight:normal; text-align:left">#offer(Object, long, TimeUnit) offer(e, time, unit)</th> <td headers="Insert BDeque offer2">#offerLast(Object, long, TimeUnit) offerLast(e, time, unit)</td> </tr> <tr> <th id="Remove" rowspan="4" style="text-align:left; vertical-align:top">Remove</th> <th id="remove" style="font-weight:normal; text-align:left">#remove() remove()</th> <td headers="Remove BDeque remove">#removeFirst() removeFirst()</td> </tr> <tr> <th id="poll1" style="font-weight:normal; text-align:left">#poll() poll()</th> <td headers="Remove BDeque poll1">#pollFirst() pollFirst()</td> </tr> <tr> <th id="take" style="font-weight:normal; text-align:left">#take() take()</th> <td headers="Remove BDeque take">#takeFirst() takeFirst()</td> </tr> <tr> <th id="poll2" style="font-weight:normal; text-align:left">#poll(long, TimeUnit) poll(time, unit)</th> <td headers="Remove BDeque poll2">#pollFirst(long, TimeUnit) pollFirst(time, unit)</td> </tr> <tr> <th id="Examine" rowspan="2" style="text-align:left; vertical-align:top">Examine</th> <th id="element" style="font-weight:normal; text-align:left">#element() element()</th> <td headers="Examine BDeque element">#getFirst() getFirst()</td> </tr> <tr> <th id="peek" style="font-weight:normal; text-align:left">#peek() peek()</th> <td headers="Examine BDeque peek">#peekFirst() peekFirst()</td> </tr> </table>

Memory consistency effects: As with other concurrent collections, actions in a thread prior to placing an object into a BlockingDeque<i>happen-before</i> actions subsequent to the access or removal of that element from the BlockingDeque in another thread.

This interface is a member of the Java Collections Framework.

Added in 1.6.

Java documentation for java.util.concurrent.BlockingDeque.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

First

Retrieves, but does not remove, the first element of this deque.

(Inherited from IDeque)
Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
IsEmpty

Returns if this Collection contains no elements.

(Inherited from ICollection)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
Last

Retrieves, but does not remove, the last element of this deque.

(Inherited from IDeque)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

Add(Object)

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

AddAll(ICollection)

Adds all of the elements in the specified collection to this collection (optional operation).

(Inherited from ICollection)
AddFirst(Object)

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

AddLast(Object)

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

Clear()

Removes all of the elements from this collection (optional operation).

(Inherited from ICollection)
Contains(Object)

Returns true if this deque contains the specified element.

ContainsAll(ICollection)

Returns true if this collection contains all of the elements in the specified collection.

(Inherited from ICollection)
DescendingIterator()

Returns an iterator over the elements in this deque in reverse sequential order.

(Inherited from IDeque)
Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
DrainTo(ICollection, Int32)

Removes at most the given number of available elements from this queue and adds them to the given collection.

(Inherited from IBlockingQueue)
DrainTo(ICollection)

Removes all available elements from this queue and adds them to the given collection.

(Inherited from IBlockingQueue)
Element()

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).

Equals(Object)

Compares the specified object with this collection for equality.

(Inherited from ICollection)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
ForEach(IConsumer)

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

(Inherited from IIterable)
GetHashCode()

Returns the hash code value for this collection.

(Inherited from ICollection)
Iterator()

Returns an iterator over the elements in this deque in proper sequence.

Offer(Object, Int64, TimeUnit)

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque), waiting up to the specified wait time if necessary for space to become available.

Offer(Object)

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.

OfferFirst(Object, Int64, TimeUnit)

Inserts the specified element at the front of this deque, waiting up to the specified wait time if necessary for space to become available.

OfferFirst(Object)

Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.

OfferLast(Object, Int64, TimeUnit)

Inserts the specified element at the end of this deque, waiting up to the specified wait time if necessary for space to become available.

OfferLast(Object)

Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.

Peek()

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

PeekFirst()

Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

(Inherited from IDeque)
PeekLast()

Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

(Inherited from IDeque)
Poll()

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

Poll(Int64, TimeUnit)

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), waiting up to the specified wait time if necessary for an element to become available.

PollFirst()

Retrieves and removes the first element of this deque, or returns null if this deque is empty.

(Inherited from IDeque)
PollFirst(Int64, TimeUnit)

Retrieves and removes the first element of this deque, waiting up to the specified wait time if necessary for an element to become available.

PollLast()

Retrieves and removes the last element of this deque, or returns null if this deque is empty.

(Inherited from IDeque)
PollLast(Int64, TimeUnit)

Retrieves and removes the last element of this deque, waiting up to the specified wait time if necessary for an element to become available.

Pop()

Pops an element from the stack represented by this deque.

(Inherited from IDeque)
Push(Object)

Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, throwing an IllegalStateException if no space is currently available.

Put(Object)

Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque), waiting if necessary for space to become available.

PutFirst(Object)

Inserts the specified element at the front of this deque, waiting if necessary for space to become available.

PutLast(Object)

Inserts the specified element at the end of this deque, waiting if necessary for space to become available.

RemainingCapacity()

Returns the number of additional elements that this queue can ideally (in the absence of memory or resource constraints) accept without blocking, or Integer.MAX_VALUE if there is no intrinsic limit.

(Inherited from IBlockingQueue)
Remove()

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).

Remove(Object)

Removes the first occurrence of the specified element from this deque.

RemoveAll(ICollection)

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

(Inherited from ICollection)
RemoveFirst()

Retrieves and removes the first element of this deque.

(Inherited from IDeque)
RemoveFirstOccurrence(Object)

Removes the first occurrence of the specified element from this deque.

RemoveIf(IPredicate)

Removes all of the elements of this collection that satisfy the given predicate.

(Inherited from ICollection)
RemoveLast()

Retrieves and removes the last element of this deque.

(Inherited from IDeque)
RemoveLastOccurrence(Object)

Removes the last occurrence of the specified element from this deque.

RetainAll(ICollection)

Retains only the elements in this collection that are contained in the specified collection (optional operation).

(Inherited from ICollection)
SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
Size()

Returns the number of elements in this deque.

Spliterator()

Creates a Spliterator over the elements described by this Iterable.

(Inherited from IIterable)
Take()

Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), waiting if necessary until an element becomes available.

TakeFirst()

Retrieves and removes the first element of this deque, waiting if necessary until an element becomes available.

TakeLast()

Retrieves and removes the last element of this deque, waiting if necessary until an element becomes available.

ToArray()

Returns an array containing all of the elements in this collection.

(Inherited from ICollection)
ToArray(IIntFunction)

Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

(Inherited from ICollection)
ToArray(Object[])

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

(Inherited from ICollection)
UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Explicit Interface Implementations

IIterable.Spliterator()

Creates a Spliterator over the elements in this collection.

(Inherited from ICollection)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
OfferFirstAsync(IBlockingDeque, Object, Int64, TimeUnit)
OfferFirstAsync(IBlockingDeque, Object)
OfferLastAsync(IBlockingDeque, Object, Int64, TimeUnit)
OfferLastAsync(IBlockingDeque, Object)
PollFirstAsync(IBlockingDeque, Int64, TimeUnit)
PollLastAsync(IBlockingDeque, Int64, TimeUnit)
PutFirstAsync(IBlockingDeque, Object)
PutLastAsync(IBlockingDeque, Object)
TakeFirstAsync(IBlockingDeque)
TakeLastAsync(IBlockingDeque)
OfferAsync(IBlockingQueue, Object, Int64, TimeUnit)
OfferAsync(IBlockingQueue, Object)
PollAsync(IBlockingQueue, Int64, TimeUnit)
PutAsync(IBlockingQueue, Object)
TakeAsync(IBlockingQueue)
ToEnumerable(IIterable)
ToEnumerable<T>(IIterable)

Applies to