Package org.miaixz.bus.core.center.queue
Class BoundedPriorityQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.PriorityQueue<E>
org.miaixz.bus.core.center.queue.BoundedPriorityQueue<E>
- Type Parameters:
E- 成员类型
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Queue<E>,BoundedCollection<E>
有界优先队列 按照给定的排序规则,排序元素,当队列满时,按照给定的排序规则淘汰末尾元素(去除末尾元素)
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBoundedPriorityQueue(int capacity) 构造BoundedPriorityQueue(int capacity, Comparator<? super E> comparator) 构造 -
Method Summary
Methods inherited from class java.util.PriorityQueue
add, clear, comparator, contains, forEach, peek, poll, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractQueue
addAll, element, removeMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
BoundedPriorityQueue
public BoundedPriorityQueue(int capacity) 构造- Parameters:
capacity- 容量
-
BoundedPriorityQueue
构造- Parameters:
capacity- 容量comparator- 比较器
-
-
Method Details
-
isFull
public boolean isFull()Description copied from interface:BoundedCollection是否已满,如果集合已满,不允许新增元素- Specified by:
isFullin interfaceBoundedCollection<E>- Returns:
- 是否已满
-
maxSize
public int maxSize()Description copied from interface:BoundedCollection获取集合最大允许容量- Specified by:
maxSizein interfaceBoundedCollection<E>- Returns:
- 容量
-
offer
加入元素,当队列满时,淘汰末尾元素 -
addAll
添加多个元素 参数为集合的情况请使用AbstractQueue.addAll(java.util.Collection<? extends E>)- Parameters:
c- 元素数组- Returns:
- 是否发生改变
-
toList
- Returns:
- 返回排序后的列表
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Overrides:
iteratorin classPriorityQueue<E>
-