@GwtCompatible abstract class AbstractSortedSetMultimap<K,V> extends AbstractSetMultimap<K,V> implements SortedSetMultimap<K,V>
SortedSetMultimap
interface. It's a
wrapper around AbstractMapBasedMultimap
that converts the returned
collections into sorted sets. The createCollection()
method
must return a SortedSet
.AbstractMapBasedMultimap.NavigableAsMap, AbstractMapBasedMultimap.NavigableKeySet, AbstractMapBasedMultimap.WrappedNavigableSet
AbstractMultimap.Values
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
protected |
AbstractSortedSetMultimap(java.util.Map<K,java.util.Collection<V>> map)
Creates a new multimap that uses the provided map.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<K,java.util.Collection<V>> |
asMap()
Returns a map view that associates each key with the corresponding values
in the multimap.
|
(package private) abstract java.util.SortedSet<V> |
createCollection()
Creates the collection of values for a single key.
|
(package private) java.util.SortedSet<V> |
createUnmodifiableEmptyCollection()
Creates an unmodifiable, empty collection of values.
|
java.util.SortedSet<V> |
get(K key)
Returns a collection view of all values associated with a key.
|
java.util.SortedSet<V> |
removeAll(java.lang.Object key)
Removes all values associated with a given key.
|
java.util.SortedSet<V> |
replaceValues(K key,
java.lang.Iterable<? extends V> values)
Stores a collection of values with the same key, replacing any existing
values for that key.
|
java.util.Collection<V> |
values()
Returns a view collection containing the value from each key-value
pair contained in this multimap, without collapsing duplicates (so
values().size() == size() ). |
entries, equals, put
backingMap, clear, containsKey, createAsMap, createCollection, createKeySet, entryIterator, setMap, size, unmodifiableCollectionSubclass, valueIterator, wrapCollection
containsEntry, containsValue, createEntries, createKeys, createValues, hashCode, isEmpty, keys, keySet, putAll, putAll, remove, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
valueComparator
entries, equals
clear, containsEntry, containsKey, containsValue, hashCode, isEmpty, keys, keySet, put, putAll, putAll, remove, size
private static final long serialVersionUID
abstract java.util.SortedSet<V> createCollection()
AbstractMapBasedMultimap
Collections with weak, soft, or phantom references are not supported.
Each call to createCollection
should create a new instance.
The returned collection class determines whether duplicate key-value pairs are allowed.
createCollection
in class AbstractSetMultimap<K,V>
java.util.SortedSet<V> createUnmodifiableEmptyCollection()
AbstractMapBasedMultimap
This is used in AbstractMapBasedMultimap.removeAll(java.lang.Object)
on an empty key.
createUnmodifiableEmptyCollection
in class AbstractSetMultimap<K,V>
public java.util.SortedSet<V> get(@Nullable K key)
Changes to the returned collection will update the underlying multimap, and vice versa.
Because a SortedSetMultimap
has unique sorted values for a given
key, this method returns a SortedSet
, instead of the
Collection
specified in the Multimap
interface.
public java.util.SortedSet<V> removeAll(@Nullable java.lang.Object key)
Because a SortedSetMultimap
has unique sorted values for a given
key, this method returns a SortedSet
, instead of the
Collection
specified in the Multimap
interface.
removeAll
in interface Multimap<K,V>
removeAll
in interface SetMultimap<K,V>
removeAll
in interface SortedSetMultimap<K,V>
removeAll
in class AbstractSetMultimap<K,V>
public java.util.SortedSet<V> replaceValues(@Nullable K key, java.lang.Iterable<? extends V> values)
Because a SortedSetMultimap
has unique sorted values for a given
key, this method returns a SortedSet
, instead of the
Collection
specified in the Multimap
interface.
Any duplicates in values
will be stored in the multimap once.
replaceValues
in interface Multimap<K,V>
replaceValues
in interface SetMultimap<K,V>
replaceValues
in interface SortedSetMultimap<K,V>
replaceValues
in class AbstractSetMultimap<K,V>
public java.util.Map<K,java.util.Collection<V>> asMap()
setValue
on its entries, put
, or putAll
.
When passed a key that is present in the map, asMap().get(Object)
has the same behavior as get(K)
, returning a
live collection. When passed a key that is not present, however, asMap().get(Object)
returns null
instead of an empty collection.
Though the method signature doesn't say so explicitly, the returned map
has SortedSet
values.
public java.util.Collection<V> values()
values().size() == size()
).
Changes to the returned collection will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.
The iterator generated by the returned collection traverses the values for one key, followed by the values of a second key, and so on. Consequently, the values do not follow their natural ordering or the ordering of the value comparator.