Class AbstractMultimap<K,V>
java.lang.Object
cloud.opencode.base.collections.AbstractMultimap<K,V>
- Type Parameters:
K- key type | 键类型V- value type | 值类型
- All Implemented Interfaces:
Multimap<K,V>, Serializable
- Direct Known Subclasses:
ArrayListMultimap, HashSetMultimap, LinkedHashMultimap, TreeSetMultimap
AbstractMultimap - Abstract Base for Multimap Implementations
AbstractMultimap - Multimap 实现的抽象基类
Provides skeletal implementation for Multimap. Subclasses need to implement the collection factory method.
为 Multimap 提供骨架实现。子类需要实现集合工厂方法。
Features | 主要功能:
- Common multimap operations - 通用多重映射操作
- Live views - 实时视图
- Serializable - 可序列化
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: Implementation dependent - 空值安全: 取决于实现
Usage Examples | 使用示例:
// Subclass provides collection factory
Multimap<String, Integer> multimap = ArrayListMultimap.create();
multimap.put("a", 1);
multimap.put("a", 2);
Collection<Integer> values = multimap.get("a"); // [1, 2]
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMultimap(Map<K, Collection<V>> map) Constructor with backing map. -
Method Summary
Modifier and TypeMethodDescriptionMap<K, Collection<V>> asMap()Return a map view with key to collection mapping.voidclear()Clear all entries.booleancontainsEntry(Object key, Object value) Check if the multimap contains the key-value pair.booleancontainsKey(Object key) Check if the multimap contains the key.booleancontainsValue(Object value) Check if the multimap contains the value.protected abstract Collection<V> Create a new collection for values.entries()Return a collection view of all key-value pairs.booleanReturn the collection of values for the key.inthashCode()booleanisEmpty()Check if the multimap is empty.keys()Return a multiset view of the keys (includes duplicates by value count).keySet()Return a set view of the keys.booleanStore a key-value pair.booleanStore multiple values for a key.booleanRemove a single key-value pair.Remove all values for a key.replaceValues(K key, Iterable<? extends V> values) Replace all values for a key.intsize()Return the total number of key-value pairs.toString()values()Return a collection view of all values.
-
Field Details
-
map
-
-
Constructor Details
-
AbstractMultimap
Constructor with backing map. 使用后备映射的构造方法。- Parameters:
map- backing map | 后备映射
-
-
Method Details
-
createCollection
Create a new collection for values. 为值创建新集合。- Returns:
- new collection | 新集合
-
size
-
isEmpty
-
containsKey
-
containsValue
-
containsEntry
Description copied from interface:MultimapCheck if the multimap contains the key-value pair. 检查多重映射是否包含键值对。- Specified by:
containsEntryin interfaceMultimap<K,V> - Parameters:
key- the key | 键value- the value | 值- Returns:
- true if contains | 如果包含则返回 true
-
put
-
putAll
-
get
-
remove
-
removeAll
-
replaceValues
Description copied from interface:MultimapReplace all values for a key. 替换键的所有值。- Specified by:
replaceValuesin interfaceMultimap<K,V> - Parameters:
key- the key | 键values- the new values | 新值- Returns:
- previous values | 之前的值
-
clear
-
keySet
-
keys
-
values
-
entries
-
asMap
-
equals
-
hashCode
-
toString
-