Package org.miaixz.bus.core.center.map
Class TableMap<K,V>
java.lang.Object
org.miaixz.bus.core.center.map.TableMap<K,V>
- Type Parameters:
K- 键类型V- 值类型
- All Implemented Interfaces:
Serializable,Iterable<Map.Entry<K,,V>> Map<K,V>
public class TableMap<K,V>
extends Object
implements Map<K,V>, Iterable<Map.Entry<K,V>>, Serializable
可重复键和值的Map
通过键值单独建立List方式,使键值对一一对应,实现正向和反向两种查找
无论是正向还是反向,都是遍历列表查找过程,相比标准的HashMap要慢,数据越多越慢
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()voidforEach(BiConsumer<? super K, ? super V> action) 根据value获得对应的key,只返回找到的第一个value对应的key值获取指定value对应的所有key获取指定key对应的所有值booleanisEmpty()iterator()keys()获取所有键,可重复,不可修改keySet()void移除指定的所有键和对应的所有值booleanremoveByIndex(int index) 移除指定位置的键值对替换指定key的所有值为指定值booleanvoidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) intsize()toString()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Map
compute, computeIfAbsent, equals, getOrDefault, hashCode, merge, putIfAbsent
-
Constructor Details
-
TableMap
public TableMap()构造 -
TableMap
public TableMap(int size) 构造- Parameters:
size- 初始容量
-
TableMap
构造- Parameters:
keys- 键列表values- 值列表
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
getKey
根据value获得对应的key,只返回找到的第一个value对应的key值- Parameters:
value- 值- Returns:
- 键
-
getValues
获取指定key对应的所有值- Parameters:
key- 键- Returns:
- 值列表
-
getKeys
获取指定value对应的所有key- Parameters:
value- 值- Returns:
- 值列表
-
put
-
remove
移除指定的所有键和对应的所有值 -
removeByIndex
移除指定位置的键值对- Parameters:
index- 位置,不能越界- Returns:
- 移除的值
-
putAll
-
clear
public void clear() -
keySet
-
keys
获取所有键,可重复,不可修改- Returns:
- 键列表
-
values
-
entrySet
-
iterator
-
toString
-
forEach
-
remove
-
replaceAll
- Specified by:
replaceAllin interfaceMap<K,V>
-
replace
-
replace
替换指定key的所有值为指定值 -
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V>
-