Class ListMultimap<K,​V>

    • Constructor Detail

      • ListMultimap

        public ListMultimap()
        Creates a new instance backed by a HashMap and ArrayList.
      • ListMultimap

        public ListMultimap​(Multimap<K,​V> multimap)
        Creates a new instance backed by a HashMap and ArrayList. All key-value mappings are copied from the input multimap.
        Parameters:
        multimap -
    • Method Detail

      • size

        public int size()
        Description copied from interface: Multimap
        Unlike Guava'sMultimap#size() this method returns the number of key-value mappings.
        Specified by:
        size in interface Multimap<K,​V>
        Returns:
        the number of key-value mappings
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Multimap<K,​V>
        Returns:
        true if there are no key-value mappings
      • get

        public C get​(K key)
        Description copied from interface: Multimap
        This method never returns null. If no collection of values for a given key exists a new value collection is initialized.
        Specified by:
        get in interface Multimap<K,​V>
        Returns:
        the collection of values for the given key
      • put

        public boolean put​(K key,
                           V value)
        Specified by:
        put in interface Multimap<K,​V>
        Returns:
        true if the the size of the collection associated with the given key increased, false otherwise (e.g. if the collection of values doesn't allow duplicates)
      • putAll

        public boolean putAll​(K key,
                              Collection<? extends V> values)
        Specified by:
        putAll in interface Multimap<K,​V>
        Returns:
        true if the the size of the collection associated with the given key increased, false otherwise (e.g. if the collection of values doesn't allow duplicates)
      • replaceValues

        public C replaceValues​(K key,
                               Iterable<? extends V> values)
        Description copied from interface: Multimap
        Note that the original collection of values is completely replaced by a new collection which contains all elements from the given iterable. If the collection of values doesn't allow duplicates, these elements are removed.
        Specified by:
        replaceValues in interface Multimap<K,​V>
        Returns:
        the collection of replaced values
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Multimap<K,​V>
        Returns:
        true if the multimap contains a mapping for the given key
      • keySet

        public Set<K> keySet()
        Specified by:
        keySet in interface Multimap<K,​V>
        Returns:
        an immutable set of keys
      • values

        public List<V> values()
        Description copied from interface: Multimap
        The list may include the same value multiple times if it occurs in multiple mappings or if the collection of values for the mapping allows duplicate elements.
        Specified by:
        values in interface Multimap<K,​V>
        Returns:
        an immutable list of all the values in the multimap
      • uniqueValues

        public Set<V> uniqueValues()
        Specified by:
        uniqueValues in interface Multimap<K,​V>
        Returns:
        an immutable set of all the values in the multimap
      • clear

        public void clear()
        Description copied from interface: Multimap
        Removes all of the mappings.
        Specified by:
        clear in interface Multimap<K,​V>