Interface NavigableMultiset<E>
- Type Parameters:
E- element type | 元素类型
- All Superinterfaces:
Collection<E>, Iterable<E>, Multiset<E>
- All Known Implementing Classes:
TreeMultiset
NavigableMultiset - Navigable Multiset Interface
NavigableMultiset - 可导航多重集合接口
A sorted multiset that provides navigation methods for accessing elements in sorted order.
提供按排序顺序访问元素的导航方法的排序多重集合。
Features | 主要功能:
- Sorted element access - 排序元素访问
- Navigation operations (lower, higher, floor, ceiling) - 导航操作
- Polling operations - 轮询操作
- Comparator access - 比较器访问
Usage Examples | 使用示例:
NavigableMultiset<String> multiset = TreeMultiset.create();
multiset.add("banana", 2);
multiset.add("apple", 3);
multiset.add("cherry");
String first = multiset.first(); // "apple"
String last = multiset.last(); // "cherry"
String lower = multiset.lower("banana"); // "apple"
Security | 安全性:
- Thread-safe: No (interface, implementation-dependent) - 否(接口,取决于实现)
- Null-safe: No - 否
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Multiset
Multiset.Entry<E> -
Method Summary
Modifier and TypeMethodDescriptionReturn the least element greater than or equal to the given element.Comparator<? super E> Return the comparator used to order elements.first()Return the first (lowest) element.Return the greatest element less than or equal to the given element.Return the least element strictly greater than the given element.last()Return the last (highest) element.Return the greatest element strictly less than the given element.Remove and return the first entry, or null if empty.Remove and return the last entry, or null if empty.Methods inherited from interface Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Method Details
-
first
E first()Return the first (lowest) element. 返回第一个(最小)元素。- Returns:
- the first element | 第一个元素
- Throws:
NoSuchElementException- if empty | 如果为空则抛出异常
-
last
E last()Return the last (highest) element. 返回最后一个(最大)元素。- Returns:
- the last element | 最后一个元素
- Throws:
NoSuchElementException- if empty | 如果为空则抛出异常
-
lower
-
higher
-
floor
-
ceiling
-
pollFirstEntry
Multiset.Entry<E> pollFirstEntry()Remove and return the first entry, or null if empty. 移除并返回第一个条目,如果为空则返回 null。- Returns:
- the first entry, or null | 第一个条目,或 null
-
pollLastEntry
Multiset.Entry<E> pollLastEntry()Remove and return the last entry, or null if empty. 移除并返回最后一个条目,如果为空则返回 null。- Returns:
- the last entry, or null | 最后一个条目,或 null
-
comparator
Comparator<? super E> comparator()Return the comparator used to order elements. 返回用于排序元素的比较器。- Returns:
- the comparator, or null for natural ordering | 比较器,自然排序则为 null
-