Multimap whose keys and values are ordered by their natural ordering or
by supplied comparators. In all cases, this implementation uses Comparable#compareTo or
Comparator#compare instead of Object#equals to determine equivalence of
instances.Warning
The comparators or comparables used must be consistent with equals as
explained by the Comparable class specification. Otherwise, the resulting multiset will
violate the general contract of SetMultimap, which is specified in terms of Object#equals.
The collections returned by keySet and asMap iterate through the keys
according to the key comparator ordering or the natural ordering of the keys. Similarly, get, removeAll, and replaceValues return collections that iterate through the
values according to the value comparator ordering or the natural ordering of the values. The
collections generated by entries, keys, and values iterate across the
keys according to the above key ordering, and for each key they iterate across the values
according to the value ordering.
The multimap does not store duplicate key-value pairs. Adding a new key-value pair equal to an existing key-value pair has no effect.
Null keys and values are permitted (provided, of course, that the respective comparators support them). All optional multimap methods are supported, and all returned views are modifiable.
This class is not threadsafe when any concurrent operations update the multimap. Concurrent
read operations will work correctly. To allow concurrent update operations, wrap your multimap
with a call to Multimaps#synchronizedSortedSetMultimap.
See the Guava User Guide article on Multimap.
| Modifier and Type | Field and Description |
|---|---|
| private transient Comparator | |
| private static final long | |
| private transient Comparator |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| private | TreeMultimap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator, Multimap<? extends K, ? extends V> multimap)
|
| Modifier and Type | Method and Description |
|---|---|
| public NavigableMap | asMap()
Overrides com. Implements com. |
| public static <K extends Comparable | |
| public static <K extends @Nullable Object, V extends @Nullable Object> TreeMultimap | create(Comparator<? super K>
the comparator that determines the key ordering keyComparator, Comparator<? super V> the comparator that determines the value ordering valueComparator)Creates an empty |
| public static <K extends Comparable | |
| pack-priv Map | |
| pack-priv SortedSet | Returns: a newTreeSet containing a collection of values for one keyImplements abstract com. |
| pack-priv Collection | createCollection(K
key to associate with values in the collection key)Overrides com. |
| public NavigableSet | get(K key)
Overrides com. Implements com. |
| public Comparator | keyComparator()
Deprecated
Use
Returns the comparator that orders the multimap keys.
((NavigableSet<K>) multimap.keySet()).comparator() instead.
|
| public NavigableSet | keySet()
Overrides com. Implements com. |
| private void | |
| public Comparator | valueComparator()
Implements com. null indicating that
natural ordering is used.
|
| private void |
| keyComparator | back to summary |
|---|---|
| private transient Comparator<? super K> keyComparator | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides com. | |
| valueComparator | back to summary |
|---|---|
| private transient Comparator<? super V> valueComparator | |
| TreeMultimap | back to summary |
|---|---|
| pack-priv TreeMultimap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) | |
| TreeMultimap | back to summary |
|---|---|
| private TreeMultimap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator, Multimap<? extends K, ? extends V> multimap) | |
| asMap | back to summary |
|---|---|
| public NavigableMap Overrides com. Implements com. Doc from com. 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 support When passed a key that is present in the map, Though the method signature doesn't say so explicitly, the returned map has Because a
| |
| create | back to summary |
|---|---|
| public static <K extends Comparable Creates an empty | |
| create | back to summary |
|---|---|
| public static <K extends @Nullable Object, V extends @Nullable Object> TreeMultimap Creates an empty
| |
| create | back to summary |
|---|---|
| public static <K extends Comparable Constructs a
| |
| createAsMap | back to summary |
|---|---|
| pack-priv Map Overrides com.
| |
| createCollection | back to summary |
|---|---|
| pack-priv SortedSet Implements abstract com. Doc from com. Creates the collection of values for a single key. Collections with weak, soft, or phantom references are not supported. Each call to The returned collection class determines whether duplicate key-value pairs are allowed. Creates an empty | |
| createCollection | back to summary |
|---|---|
| pack-priv Collection Overrides com. Doc from com. Creates the collection of values for an explicitly provided key. By default, it simply calls
| |
| get | back to summary |
|---|---|
| public NavigableSet Overrides com. Implements com. Doc from com. 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
| |
| keyComparator | back to summary |
|---|---|
| public Comparator Deprecated Use Returns the comparator that orders the multimap keys.
| |
| keySet | back to summary |
|---|---|
| public NavigableSet Overrides com. Implements com. Doc from com. Returns a view collection of all distinct keys contained in this multimap. Note that the key set contains a key if and only if this multimap maps that key to at least one value. Changes to the returned set will update the underlying multimap, and vice versa. However, adding to the returned set is not possible. Because a
| |
| readObject | back to summary |
|---|---|
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
| |
| valueComparator | back to summary |
|---|---|
| public Comparator Implements com. Doc from com. Returns the comparator that orders the multimap values, with
| |
| writeObject | back to summary |
|---|---|
private void writeObject(ObjectOutputStream stream) throws IOException
| |