Class MinMaxPriorityQueue.Builder<E>
java.lang.Object
cloud.opencode.base.collections.specialized.MinMaxPriorityQueue.Builder<E>
- Type Parameters:
E- element type | 元素类型
- Enclosing class:
MinMaxPriorityQueue<E>
Builder for MinMaxPriorityQueue.
MinMaxPriorityQueue 构建器。
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptioncomparator(Comparator<? super E> comparator) Set the comparator for element ordering.create()Create the MinMaxPriorityQueue.final MinMaxPriorityQueue<E> Create the MinMaxPriorityQueue with initial elements.Create the MinMaxPriorityQueue from collection.initialCapacity(int initialCapacity) Set the initial capacity.maximumSize(int maximumSize) Set the maximum size.
-
Method Details
-
comparator
Set the comparator for element ordering. 设置元素排序的比较器。- Parameters:
comparator- the comparator | 比较器- Returns:
- this builder | 此构建器
-
initialCapacity
Set the initial capacity. 设置初始容量。- Parameters:
initialCapacity- initial capacity | 初始容量- Returns:
- this builder | 此构建器
- Throws:
IllegalArgumentException- if initialCapacity is negative | 如果初始容量为负
-
maximumSize
Set the maximum size. When the queue exceeds this size, the largest elements are automatically evicted. 设置最大容量。当队列超过此大小时,最大的元素将被自动淘汰。- Parameters:
maximumSize- maximum size | 最大容量- Returns:
- this builder | 此构建器
- Throws:
IllegalArgumentException- if maximumSize is not positive | 如果最大容量非正数
-
create
Create the MinMaxPriorityQueue. 创建 MinMaxPriorityQueue。- Returns:
- new MinMaxPriorityQueue | 新 MinMaxPriorityQueue
-
create
Create the MinMaxPriorityQueue with initial elements. 使用初始元素创建 MinMaxPriorityQueue。- Parameters:
elements- initial elements | 初始元素- Returns:
- new MinMaxPriorityQueue | 新 MinMaxPriorityQueue
-
create
Create the MinMaxPriorityQueue from collection. 从集合创建 MinMaxPriorityQueue。- Parameters:
collection- the collection | 集合- Returns:
- new MinMaxPriorityQueue | 新 MinMaxPriorityQueue
-