Class TableMap<K,V>

java.lang.Object
org.aoju.bus.core.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
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • TableMap

      public TableMap()
      构造
    • TableMap

      public TableMap(int size)
      构造
      Parameters:
      size - 初始容量
    • TableMap

      public TableMap(K[] keys, V[] values)
      构造
      Parameters:
      keys - 键列表
      values - 值列表
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • getKey

      public K getKey(V value)
      根据value获得对应的key,只返回找到的第一个value对应的key值
      Parameters:
      value - 值
      Returns:
    • getValues

      public List<V> getValues(K key)
      获取指定key对应的所有值
      Parameters:
      key - 键
      Returns:
      值列表
    • getKeys

      public List<K> getKeys(V value)
      获取指定value对应的所有key
      Parameters:
      value - 值
      Returns:
      值列表
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • keys

      public List<K> keys()
      获取所有键,可重复,不可修改
      Returns:
      键列表
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • iterator

      public Iterator<Map.Entry<K,V>> iterator()
      Specified by:
      iterator in interface Iterable<K>
    • toString

      public String toString()
      Overrides:
      toString in class Object