Interface SetMultimap<K,V>
- Type Parameters:
K- key type | 键类型V- value type | 值类型
- All Superinterfaces:
Multimap<K,V>
- All Known Subinterfaces:
SortedSetMultimap<K,V>
- All Known Implementing Classes:
TreeSetMultimap
SetMultimap - Set-based Multimap Interface
SetMultimap - 基于集合的多值映射接口
A multimap that stores values in sets, not allowing duplicate key-value pairs.
将值存储在集合中的多值映射,不允许重复的键值对。
Features | 主要功能:
- No duplicate values per key - 每个键不允许重复值
- Set semantics - 集合语义
- Efficient contains check - 高效的包含检查
Usage Examples | 使用示例:
SetMultimap<String, Integer> multimap = MultimapBuilder.linkedHashKeys()
.linkedHashSetValues()
.build();
multimap.put("a", 1);
multimap.put("a", 2);
multimap.put("a", 1); // duplicate ignored
Set<Integer> values = multimap.get("a"); // [1, 2]
Performance | 性能特性:
- get: O(1) - get: O(1)
- put: O(1) average - put: O(1) 平均
- contains: O(1) - contains: O(1)
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:
-
Method Summary
Modifier and TypeMethodDescriptionentries()Return all entries as a set.Get the set of values for a key.Remove all values for a key and return them as a set.replaceValues(K key, Iterable<? extends V> values) Replace all values for a key and return the old values as a set.
-
Method Details
-
get
-
removeAll
-
replaceValues
-
entries
-