ConditionPriorityBlockingQueue
  public
  
  
  
  class
  ConditionPriorityBlockingQueue
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | com.android.tradefed.util.ConditionPriorityBlockingQueue<T> | 
A thread-safe class with ERROR(/PriorityBlockingQueue)-like operations that can retrieve objects
 that match a certain condition.
 
ERROR(/ConcurrentModificationException) will not be thrown, but the iterator
 will also not reflect the modified contents.
 
  See also:
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | ConditionPriorityBlockingQueue.AlwaysMatch<T>A  | 
| 
        
        
        
        
        interface | ConditionPriorityBlockingQueue.IMatcher<T>An interface for determining if elements match some sort of condition. | 
| Public constructors | |
|---|---|
| 
      ConditionPriorityBlockingQueue()
      Creates a  | |
| 
      ConditionPriorityBlockingQueue(Creates a  | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        boolean | 
      add(T addedElement)
      Inserts the specified element into this queue. | 
| 
        
        
        
        
        
        T | 
      addUnique(IMatcher<T> matcher, T object)
      Adds a item to this queue, replacing any existing object that matches given condition | 
| 
        
        
        
        
        
        void | 
      clear()
      Removes all elements from this queue. | 
| 
        
        
        
        
        
        boolean | 
      contains(T object)
      Determine if an object is currently contained in this queue. | 
| 
        
        
        
        
        
         | 
      getCopy()
      Get a copy of the contents of the queue. | 
| 
        
        
        
        
        
         | 
      iterator()
      
 | 
| 
        
        
        
        
        
        T | 
      poll(long timeout, TimeUnit unit)
      Retrieves and removes the minimum (as judged by the provided  | 
| 
        
        
        
        
        
        T | 
      poll(long timeout, TimeUnit unit, IMatcher<T> matcher)
      Retrieves and removes the minimum (as judged by the provided  | 
| 
        
        
        
        
        
        T | 
      poll(IMatcher<T> matcher)
      Retrieves and removes the minimum (as judged by the provided  | 
| 
        
        
        
        
        
        T | 
      poll()
      Retrieves and removes the head of this queue. | 
| 
        
        
        
        
        
        boolean | 
      remove(T object)
      Removes an item from this queue. | 
| 
        
        
        
        
        
        int | 
      size()
       | 
| 
        
        
        
        
        
        T | 
      take()
      Retrieves and removes the minimum (as judged by the provided  | 
| 
        
        
        
        
        
        T | 
      take(IMatcher<T> matcher)
      Retrieves and removes the first element T in the queue where matcher.matches(T) is
  | 
Public constructors
ConditionPriorityBlockingQueue
public ConditionPriorityBlockingQueue ()
Creates a ConditionPriorityBlockingQueue
 
ConditionPriorityBlockingQueue
public ConditionPriorityBlockingQueue (c) 
Creates a ConditionPriorityBlockingQueue
| Parameters | |
|---|---|
| c | : theERROR(/Comparator)used to prioritize the queue. | 
Public methods
add
public boolean add (T addedElement)
Inserts the specified element into this queue. As the queue is unbounded this method will never block.
| Parameters | |
|---|---|
| addedElement | T: the element to add | 
| Returns | |
|---|---|
| boolean | true | 
| Throws | |
|---|---|
| ClassCastException | if the specified element cannot be compared with elements currently in the priority queue according to the priority queue's ordering | 
| NullPointerException | if the specified element is null | 
addUnique
public T addUnique (IMatcher<T> matcher, T object)
Adds a item to this queue, replacing any existing object that matches given condition
| Parameters | |
|---|---|
| matcher | IMatcher: the matcher to evaluate existing objects | 
| object | T: the object to add | 
| Returns | |
|---|---|
| T | the replaced object or nullif none exist | 
clear
public void clear ()
Removes all elements from this queue.
contains
public boolean contains (T object)
Determine if an object is currently contained in this queue.
| Parameters | |
|---|---|
| object | T: the object to find | 
| Returns | |
|---|---|
| boolean | trueif given object is contained in queue.false>otherwise. | 
getCopy
publicgetCopy () 
Get a copy of the contents of the queue.
| Returns | |
|---|---|
|  | |
iterator
publiciterator () 
| Returns | |
|---|---|
|  | |
poll
public T poll (long timeout, 
                TimeUnit unit)Retrieves and removes the minimum (as judged by the provided ERROR(/Comparator) element T in
 the queue.
 
| Parameters | |
|---|---|
| timeout | long: the amount of time to wait for an element to become available | 
| unit | TimeUnit: theERROR(/TimeUnit)of timeout | 
| Returns | |
|---|---|
| T | the minimum matched element or nullif there are no matching elements | 
poll
public T poll (long timeout, 
                TimeUnit unit, 
                IMatcher<T> matcher)Retrieves and removes the minimum (as judged by the provided ERROR(/Comparator) element T in
 the queue where matcher.matches(T) is true.
 
| Parameters | |
|---|---|
| timeout | long: the amount of time to wait for an element to become available | 
| unit | TimeUnit: theERROR(/TimeUnit)of timeout | 
| matcher | IMatcher: theIMatcherto use to evaluate elements | 
| Returns | |
|---|---|
| T | the minimum matched element or nullif there are no matching elements | 
poll
public T poll (IMatcher<T> matcher)
Retrieves and removes the minimum (as judged by the provided ERROR(/Comparator) element T in
 the queue where matcher.matches(T) is true.
| Parameters | |
|---|---|
| matcher | IMatcher: theIMatcherto use to evaluate elements | 
| Returns | |
|---|---|
| T | the minimum matched element or nullif there are no matching elements | 
poll
public T poll ()
Retrieves and removes the head of this queue.
| Returns | |
|---|---|
| T | the head of this queue, or nullif the queue is empty | 
remove
public boolean remove (T object)
Removes an item from this queue.
| Parameters | |
|---|---|
| object | T: the object to remove | 
| Returns | |
|---|---|
| boolean | trueif given object was removed from queue.false>otherwise. | 
size
public int size ()
| Returns | |
|---|---|
| int | the number of elements in queue | 
take
public T take ()
Retrieves and removes the minimum (as judged by the provided ERROR(/Comparator) element T in
 the queue.
 
| Returns | |
|---|---|
| T | the head of this queue | 
| Throws | |
|---|---|
| InterruptedException | if interrupted while waiting | 
take
public T take (IMatcher<T> matcher)
Retrieves and removes the first element T in the queue where matcher.matches(T) is
 true, waiting if necessary until such an element becomes available.
| Parameters | |
|---|---|
| matcher | IMatcher: theIMatcherto use to evaluate elements | 
| Returns | |
|---|---|
| T | the matched element | 
| Throws | |
|---|---|
| InterruptedException | if interrupted while waiting | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-07-19 UTC.
