Share via


IBlockingQueue.DrainTo Method

Definition

Overloads

DrainTo(ICollection)

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

DrainTo(ICollection, Int32)

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

DrainTo(ICollection)

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

[Android.Runtime.Register("drainTo", "(Ljava/util/Collection;)I", "GetDrainTo_Ljava_util_Collection_Handler:Java.Util.Concurrent.IBlockingQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public int DrainTo (System.Collections.ICollection? c);
[<Android.Runtime.Register("drainTo", "(Ljava/util/Collection;)I", "GetDrainTo_Ljava_util_Collection_Handler:Java.Util.Concurrent.IBlockingQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member DrainTo : System.Collections.ICollection -> int

Parameters

c
ICollection

the collection to transfer elements into

Returns

the number of elements transferred

Attributes

Remarks

Removes all available elements from this queue and adds them to the given collection. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Java documentation for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection<? super E>).

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.

Applies to

DrainTo(ICollection, Int32)

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

[Android.Runtime.Register("drainTo", "(Ljava/util/Collection;I)I", "GetDrainTo_Ljava_util_Collection_IHandler:Java.Util.Concurrent.IBlockingQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public int DrainTo (System.Collections.ICollection? c, int maxElements);
[<Android.Runtime.Register("drainTo", "(Ljava/util/Collection;I)I", "GetDrainTo_Ljava_util_Collection_IHandler:Java.Util.Concurrent.IBlockingQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member DrainTo : System.Collections.ICollection * int -> int

Parameters

c
ICollection

the collection to transfer elements into

maxElements
Int32

the maximum number of elements to transfer

Returns

the number of elements transferred

Attributes

Remarks

Removes at most the given number of available elements from this queue and adds them to the given collection. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Java documentation for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection<? super E>, int).

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.

Applies to