* Copyright (C) 2007 The Guava Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
import static com.google.common.base.Preconditions.checkNotNull;
Multimapwhose keys and values are ordered by their natural ordering or by supplied comparators. In all cases, this implementation uses
to determine equivalence of instances.
Warning: The comparators or comparables used must be consistent
with equals as explained by the
Otherwise, the resulting multiset will violate the general contract of
, which it is specified in terms of
The collections returned by
through the keys according to the key comparator ordering or the natural
ordering of the keys. Similarly,
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
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
See the Guava User Guide article on.
TreeMultimapinstance using explicit comparators. Neither comparator may be null; use
to specify natural order.
keyComparatorthe comparator that determines the key ordering
valueComparatorthe comparator that determines the value ordering