条件优先级阻塞队列
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 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-07-19。