Class ImmutableListMultimap<K,V>
java.lang.Object
cloud.opencode.base.collections.immutable.ImmutableMultimap<K,V>
cloud.opencode.base.collections.immutable.ImmutableListMultimap<K,V>
- Type Parameters:
K- key type | 键类型V- value type | 值类型
- All Implemented Interfaces:
Multimap<K,V>, Serializable
ImmutableListMultimap - Immutable List Multimap Implementation
ImmutableListMultimap - 不可变列表多值映射实现
A multimap that stores values in lists, preserving insertion order and allowing duplicates.
将值存储在列表中的多值映射,保留插入顺序并允许重复。
Features | 主要功能:
- Immutable - 不可变
- Thread-safe - 线程安全
- Preserves insertion order - 保留插入顺序
- Allows duplicate values - 允许重复值
Usage Examples | 使用示例:
ImmutableListMultimap<String, Integer> multimap = ImmutableListMultimap.<String, Integer>builder()
.put("a", 1)
.put("a", 2)
.put("a", 1) // duplicate allowed
.build();
ImmutableList<Integer> values = multimap.get("a"); // [1, 2, 1]
Performance | 性能特性:
- get: O(1) - get: O(1)
- containsKey: O(1) - containsKey: O(1)
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for ImmutableListMultimap. -
Method Summary
Modifier and TypeMethodDescriptionMap<K, ? extends Collection<V>> asMap()Return a map view with key to collection mapping.static <K,V> ImmutableListMultimap.Builder <K, V> builder()Create a builder.static <K,V> ImmutableListMultimap <K, V> Copy from a multimap.Return the collection of values for the key.inverse()Return the inverse multimap.static <K,V> ImmutableListMultimap <K, V> of()Return an empty immutable list multimap.static <K,V> ImmutableListMultimap <K, V> of(K k1, V v1) Return an immutable list multimap with one entry.static <K,V> ImmutableListMultimap <K, V> of(K k1, V v1, K k2, V v2) Return an immutable list multimap with two entries.Methods inherited from class ImmutableMultimap
clear, containsEntry, containsKey, containsValue, entries, isEmpty, keys, keySet, put, putAll, putAll, remove, removeAll, replaceValues, size, values
-
Method Details
-
of
Return an empty immutable list multimap. 返回空不可变列表多值映射。- Type Parameters:
K- key type | 键类型V- value type | 值类型- Returns:
- empty immutable list multimap | 空不可变列表多值映射
-
of
Return an immutable list multimap with one entry. 返回包含一个条目的不可变列表多值映射。- Type Parameters:
K- key type | 键类型V- value type | 值类型- Parameters:
k1- key | 键v1- value | 值- Returns:
- immutable list multimap | 不可变列表多值映射
-
of
Return an immutable list multimap with two entries. 返回包含两个条目的不可变列表多值映射。- Type Parameters:
K- key type | 键类型V- value type | 值类型- Parameters:
k1- first key | 第一个键v1- first value | 第一个值k2- second key | 第二个键v2- second value | 第二个值- Returns:
- immutable list multimap | 不可变列表多值映射
-
copyOf
Copy from a multimap. 从多值映射复制。- Type Parameters:
K- key type | 键类型V- value type | 值类型- Parameters:
multimap- the multimap | 多值映射- Returns:
- immutable list multimap | 不可变列表多值映射
-
builder
Create a builder. 创建构建器。- Type Parameters:
K- key type | 键类型V- value type | 值类型- Returns:
- builder | 构建器
-
get
Description copied from interface:MultimapReturn the collection of values for the key. 返回键的值集合。 -
asMap
-
inverse
Return the inverse multimap. 返回逆多值映射。- Returns:
- inverse multimap | 逆多值映射
-