PriorityBlockingQueue 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
未系結的 BlockingQueue 封鎖佇列,其使用與類別 PriorityQueue
相同的排序規則,並提供封鎖擷取作業。
[Android.Runtime.Register("java/util/concurrent/PriorityBlockingQueue", DoNotGenerateAcw=true)]
[Java.Interop.JavaTypeParameters(new System.String[] { "E" })]
public class PriorityBlockingQueue : Java.Util.AbstractQueue, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Util.Concurrent.IBlockingQueue
[<Android.Runtime.Register("java/util/concurrent/PriorityBlockingQueue", DoNotGenerateAcw=true)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "E" })>]
type PriorityBlockingQueue = class
inherit AbstractQueue
interface ISerializable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
interface IBlockingQueue
interface IQueue
interface ICollection
interface IIterable
- 繼承
- 屬性
- 實作
備註
未系結的 BlockingQueue 封鎖佇列,其使用與類別 PriorityQueue
相同的排序規則,並提供封鎖擷取作業。 雖然此佇列邏輯上未系結,但嘗試新增可能會因為資源耗盡而失敗, (造成 OutOfMemoryError
) 。 這個類別不允許 null
元素。 依賴可比較自然順序的優先順序佇列也不允許插入非可比較的物件, (這麼做會導致 ClassCastException
) 。
這個類別及其反覆運算器會實作 和 Iterator
介面的所有 < em > 選擇性 < /em > 方法 Collection
。 方法 #iterator()
中提供的 Iterator 和 方法 #spliterator()
>< 中提供的 Spliterator 不 <> 保證會以任何特定順序周遊 PriorityBlockingQueue 的專案。 如果您需要已排序的周遊,請考慮使用 Arrays.sort(pq.toArray())
。 此外,方法 drainTo
可以用來 < em > remove < /em > 某些或所有優先順序的元素,並將其放在另一個集合中。
此類別上的作業不保證具有相等優先順序的專案排序。 如果您需要強制執行排序,您可以定義使用次要索引鍵來中斷主要優先順序值的系結的自訂類別或比較子。 例如,以下是一個類別,會套用先入先出系結至可比較的元素。 若要使用它,您可以插入 , new FIFOEntry(anEntry)
而不是純專案物件。
{@code
class FIFOEntry<E extends Comparable<? super E>>
implements Comparable<FIFOEntry<E>> {
static final AtomicLong seq = new AtomicLong();
final long seqNum;
final E entry;
public FIFOEntry(E entry) {
seqNum = seq.getAndIncrement();
this.entry = entry;
}
public E getEntry() { return entry; }
public int compareTo(FIFOEntry<E> other) {
int res = entry.compareTo(other.entry);
if (res == 0 && other.entry != this.entry)
res = (seqNum < other.seqNum ? -1 : 1);
return res;
}
}}
這個類別是 JAVA Collections Framework的成員。
在 1.5 中新增。
的 java.util.concurrent.PriorityBlockingQueue
JAVA 檔。
此頁面的部分是根據所建立和共用的工作進行修改,並根據 2.5 屬性授權中所述的詞彙來使用。
建構函式
PriorityBlockingQueue() |
|
PriorityBlockingQueue(ICollection) |
建立 , |
PriorityBlockingQueue(Int32) |
建立具有指定初始容量的 , |
PriorityBlockingQueue(Int32, IComparator) |
使用指定的初始容量建立 , |
PriorityBlockingQueue(IntPtr, JniHandleOwnership) |
建立 JNI 物件的 Managed 標記法時使用的建構函式;由執行時間呼叫。 |
屬性
Class |
傳回這個 |
Handle |
基礎 Android 實例的控制碼。 (繼承來源 Object) |
IsEmpty |
要新增 (繼承來源 AbstractCollection) |
JniIdentityHashCode |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
JniPeerMembers |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
PeerReference |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
ThresholdClass |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 |
ThresholdType |
此 API 支援適用于 Android 的 Mono 基礎結構,並不適合直接從您的程式碼使用。 |
方法
Add(Object) |
要新增 (繼承來源 AbstractCollection) |
AddAll(ICollection) |
要新增 (繼承來源 AbstractCollection) |
Clear() |
要新增 (繼承來源 AbstractCollection) |
Clone() |
建立並傳回這個 物件的複本。 (繼承來源 Object) |
Comparator() |
傳回用來排序此佇列中元素的比較子,或者 |
Contains(Object) |
要新增 (繼承來源 AbstractCollection) |
ContainsAll(ICollection) |
要新增 (繼承來源 AbstractCollection) |
Dispose() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
Dispose(Boolean) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
DrainTo(ICollection) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
DrainTo(ICollection, Int32) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
Element() |
擷取,但不會移除此佇列的前端。 (繼承來源 AbstractQueue) |
Equals(Object) |
指出其他物件是否「等於」這個物件。 (繼承來源 Object) |
ForEach(IConsumer) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
GetHashCode() |
傳回此物件的雜湊碼值。 (繼承來源 Object) |
Iterator() |
傳回這個佇列中元素的反覆運算器。 |
JavaFinalize() |
當垃圾收集判斷物件不再參考物件時,垃圾收集行程會在物件上呼叫。 (繼承來源 Object) |
Notify() |
喚醒正在等候此物件監視器的單一線程。 (繼承來源 Object) |
NotifyAll() |
喚醒正在等候此物件監視器的所有線程。 (繼承來源 Object) |
Offer(Object) |
將指定的專案插入這個優先順序佇列中。 |
Offer(Object, Int64, TimeUnit) |
將指定的專案插入這個優先順序佇列中。 |
Peek() |
擷取但不會移除此佇列的前端,如果這個佇列是空的,則傳 |
Poll() |
擷取並移除此佇列的前端,如果這個佇列是空的,則傳 |
Poll(Int64, TimeUnit) |
擷取並移除此佇列的前端,並視需要等候指定的等候時間,讓專案變成可用。 |
Put(Object) |
將指定的專案插入這個優先順序佇列中。 |
RemainingCapacity() |
一律會傳 |
Remove() |
擷取並移除此佇列的前端。 (繼承來源 AbstractQueue) |
Remove(Object) |
要新增 (繼承來源 AbstractCollection) |
RemoveAll(ICollection) |
要新增 (繼承來源 AbstractCollection) |
RemoveIf(IPredicate) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
RetainAll(ICollection) |
要新增 (繼承來源 AbstractCollection) |
SetHandle(IntPtr, JniHandleOwnership) |
設定 Handle 屬性。 (繼承來源 Object) |
Size() |
傳回這個 |
Spliterator() |
傳 |
Take() |
擷取並移除此佇列的前端,並視需要等候直到元素變成可用為止。 |
ToArray() |
要新增 (繼承來源 AbstractCollection) |
ToArray(Object[]) |
要新增 (繼承來源 AbstractCollection) |
ToArray<T>() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
ToString() |
傳回物件的字串表示。 (繼承來源 Object) |
UnregisterFromRuntime() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
Wait() |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > 。 >< (繼承來源 Object) |
Wait(Int64) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
Wait(Int64, Int32) |
讓目前的執行緒等到喚醒為止,通常是 em < notified/em > 或 < em > interrupted < /em > ,或直到經過一定數量的即時為止。 <> (繼承來源 Object) |
明確介面實作
IJavaPeerable.Disposed() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.DisposeUnlessReferenced() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.Finalized() |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.JniManagedPeerState |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
IJavaPeerable.SetPeerReference(JniObjectReference) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
擴充方法
JavaCast<TResult>(IJavaObject) |
執行 Android 執行時間檢查的類型轉換。 |
JavaCast<TResult>(IJavaObject) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
GetJniTypeName(IJavaPeerable) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
OfferAsync(IBlockingQueue, Object) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
OfferAsync(IBlockingQueue, Object, Int64, TimeUnit) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
PollAsync(IBlockingQueue, Int64, TimeUnit) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
PutAsync(IBlockingQueue, Object) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
TakeAsync(IBlockingQueue) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
ToEnumerable(IIterable) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |
ToEnumerable<T>(IIterable) |
未系結的 BlockingQueue 封鎖佇列,其使用與類別 |