Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * 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 java.util.Set;

Implementation of using hash tables.

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.

Keys and values may be null. 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.synchronizedSetMultimap(

Jared Levy
2.0 (imported from Google Collections Library)
 @GwtCompatible(serializable = true, emulated = true)
 public final class HashMultimap<K, V> extends AbstractSetMultimap<K, V> {
   private static final int DEFAULT_VALUES_PER_KEY = 2;
   transient int expectedValuesPerKey = ;

Creates a new, empty HashMultimap with the default initial capacities.
   public static <K, V> HashMultimap<K, V> create() {
     return new HashMultimap<K, V>();

Constructs an empty HashMultimap with enough capacity to hold the specified numbers of keys and values without rehashing.

expectedKeys the expected number of distinct keys
expectedValuesPerKey the expected average number of values per key
java.lang.IllegalArgumentException if expectedKeys or expectedValuesPerKey is negative
   public static <K, V> HashMultimap<K, V> create(
       int expectedKeysint expectedValuesPerKey) {
     return new HashMultimap<K, V>(expectedKeysexpectedValuesPerKey);

Constructs a HashMultimap with the same mappings as the specified multimap. If a key-value mapping appears multiple times in the input multimap, it only appears once in the constructed multimap.

multimap the multimap whose contents are copied to this multimap
   public static <K, V> HashMultimap<K, V> create(
       Multimap<? extends K, ? extends V> multimap) {
     return new HashMultimap<K, V>(multimap);
   private HashMultimap() {
     super(new HashMap<K, Collection<V>>());
   private HashMultimap(int expectedKeysint expectedValuesPerKey) {
     super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(expectedKeys));
     Preconditions.checkArgument(expectedValuesPerKey >= 0);
     this. = expectedValuesPerKey;
   private HashMultimap(Multimap<? extends K, ? extends V> multimap) {
     super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(


Creates an empty HashSet for a collection of values for one key.

a new HashSet containing a collection of values for one key
New to GrepCode? Check out our FAQ X