Class UnsynchronizedMultiMap<K,​V>

    • Constructor Summary

      Constructors 
      Constructor Description
      UnsynchronizedMultiMap()
      Creates a new empty UnsynchronizedMultiMap with default initial capacity.
      UnsynchronizedMultiMap​(int initialCapacity)
      Creates a new empty UnsynchronizedMultiMap with the specified initial capacity.
      UnsynchronizedMultiMap​(MultiMap<? extends K,​? extends V> source)
      Creates a new UnsynchronizedMultiMap containing the same mappings as the specified MultiMap.
      UnsynchronizedMultiMap​(Map<? extends K,​? extends V> source)
      Creates a new UnsynchronizedMultiMap containing the same mappings as the specified map.
    • Constructor Detail

      • UnsynchronizedMultiMap

        public UnsynchronizedMultiMap()
        Creates a new empty UnsynchronizedMultiMap with default initial capacity.
      • UnsynchronizedMultiMap

        public UnsynchronizedMultiMap​(int initialCapacity)
        Creates a new empty UnsynchronizedMultiMap with the specified initial capacity.
        Parameters:
        initialCapacity - the initial capacity
        Throws:
        IllegalArgumentException - if initialCapacity is negative
      • UnsynchronizedMultiMap

        public UnsynchronizedMultiMap​(Map<? extends K,​? extends V> source)
        Creates a new UnsynchronizedMultiMap containing the same mappings as the specified map. Null keys and null values in the source map cause a NullPointerException.
        Parameters:
        source - the map whose mappings are to be copied
        Throws:
        NullPointerException - if source is null, or if it contains null keys or null values
      • UnsynchronizedMultiMap

        public UnsynchronizedMultiMap​(MultiMap<? extends K,​? extends V> source)
        Creates a new UnsynchronizedMultiMap containing the same mappings as the specified MultiMap.
        Parameters:
        source - the multi-map whose mappings are to be copied
        Throws:
        NullPointerException - if source is null
    • Method Detail

      • get

        public V get​(K key)
        Description copied from interface: MultiMap
        Returns the value associated with the specified key, or null if no mapping exists. This method is designed for chained lookups across multiple levels.
        Specified by:
        get in interface MultiMap<K,​V>
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value associated with key, or null
      • getOpt

        public Optional<V> getOpt​(K key)
        Description copied from interface: MultiMap
        Returns the value associated with the specified key wrapped in an Optional, or an empty Optional if no mapping exists.
        Specified by:
        getOpt in interface MultiMap<K,​V>
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        an Optional containing the value, or empty
      • getOrCreate

        public V getOrCreate​(K key,
                             Supplier<V> factory)
        Description copied from interface: MultiMap
        Returns the value associated with the specified key. If no mapping exists, creates one using the given factory, inserts it, and returns the new value. This method is designed for chained writes across multiple levels.
        Specified by:
        getOrCreate in interface MultiMap<K,​V>
        Parameters:
        key - the key whose associated value is to be returned or created
        factory - the supplier used to create a new value if absent
        Returns:
        the existing or newly created value
      • containsKey

        public boolean containsKey​(K key)
        Description copied from interface: MultiMap
        Returns true if this map contains a mapping for the specified key.
        Specified by:
        containsKey in interface MultiMap<K,​V>
        Parameters:
        key - the key whose presence is to be tested
        Returns:
        true if this map contains a mapping for key
      • put

        public V put​(K key,
                     V value)
        Description copied from interface: MultiMap
        Associates the specified value with the specified key. If a mapping already exists for this key, the old value is replaced.
        Specified by:
        put in interface MultiMap<K,​V>
        Parameters:
        key - the key with which the value is to be associated
        value - the value to associate
        Returns:
        the previous value associated with key, or null if there was no mapping
      • remove

        public V remove​(K key)
        Description copied from interface: MultiMap
        Removes the mapping for the specified key, if present.
        Specified by:
        remove in interface MultiMap<K,​V>
        Parameters:
        key - the key whose mapping is to be removed
        Returns:
        the previous value associated with key, or null if there was no mapping
      • clear

        public void clear()
        Description copied from interface: MultiMap
        Removes all mappings from this map.
        Specified by:
        clear in interface MultiMap<K,​V>
      • size

        public int size()
        Description copied from interface: MultiMap
        Returns the number of key-value mappings at this level.
        Specified by:
        size in interface MultiMap<K,​V>
        Returns:
        the number of mappings
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: MultiMap
        Returns true if this map contains no mappings.
        Specified by:
        isEmpty in interface MultiMap<K,​V>
        Returns:
        true if empty
      • keySet

        public Set<K> keySet()
        Description copied from interface: MultiMap
        Returns a Set view of the keys contained in this map.
        Specified by:
        keySet in interface MultiMap<K,​V>
        Returns:
        a set view of the keys
      • values

        public Collection<V> values()
        Description copied from interface: MultiMap
        Returns a Collection view of the values contained in this map.
        Specified by:
        values in interface MultiMap<K,​V>
        Returns:
        a collection view of the values
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object