條件優先權阻塞佇列
public class ConditionPriorityBlockingQueue
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.ConditionPriorityBlockingQueue<T> |
具有類似ERROR(/PriorityBlockingQueue)
操作的線程安全類,可以檢索與特定條件相符的物件。
ERROR(/ConcurrentModificationException)
,但迭代器也不會反映修改的內容。概括
嵌套類 | |
---|---|
class | ConditionPriorityBlockingQueue.AlwaysMatch <T> 與任何物件相符的 |
interface | ConditionPriorityBlockingQueue.IMatcher <T> 用於確定元素是否符合某種條件的介面。 |
公共構造函數 | |
---|---|
ConditionPriorityBlockingQueue () 元素將按 FIFO 順序排列優先順序。 | |
ConditionPriorityBlockingQueue ( c) ConditionPriorityBlockingQueue ( c) |
公共方法 | |
---|---|
boolean | add (T addedElement) 將指定元素插入此隊列。 |
T | addUnique ( IMatcher <T> matcher, T object) 將一個項目新增至此佇列,取代與給定條件相符的任何現有對象 |
void | clear () 從此隊列中刪除所有元素。 |
boolean | contains (T object) 確定此佇列中目前是否包含物件。 |
getCopy () 取得隊列內容的副本。 | |
iterator () | |
T | poll (long timeout, TimeUnit unit) 檢索並刪除最小值(由佇列中提供的 |
T | poll (long timeout, TimeUnit unit, IMatcher <T> matcher) 檢索並刪除佇列中matcher.matches(T)為 |
T | poll ( IMatcher <T> matcher) 檢索並刪除佇列中matcher.matches(T)為 |
T | poll () 檢索並刪除此佇列的頭部。 |
boolean | remove (T object) 從此隊列中刪除一個項目。 |
int | size () |
T | take () 檢索並刪除最小值(由佇列中提供的 |
T | take ( IMatcher <T> matcher) 檢索並刪除佇列中matcher.matches(T)為 |
公共構造函數
條件優先權阻塞佇列
public ConditionPriorityBlockingQueue ()元素將按 FIFO 順序排列優先順序。
條件優先權阻塞佇列
public ConditionPriorityBlockingQueue (c)
創建ConditionPriorityBlockingQueue
參數 | |
---|---|
c | ERROR(/Comparator) 。 |
公共方法
添加
public boolean add (T addedElement)
將指定元素插入此隊列。由於隊列是無界的,因此該方法永遠不會阻塞。
參數 | |
---|---|
addedElement | T :要新增的元素 |
退貨 | |
---|---|
boolean | true |
投擲 | |
---|---|
ClassCastException | 如果指定的元素無法根據優先權佇列的排序與優先權佇列中目前的元素進行比較 |
NullPointerException | 如果指定元素為空 |
添加唯一
public T addUnique (IMatcher<T> matcher, T object)
將一個項目新增至此佇列,取代與給定條件相符的任何現有對象
參數 | |
---|---|
matcher | IMatcher :評估現有物件的匹配器 |
object | T :要新增的對象 |
退貨 | |
---|---|
T | 被替換的對象,如果不存在則為null |
清除
public void clear ()
從此隊列中刪除所有元素。
包含
public boolean contains (T object)
確定此佇列中目前是否包含物件。
參數 | |
---|---|
object | T :要找的對象 |
退貨 | |
---|---|
boolean | 如果給定物件包含在佇列中,則為true 。 false> 否則。 |
取得副本
publicgetCopy ()
取得隊列內容的副本。
退貨 | |
---|---|
迭代器
publiciterator ()
退貨 | |
---|---|
輪詢
public T poll (long timeout, TimeUnit unit)
檢索並刪除最小值(由佇列中提供的ERROR(/Comparator)
元素 T 判斷)。
參數 | |
---|---|
timeout | long :等待元素變得可用的時間量 |
unit | TimeUnit : 超時的ERROR(/TimeUnit) |
退貨 | |
---|---|
T | 最小匹配元素,如果沒有匹配元素則為null |
輪詢
public T poll (long timeout, TimeUnit unit, IMatcher<T> matcher)
檢索並刪除佇列中matcher.matches(T)為true
最小值(根據佇列中提供的ERROR(/Comparator)
元素 T 進行判斷)。
參數 | |
---|---|
timeout | long :等待元素變得可用的時間量 |
unit | TimeUnit : 超時的ERROR(/TimeUnit) |
matcher | IMatcher :用於評估元素的IMatcher |
退貨 | |
---|---|
T | 最小匹配元素,如果沒有匹配元素則為null |
輪詢
public T poll (IMatcher<T> matcher)
檢索並刪除佇列中matcher.matches(T)為true
最小值(根據佇列中提供的ERROR(/Comparator)
元素 T 進行判斷)。
參數 | |
---|---|
matcher | IMatcher :用於評估元素的IMatcher |
退貨 | |
---|---|
T | 最小匹配元素,如果沒有匹配元素則為null |
輪詢
public T poll ()
檢索並刪除此佇列的頭部。
退貨 | |
---|---|
T | 該隊列的頭部,如果隊列為空則為null |
消除
public boolean remove (T object)
從此隊列中刪除一個項目。
參數 | |
---|---|
object | T :要刪除的對象 |
退貨 | |
---|---|
boolean | 如果給定物件已從佇列中刪除,則為true 。 false> 否則。 |
尺寸
public int size ()
退貨 | |
---|---|
int | 隊列中元素的數量 |
拿
public T take ()
檢索並刪除最小值(由佇列中提供的ERROR(/Comparator)
元素 T 判斷)。
退貨 | |
---|---|
T | 這個隊列的頭 |
投擲 | |
---|---|
InterruptedException | 如果在等待時被打擾 |
拿
public T take (IMatcher<T> matcher)
檢索並刪除佇列中matcher.matches(T)為true
第一個元素 T ,如有必要,則等待直到該元素可用。
參數 | |
---|---|
matcher | IMatcher :用於評估元素的IMatcher |
退貨 | |
---|---|
T | 匹配的元素 |
投擲 | |
---|---|
InterruptedException | 如果在等待時被打擾 |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2023-12-01 (世界標準時間)。