Class ImmutableSortedMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
cloud.opencode.base.collections.immutable.ImmutableSortedMap<K,V>
Type Parameters:
K - key type | 键类型
V - value type | 值类型
All Implemented Interfaces:
Serializable, Map<K,V>, NavigableMap<K,V>, SequencedMap<K,V>, SortedMap<K,V>

public final class ImmutableSortedMap<K,V> extends AbstractMap<K,V> implements NavigableMap<K,V>, Serializable
ImmutableSortedMap - Immutable Sorted Map Implementation ImmutableSortedMap - 不可变有序映射实现

A sorted map that cannot be modified after creation. Entries are stored in sorted order by key.

创建后不能修改的有序映射。条目按键排序存储。

Features | 主要功能:

  • Immutable - 不可变
  • Thread-safe - 线程安全
  • Sorted by key - 按键排序
  • NavigableMap operations - NavigableMap 操作

Usage Examples | 使用示例:

// Create from entries - 从条目创建
ImmutableSortedMap<String, Integer> map = ImmutableSortedMap.of("c", 3, "a", 1, "b", 2);
// Keys in order: [a, b, c]

// Create with builder - 使用构建器创建
ImmutableSortedMap<String, Integer> map = ImmutableSortedMap.<String, Integer>naturalOrder()
    .put("c", 3)
    .put("a", 1)
    .build();

Performance | 性能特性:

  • get: O(log n) - get: O(log n)
  • containsKey: O(log n) - containsKey: O(log 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: