Class ImmutableSortedSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
cloud.opencode.base.collections.immutable.ImmutableSortedSet<E>
Type Parameters:
E - element type | 元素类型
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, NavigableSet<E>, SequencedCollection<E>, SequencedSet<E>, Set<E>, SortedSet<E>

public final class ImmutableSortedSet<E> extends AbstractSet<E> implements NavigableSet<E>, Serializable
ImmutableSortedSet - Immutable Sorted Set Implementation ImmutableSortedSet - 不可变有序集合实现

A sorted set that cannot be modified after creation. Elements are stored in sorted order according to their natural ordering or a provided comparator.

创建后不能修改的有序集合。元素按自然顺序或提供的比较器排序存储。

Features | 主要功能:

  • Immutable - 不可变
  • Thread-safe - 线程安全
  • Sorted elements - 元素有序
  • NavigableSet operations - NavigableSet 操作

Usage Examples | 使用示例:

// Create from elements - 从元素创建
ImmutableSortedSet<String> set = ImmutableSortedSet.of("c", "a", "b");
// Result: [a, b, c]

// Create with comparator - 使用比较器创建
ImmutableSortedSet<String> set = ImmutableSortedSet.orderedBy(String.CASE_INSENSITIVE_ORDER)
    .add("A", "b", "C")
    .build();

Performance | 性能特性:

  • contains: O(log n) - contains: O(log n)
  • iteration: O(n) - iteration: O(n)

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: Yes (nulls not allowed) - 空值安全: 是(不允许空值)
Since:
JDK 25, opencode-base-collections V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: