Class AbstractSortedSetMultimap<K,V>
- java.lang.Object
-
- com.google.common.collect.AbstractMultimap<K,V>
-
- com.google.common.collect.AbstractMapBasedMultimap<K,V>
-
- com.google.common.collect.AbstractSetMultimap<K,V>
-
- com.google.common.collect.AbstractSortedSetMultimap<K,V>
-
- All Implemented Interfaces:
Multimap<K,V>,SetMultimap<K,V>,SortedSetMultimap<K,V>,java.io.Serializable
- Direct Known Subclasses:
AbstractSortedKeySortedSetMultimap,Multimaps.CustomSortedSetMultimap
@GwtCompatible abstract class AbstractSortedSetMultimap<K,V> extends AbstractSetMultimap<K,V> implements SortedSetMultimap<K,V>
Basic implementation of theSortedSetMultimapinterface. It's a wrapper aroundAbstractMapBasedMultimapthat converts the returned collections into sorted sets. ThecreateCollection()method must return aSortedSet.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.AbstractMapBasedMultimap
AbstractMapBasedMultimap.NavigableAsMap, AbstractMapBasedMultimap.NavigableKeySet, AbstractMapBasedMultimap.WrappedCollection, AbstractMapBasedMultimap.WrappedList, AbstractMapBasedMultimap.WrappedNavigableSet, AbstractMapBasedMultimap.WrappedSet, AbstractMapBasedMultimap.WrappedSortedSet
-
Nested classes/interfaces inherited from class com.google.common.collect.AbstractMultimap
AbstractMultimap.Entries, AbstractMultimap.EntrySet, AbstractMultimap.Values
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSortedSetMultimap(java.util.Map<K,java.util.Collection<V>> map)Creates a new multimap that uses the provided map.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.(package private) <E> java.util.SortedSet<E>unmodifiableCollectionSubclass(java.util.Collection<E> collection)java.util.Collection<V>values()Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (sovalues().size() == size()).(package private) java.util.Collection<V>wrapCollection(K key, java.util.Collection<V> collection)Generates a decorated collection that remains consistent with the values in the multimap for the provided key.-
Methods inherited from class com.google.common.collect.AbstractSetMultimap
entries, equals, put
-
Methods inherited from class com.google.common.collect.AbstractMapBasedMultimap
backingMap, clear, containsKey, createAsMap, createCollection, createEntries, createKeys, createKeySet, createMaybeNavigableAsMap, createMaybeNavigableKeySet, createValues, entryIterator, entrySpliterator, forEach, setMap, size, valueIterator, valueSpliterator, wrapList
-
Methods inherited from class com.google.common.collect.AbstractMultimap
containsEntry, containsValue, hashCode, isEmpty, keys, keySet, putAll, putAll, remove, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.collect.Multimap
clear, containsEntry, containsKey, containsValue, forEach, hashCode, isEmpty, keys, keySet, put, putAll, putAll, remove, size
-
Methods inherited from interface com.google.common.collect.SetMultimap
entries, equals
-
Methods inherited from interface com.google.common.collect.SortedSetMultimap
valueComparator
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
createCollection
abstract java.util.SortedSet<V> createCollection()
Description copied from class:AbstractMapBasedMultimapCreates the collection of values for a single key.Collections with weak, soft, or phantom references are not supported. Each call to
createCollectionshould create a new instance.The returned collection class determines whether duplicate key-value pairs are allowed.
- Specified by:
createCollectionin classAbstractSetMultimap<K,V>- Returns:
- an empty collection of values
-
createUnmodifiableEmptyCollection
java.util.SortedSet<V> createUnmodifiableEmptyCollection()
Description copied from class:AbstractMapBasedMultimapCreates an unmodifiable, empty collection of values.This is used in
AbstractMapBasedMultimap.removeAll(java.lang.Object)on an empty key.- Overrides:
createUnmodifiableEmptyCollectionin classAbstractSetMultimap<K,V>
-
unmodifiableCollectionSubclass
<E> java.util.SortedSet<E> unmodifiableCollectionSubclass(java.util.Collection<E> collection)
- Overrides:
unmodifiableCollectionSubclassin classAbstractSetMultimap<K,V>
-
wrapCollection
java.util.Collection<V> wrapCollection(K key, java.util.Collection<V> collection)
Description copied from class:AbstractMapBasedMultimapGenerates a decorated collection that remains consistent with the values in the multimap for the provided key. Changes to the multimap may alter the returned collection, and vice versa.- Overrides:
wrapCollectionin classAbstractSetMultimap<K,V>
-
get
public java.util.SortedSet<V> get(K key)
Returns a collection view of all values associated with a key. If no mappings in the multimap have the provided key, an empty collection is returned.Changes to the returned collection will update the underlying multimap, and vice versa.
Because a
SortedSetMultimaphas unique sorted values for a given key, this method returns aSortedSet, instead of theCollectionspecified in theMultimapinterface.
-
removeAll
public java.util.SortedSet<V> removeAll(java.lang.Object key)
Removes all values associated with a given key. The returned collection is immutable.Because a
SortedSetMultimaphas unique sorted values for a given key, this method returns aSortedSet, instead of theCollectionspecified in theMultimapinterface.- Specified by:
removeAllin interfaceMultimap<K,V>- Specified by:
removeAllin interfaceSetMultimap<K,V>- Specified by:
removeAllin interfaceSortedSetMultimap<K,V>- Overrides:
removeAllin classAbstractSetMultimap<K,V>- Returns:
- the values that were removed (possibly empty). The returned collection may be modifiable, but updating it will have no effect on the multimap.
-
replaceValues
public 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. The returned collection is immutable.Because a
SortedSetMultimaphas unique sorted values for a given key, this method returns aSortedSet, instead of theCollectionspecified in theMultimapinterface.Any duplicates in
valueswill be stored in the multimap once.- Specified by:
replaceValuesin interfaceMultimap<K,V>- Specified by:
replaceValuesin interfaceSetMultimap<K,V>- Specified by:
replaceValuesin interfaceSortedSetMultimap<K,V>- Overrides:
replaceValuesin classAbstractSetMultimap<K,V>- Returns:
- the collection of replaced values, or an empty collection if no values were previously associated with the key. The collection may be modifiable, but updating it will have no effect on the multimap.
-
asMap
public java.util.Map<K,java.util.Collection<V>> asMap()
Returns a map view that associates each key with the corresponding values in the multimap. Changes to the returned map, such as element removal, will update the underlying multimap. The map does not supportsetValueon its entries,put, orputAll.When passed a key that is present in the map,
asMap().get(Object)has the same behavior asget(K), returning a live collection. When passed a key that is not present, however,asMap().get(Object)returnsnullinstead of an empty collection.Though the method signature doesn't say so explicitly, the returned map has
SortedSetvalues.
-
values
public java.util.Collection<V> values()
Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (sovalues().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.
-
-