ConditionPriorityBlockingQueue
  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( | |
| 公用方法 | |
|---|---|
| 
        
        
        
        
        
        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)
      擷取並移除最小值 (根據佇列中  | 
| 
        
        
        
        
        
        T | 
      poll()
      擷取並移除此佇列的首項。 | 
| 
        
        
        
        
        
        boolean | 
      remove(T object)
      從這個佇列中移除項目。 | 
| 
        
        
        
        
        
        int | 
      size()
       | 
| 
        
        
        
        
        
        T | 
      take()
      擷取並移除最小值 (根據佇列中提供的  | 
| 
        
        
        
        
        
        T | 
      take(IMatcher<T> matcher)
      擷取並移除佇列中 matcher.matches(T) 為  | 
公用建構函式
ConditionPriorityBlockingQueue
public ConditionPriorityBlockingQueue ()
建立 ConditionPriorityBlockingQueue
 
元素會以 FIFO 順序排序。
ConditionPriorityBlockingQueue
public ConditionPriorityBlockingQueue (c) 
建立 ConditionPriorityBlockingQueue
| 參數 | |
|---|---|
| c | :用於將優先順序排入佇列的ERROR(/Comparator)。 | 
公用方法
新增
public boolean add (T addedElement)
將指定元素插入此佇列。由於佇列是無界限的,因此這個方法永遠不會阻斷。
| 參數 | |
|---|---|
| addedElement | T:要新增的元素 | 
| 傳回 | |
|---|---|
| boolean | true | 
| 擲回 | |
|---|---|
| ClassCastException | 如果指定的元素無法根據優先佇列的排序,與目前在優先佇列中的元素進行比較 | 
| NullPointerException | 如果指定的元素為空值 | 
addUnique
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>。 | 
getCopy
publicgetCopy () 
取得佇列內容的副本。
| 傳回 | |
|---|---|
|  | |
疊代器
publiciterator () 
| 傳回 | |
|---|---|
|  | |
意見調查
public T poll (long timeout, 
                TimeUnit unit)擷取並移除最小值 (根據佇列中提供的 ERROR(/Comparator) 元素 T 判斷)。
元素最多會在 timeout 時間內封鎖。
| 參數 | |
|---|---|
| timeout | long:等待元素可用所需的時間 | 
| unit | TimeUnit:逾時的ERROR(/TimeUnit) | 
| 傳回 | |
|---|---|
| T | 最少相符的元素,如果沒有相符的元素則為 null | 
意見調查
public T poll (long timeout, 
                TimeUnit unit, 
                IMatcher<T> matcher)擷取並移除最小值 (根據佇列中提供的 ERROR(/Comparator) 元素 T 判斷,其中 matcher.matches(T) 為 true)。
元素最多會在 timeout 時間內封鎖。
| 參數 | |
|---|---|
| timeout | long:等待元素可用所需的時間 | 
| unit | TimeUnit:逾時的ERROR(/TimeUnit) | 
| matcher | IMatcher:用於評估元素的IMatcher | 
| 傳回 | |
|---|---|
| T | 最少相符的元素,如果沒有相符的元素則為 null | 
意見調查
public T poll (IMatcher<T> matcher)
擷取並移除最小值 (根據佇列中 ERROR(/Comparator) 元素 T 的判斷結果,其中 matcher.matches(T) 為 true)。
| 參數 | |
|---|---|
| matcher | IMatcher:用於評估元素的IMatcher | 
| 傳回 | |
|---|---|
| T | 最少相符的元素,如果沒有相符的元素則為 null | 
意見調查
public T poll ()
擷取並移除此佇列的首項。
| 傳回 | |
|---|---|
| T | 這個佇列的首項,如果佇列為空,則為 null | 
移除
public boolean remove (T object)
從這個佇列中移除項目。
| 參數 | |
|---|---|
| object | T:要移除的物件 | 
| 傳回 | |
|---|---|
| boolean | true如果已從佇列中移除指定物件。否則為false>。 | 
size
public int size ()
| 傳回 | |
|---|---|
| int | 佇列中的元素數量 | 
取
public T take ()
擷取並移除最小值 (根據佇列中提供的 ERROR(/Comparator) 元素 T 判斷)。
無限期阻斷元素可用。
| 傳回 | |
|---|---|
| T | 這個佇列的頭部 | 
| 擲回 | |
|---|---|
| InterruptedException | 在等待期間中斷 | 
