001/* 002 * Copyright (C) 2008 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.collect; 018 019import static com.google.common.base.Preconditions.checkNotNull; 020import static com.google.common.collect.CollectPreconditions.checkEntryNotNull; 021 022import com.google.common.annotations.Beta; 023import com.google.common.annotations.GwtCompatible; 024import com.google.common.annotations.GwtIncompatible; 025import com.google.errorprone.annotations.CanIgnoreReturnValue; 026import com.google.j2objc.annotations.Weak; 027import com.google.j2objc.annotations.WeakOuter; 028import java.io.Serializable; 029import java.util.ArrayList; 030import java.util.Arrays; 031import java.util.Collection; 032import java.util.Comparator; 033import java.util.Iterator; 034import java.util.Map; 035import java.util.Map.Entry; 036import java.util.Set; 037import java.util.Spliterator; 038import java.util.function.BiConsumer; 039import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 040import org.checkerframework.checker.nullness.qual.Nullable; 041 042/** 043 * A {@link Multimap} whose contents will never change, with many other important properties 044 * detailed at {@link ImmutableCollection}. 045 * 046 * <p><b>Warning:</b> avoid <i>direct</i> usage of {@link ImmutableMultimap} as a type (as with 047 * {@link Multimap} itself). Prefer subtypes such as {@link ImmutableSetMultimap} or {@link 048 * ImmutableListMultimap}, which have well-defined {@link #equals} semantics, thus avoiding a common 049 * source of bugs and confusion. 050 * 051 * <p><b>Note:</b> every {@link ImmutableMultimap} offers an {@link #inverse} view, so there is no 052 * need for a distinct {@code ImmutableBiMultimap} type. 053 * 054 * <p><a name="iteration"></a> 055 * 056 * <p><b>Key-grouped iteration.</b> All view collections follow the same iteration order. In all 057 * current implementations, the iteration order always keeps multiple entries with the same key 058 * together. Any creation method that would customarily respect insertion order (such as {@link 059 * #copyOf(Multimap)}) instead preserves key-grouped order by inserting entries for an existing key 060 * immediately after the last entry having that key. 061 * 062 * <p>See the Guava User Guide article on <a href= 063 * "https://github.com/google/guava/wiki/ImmutableCollectionsExplained"> immutable collections</a>. 064 * 065 * @author Jared Levy 066 * @since 2.0 067 */ 068@GwtCompatible(emulated = true) 069public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V> 070 implements Serializable { 071 072 /** Returns an empty multimap. */ 073 public static <K, V> ImmutableMultimap<K, V> of() { 074 return ImmutableListMultimap.of(); 075 } 076 077 /** Returns an immutable multimap containing a single entry. */ 078 public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1) { 079 return ImmutableListMultimap.of(k1, v1); 080 } 081 082 /** Returns an immutable multimap containing the given entries, in order. */ 083 public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2) { 084 return ImmutableListMultimap.of(k1, v1, k2, v2); 085 } 086 087 /** 088 * Returns an immutable multimap containing the given entries, in the "key-grouped" insertion 089 * order described in the <a href="#iteration">class documentation</a>. 090 */ 091 public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) { 092 return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3); 093 } 094 095 /** 096 * Returns an immutable multimap containing the given entries, in the "key-grouped" insertion 097 * order described in the <a href="#iteration">class documentation</a>. 098 */ 099 public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) { 100 return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3, k4, v4); 101 } 102 103 /** 104 * Returns an immutable multimap containing the given entries, in the "key-grouped" insertion 105 * order described in the <a href="#iteration">class documentation</a>. 106 */ 107 public static <K, V> ImmutableMultimap<K, V> of( 108 K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) { 109 return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5); 110 } 111 112 // looking for of() with > 5 entries? Use the builder instead. 113 114 /** 115 * Returns a new builder. The generated builder is equivalent to the builder created by the {@link 116 * Builder} constructor. 117 */ 118 public static <K, V> Builder<K, V> builder() { 119 return new Builder<>(); 120 } 121 122 /** 123 * A builder for creating immutable multimap instances, especially {@code public static final} 124 * multimaps ("constant multimaps"). Example: 125 * 126 * <pre>{@code 127 * static final Multimap<String, Integer> STRING_TO_INTEGER_MULTIMAP = 128 * new ImmutableMultimap.Builder<String, Integer>() 129 * .put("one", 1) 130 * .putAll("several", 1, 2, 3) 131 * .putAll("many", 1, 2, 3, 4, 5) 132 * .build(); 133 * }</pre> 134 * 135 * <p>Builder instances can be reused; it is safe to call {@link #build} multiple times to build 136 * multiple multimaps in series. Each multimap contains the key-value mappings in the previously 137 * created multimaps. 138 * 139 * @since 2.0 140 */ 141 public static class Builder<K, V> { 142 Map<K, Collection<V>> builderMap; 143 @MonotonicNonNull Comparator<? super K> keyComparator; 144 @MonotonicNonNull Comparator<? super V> valueComparator; 145 146 /** 147 * Creates a new builder. The returned builder is equivalent to the builder generated by {@link 148 * ImmutableMultimap#builder}. 149 */ 150 public Builder() { 151 this.builderMap = Platform.preservesInsertionOrderOnPutsMap(); 152 } 153 154 Collection<V> newMutableValueCollection() { 155 return new ArrayList<>(); 156 } 157 158 /** Adds a key-value mapping to the built multimap. */ 159 @CanIgnoreReturnValue 160 public Builder<K, V> put(K key, V value) { 161 checkEntryNotNull(key, value); 162 Collection<V> valueCollection = builderMap.get(key); 163 if (valueCollection == null) { 164 builderMap.put(key, valueCollection = newMutableValueCollection()); 165 } 166 valueCollection.add(value); 167 return this; 168 } 169 170 /** 171 * Adds an entry to the built multimap. 172 * 173 * @since 11.0 174 */ 175 @CanIgnoreReturnValue 176 public Builder<K, V> put(Entry<? extends K, ? extends V> entry) { 177 return put(entry.getKey(), entry.getValue()); 178 } 179 180 /** 181 * Adds entries to the built multimap. 182 * 183 * @since 19.0 184 */ 185 @CanIgnoreReturnValue 186 @Beta 187 public Builder<K, V> putAll(Iterable<? extends Entry<? extends K, ? extends V>> entries) { 188 for (Entry<? extends K, ? extends V> entry : entries) { 189 put(entry); 190 } 191 return this; 192 } 193 194 /** 195 * Stores a collection of values with the same key in the built multimap. 196 * 197 * @throws NullPointerException if {@code key}, {@code values}, or any element in {@code values} 198 * is null. The builder is left in an invalid state. 199 */ 200 @CanIgnoreReturnValue 201 public Builder<K, V> putAll(K key, Iterable<? extends V> values) { 202 if (key == null) { 203 throw new NullPointerException("null key in entry: null=" + Iterables.toString(values)); 204 } 205 Collection<V> valueCollection = builderMap.get(key); 206 if (valueCollection != null) { 207 for (V value : values) { 208 checkEntryNotNull(key, value); 209 valueCollection.add(value); 210 } 211 return this; 212 } 213 Iterator<? extends V> valuesItr = values.iterator(); 214 if (!valuesItr.hasNext()) { 215 return this; 216 } 217 valueCollection = newMutableValueCollection(); 218 while (valuesItr.hasNext()) { 219 V value = valuesItr.next(); 220 checkEntryNotNull(key, value); 221 valueCollection.add(value); 222 } 223 builderMap.put(key, valueCollection); 224 return this; 225 } 226 227 /** 228 * Stores an array of values with the same key in the built multimap. 229 * 230 * @throws NullPointerException if the key or any value is null. The builder is left in an 231 * invalid state. 232 */ 233 @CanIgnoreReturnValue 234 public Builder<K, V> putAll(K key, V... values) { 235 return putAll(key, Arrays.asList(values)); 236 } 237 238 /** 239 * Stores another multimap's entries in the built multimap. The generated multimap's key and 240 * value orderings correspond to the iteration ordering of the {@code multimap.asMap()} view, 241 * with new keys and values following any existing keys and values. 242 * 243 * @throws NullPointerException if any key or value in {@code multimap} is null. The builder is 244 * left in an invalid state. 245 */ 246 @CanIgnoreReturnValue 247 public Builder<K, V> putAll(Multimap<? extends K, ? extends V> multimap) { 248 for (Entry<? extends K, ? extends Collection<? extends V>> entry : 249 multimap.asMap().entrySet()) { 250 putAll(entry.getKey(), entry.getValue()); 251 } 252 return this; 253 } 254 255 /** 256 * Specifies the ordering of the generated multimap's keys. 257 * 258 * @since 8.0 259 */ 260 @CanIgnoreReturnValue 261 public Builder<K, V> orderKeysBy(Comparator<? super K> keyComparator) { 262 this.keyComparator = checkNotNull(keyComparator); 263 return this; 264 } 265 266 /** 267 * Specifies the ordering of the generated multimap's values for each key. 268 * 269 * @since 8.0 270 */ 271 @CanIgnoreReturnValue 272 public Builder<K, V> orderValuesBy(Comparator<? super V> valueComparator) { 273 this.valueComparator = checkNotNull(valueComparator); 274 return this; 275 } 276 277 @CanIgnoreReturnValue 278 Builder<K, V> combine(Builder<K, V> other) { 279 for (Map.Entry<K, Collection<V>> entry : other.builderMap.entrySet()) { 280 putAll(entry.getKey(), entry.getValue()); 281 } 282 return this; 283 } 284 285 /** Returns a newly-created immutable multimap. */ 286 public ImmutableMultimap<K, V> build() { 287 Collection<Map.Entry<K, Collection<V>>> mapEntries = builderMap.entrySet(); 288 if (keyComparator != null) { 289 mapEntries = Ordering.from(keyComparator).<K>onKeys().immutableSortedCopy(mapEntries); 290 } 291 return ImmutableListMultimap.fromMapEntries(mapEntries, valueComparator); 292 } 293 } 294 295 /** 296 * Returns an immutable multimap containing the same mappings as {@code multimap}, in the 297 * "key-grouped" iteration order described in the class documentation. 298 * 299 * <p>Despite the method name, this method attempts to avoid actually copying the data when it is 300 * safe to do so. The exact circumstances under which a copy will or will not be performed are 301 * undocumented and subject to change. 302 * 303 * @throws NullPointerException if any key or value in {@code multimap} is null 304 */ 305 public static <K, V> ImmutableMultimap<K, V> copyOf(Multimap<? extends K, ? extends V> multimap) { 306 if (multimap instanceof ImmutableMultimap) { 307 @SuppressWarnings("unchecked") // safe since multimap is not writable 308 ImmutableMultimap<K, V> kvMultimap = (ImmutableMultimap<K, V>) multimap; 309 if (!kvMultimap.isPartialView()) { 310 return kvMultimap; 311 } 312 } 313 return ImmutableListMultimap.copyOf(multimap); 314 } 315 316 /** 317 * Returns an immutable multimap containing the specified entries. The returned multimap iterates 318 * over keys in the order they were first encountered in the input, and the values for each key 319 * are iterated in the order they were encountered. 320 * 321 * @throws NullPointerException if any key, value, or entry is null 322 * @since 19.0 323 */ 324 @Beta 325 public static <K, V> ImmutableMultimap<K, V> copyOf( 326 Iterable<? extends Entry<? extends K, ? extends V>> entries) { 327 return ImmutableListMultimap.copyOf(entries); 328 } 329 330 final transient ImmutableMap<K, ? extends ImmutableCollection<V>> map; 331 final transient int size; 332 333 // These constants allow the deserialization code to set final fields. This 334 // holder class makes sure they are not initialized unless an instance is 335 // deserialized. 336 @GwtIncompatible // java serialization is not supported 337 static class FieldSettersHolder { 338 static final Serialization.FieldSetter<ImmutableMultimap> MAP_FIELD_SETTER = 339 Serialization.getFieldSetter(ImmutableMultimap.class, "map"); 340 static final Serialization.FieldSetter<ImmutableMultimap> SIZE_FIELD_SETTER = 341 Serialization.getFieldSetter(ImmutableMultimap.class, "size"); 342 } 343 344 ImmutableMultimap(ImmutableMap<K, ? extends ImmutableCollection<V>> map, int size) { 345 this.map = map; 346 this.size = size; 347 } 348 349 // mutators (not supported) 350 351 /** 352 * Guaranteed to throw an exception and leave the multimap unmodified. 353 * 354 * @throws UnsupportedOperationException always 355 * @deprecated Unsupported operation. 356 */ 357 @CanIgnoreReturnValue 358 @Deprecated 359 @Override 360 public ImmutableCollection<V> removeAll(Object key) { 361 throw new UnsupportedOperationException(); 362 } 363 364 /** 365 * Guaranteed to throw an exception and leave the multimap unmodified. 366 * 367 * @throws UnsupportedOperationException always 368 * @deprecated Unsupported operation. 369 */ 370 @CanIgnoreReturnValue 371 @Deprecated 372 @Override 373 public ImmutableCollection<V> replaceValues(K key, Iterable<? extends V> values) { 374 throw new UnsupportedOperationException(); 375 } 376 377 /** 378 * Guaranteed to throw an exception and leave the multimap unmodified. 379 * 380 * @throws UnsupportedOperationException always 381 * @deprecated Unsupported operation. 382 */ 383 @Deprecated 384 @Override 385 public void clear() { 386 throw new UnsupportedOperationException(); 387 } 388 389 /** 390 * Returns an immutable collection of the values for the given key. If no mappings in the multimap 391 * have the provided key, an empty immutable collection is returned. The values are in the same 392 * order as the parameters used to build this multimap. 393 */ 394 @Override 395 public abstract ImmutableCollection<V> get(K key); 396 397 /** 398 * Returns an immutable multimap which is the inverse of this one. For every key-value mapping in 399 * the original, the result will have a mapping with key and value reversed. 400 * 401 * @since 11.0 402 */ 403 public abstract ImmutableMultimap<V, K> inverse(); 404 405 /** 406 * Guaranteed to throw an exception and leave the multimap unmodified. 407 * 408 * @throws UnsupportedOperationException always 409 * @deprecated Unsupported operation. 410 */ 411 @CanIgnoreReturnValue 412 @Deprecated 413 @Override 414 public boolean put(K key, V value) { 415 throw new UnsupportedOperationException(); 416 } 417 418 /** 419 * Guaranteed to throw an exception and leave the multimap unmodified. 420 * 421 * @throws UnsupportedOperationException always 422 * @deprecated Unsupported operation. 423 */ 424 @CanIgnoreReturnValue 425 @Deprecated 426 @Override 427 public boolean putAll(K key, Iterable<? extends V> values) { 428 throw new UnsupportedOperationException(); 429 } 430 431 /** 432 * Guaranteed to throw an exception and leave the multimap unmodified. 433 * 434 * @throws UnsupportedOperationException always 435 * @deprecated Unsupported operation. 436 */ 437 @CanIgnoreReturnValue 438 @Deprecated 439 @Override 440 public boolean putAll(Multimap<? extends K, ? extends V> multimap) { 441 throw new UnsupportedOperationException(); 442 } 443 444 /** 445 * Guaranteed to throw an exception and leave the multimap unmodified. 446 * 447 * @throws UnsupportedOperationException always 448 * @deprecated Unsupported operation. 449 */ 450 @CanIgnoreReturnValue 451 @Deprecated 452 @Override 453 public boolean remove(Object key, Object value) { 454 throw new UnsupportedOperationException(); 455 } 456 457 /** 458 * Returns {@code true} if this immutable multimap's implementation contains references to 459 * user-created objects that aren't accessible via this multimap's methods. This is generally used 460 * to determine whether {@code copyOf} implementations should make an explicit copy to avoid 461 * memory leaks. 462 */ 463 boolean isPartialView() { 464 return map.isPartialView(); 465 } 466 467 // accessors 468 469 @Override 470 public boolean containsKey(@Nullable Object key) { 471 return map.containsKey(key); 472 } 473 474 @Override 475 public boolean containsValue(@Nullable Object value) { 476 return value != null && super.containsValue(value); 477 } 478 479 @Override 480 public int size() { 481 return size; 482 } 483 484 // views 485 486 /** 487 * Returns an immutable set of the distinct keys in this multimap, in the same order as they 488 * appear in this multimap. 489 */ 490 @Override 491 public ImmutableSet<K> keySet() { 492 return map.keySet(); 493 } 494 495 @Override 496 Set<K> createKeySet() { 497 throw new AssertionError("unreachable"); 498 } 499 500 /** 501 * Returns an immutable map that associates each key with its corresponding values in the 502 * multimap. Keys and values appear in the same order as in this multimap. 503 */ 504 @Override 505 @SuppressWarnings("unchecked") // a widening cast 506 public ImmutableMap<K, Collection<V>> asMap() { 507 return (ImmutableMap) map; 508 } 509 510 @Override 511 Map<K, Collection<V>> createAsMap() { 512 throw new AssertionError("should never be called"); 513 } 514 515 /** Returns an immutable collection of all key-value pairs in the multimap. */ 516 @Override 517 public ImmutableCollection<Entry<K, V>> entries() { 518 return (ImmutableCollection<Entry<K, V>>) super.entries(); 519 } 520 521 @Override 522 ImmutableCollection<Entry<K, V>> createEntries() { 523 return new EntryCollection<>(this); 524 } 525 526 private static class EntryCollection<K, V> extends ImmutableCollection<Entry<K, V>> { 527 @Weak final ImmutableMultimap<K, V> multimap; 528 529 EntryCollection(ImmutableMultimap<K, V> multimap) { 530 this.multimap = multimap; 531 } 532 533 @Override 534 public UnmodifiableIterator<Entry<K, V>> iterator() { 535 return multimap.entryIterator(); 536 } 537 538 @Override 539 boolean isPartialView() { 540 return multimap.isPartialView(); 541 } 542 543 @Override 544 public int size() { 545 return multimap.size(); 546 } 547 548 @Override 549 public boolean contains(Object object) { 550 if (object instanceof Entry) { 551 Entry<?, ?> entry = (Entry<?, ?>) object; 552 return multimap.containsEntry(entry.getKey(), entry.getValue()); 553 } 554 return false; 555 } 556 557 private static final long serialVersionUID = 0; 558 } 559 560 @Override 561 UnmodifiableIterator<Entry<K, V>> entryIterator() { 562 return new UnmodifiableIterator<Entry<K, V>>() { 563 final Iterator<? extends Entry<K, ? extends ImmutableCollection<V>>> asMapItr = 564 map.entrySet().iterator(); 565 K currentKey = null; 566 Iterator<V> valueItr = Iterators.emptyIterator(); 567 568 @Override 569 public boolean hasNext() { 570 return valueItr.hasNext() || asMapItr.hasNext(); 571 } 572 573 @Override 574 public Entry<K, V> next() { 575 if (!valueItr.hasNext()) { 576 Entry<K, ? extends ImmutableCollection<V>> entry = asMapItr.next(); 577 currentKey = entry.getKey(); 578 valueItr = entry.getValue().iterator(); 579 } 580 return Maps.immutableEntry(currentKey, valueItr.next()); 581 } 582 }; 583 } 584 585 @Override 586 Spliterator<Entry<K, V>> entrySpliterator() { 587 return CollectSpliterators.flatMap( 588 asMap().entrySet().spliterator(), 589 keyToValueCollectionEntry -> { 590 K key = keyToValueCollectionEntry.getKey(); 591 Collection<V> valueCollection = keyToValueCollectionEntry.getValue(); 592 return CollectSpliterators.map( 593 valueCollection.spliterator(), (V value) -> Maps.immutableEntry(key, value)); 594 }, 595 Spliterator.SIZED | (this instanceof SetMultimap ? Spliterator.DISTINCT : 0), 596 size()); 597 } 598 599 @Override 600 public void forEach(BiConsumer<? super K, ? super V> action) { 601 checkNotNull(action); 602 asMap() 603 .forEach( 604 (key, valueCollection) -> valueCollection.forEach(value -> action.accept(key, value))); 605 } 606 607 /** 608 * Returns an immutable multiset containing all the keys in this multimap, in the same order and 609 * with the same frequencies as they appear in this multimap; to get only a single occurrence of 610 * each key, use {@link #keySet}. 611 */ 612 @Override 613 public ImmutableMultiset<K> keys() { 614 return (ImmutableMultiset<K>) super.keys(); 615 } 616 617 @Override 618 ImmutableMultiset<K> createKeys() { 619 return new Keys(); 620 } 621 622 @SuppressWarnings("serial") // Uses writeReplace, not default serialization 623 @WeakOuter 624 class Keys extends ImmutableMultiset<K> { 625 @Override 626 public boolean contains(@Nullable Object object) { 627 return containsKey(object); 628 } 629 630 @Override 631 public int count(@Nullable Object element) { 632 Collection<V> values = map.get(element); 633 return (values == null) ? 0 : values.size(); 634 } 635 636 @Override 637 public ImmutableSet<K> elementSet() { 638 return keySet(); 639 } 640 641 @Override 642 public int size() { 643 return ImmutableMultimap.this.size(); 644 } 645 646 @Override 647 Multiset.Entry<K> getEntry(int index) { 648 Map.Entry<K, ? extends Collection<V>> entry = map.entrySet().asList().get(index); 649 return Multisets.immutableEntry(entry.getKey(), entry.getValue().size()); 650 } 651 652 @Override 653 boolean isPartialView() { 654 return true; 655 } 656 657 @GwtIncompatible 658 @Override 659 Object writeReplace() { 660 return new KeysSerializedForm(ImmutableMultimap.this); 661 } 662 } 663 664 @GwtIncompatible 665 private static final class KeysSerializedForm implements Serializable { 666 final ImmutableMultimap<?, ?> multimap; 667 668 KeysSerializedForm(ImmutableMultimap<?, ?> multimap) { 669 this.multimap = multimap; 670 } 671 672 Object readResolve() { 673 return multimap.keys(); 674 } 675 } 676 677 /** 678 * Returns an immutable collection of the values in this multimap. Its iterator traverses the 679 * values for the first key, the values for the second key, and so on. 680 */ 681 @Override 682 public ImmutableCollection<V> values() { 683 return (ImmutableCollection<V>) super.values(); 684 } 685 686 @Override 687 ImmutableCollection<V> createValues() { 688 return new Values<>(this); 689 } 690 691 @Override 692 UnmodifiableIterator<V> valueIterator() { 693 return new UnmodifiableIterator<V>() { 694 Iterator<? extends ImmutableCollection<V>> valueCollectionItr = map.values().iterator(); 695 Iterator<V> valueItr = Iterators.emptyIterator(); 696 697 @Override 698 public boolean hasNext() { 699 return valueItr.hasNext() || valueCollectionItr.hasNext(); 700 } 701 702 @Override 703 public V next() { 704 if (!valueItr.hasNext()) { 705 valueItr = valueCollectionItr.next().iterator(); 706 } 707 return valueItr.next(); 708 } 709 }; 710 } 711 712 private static final class Values<K, V> extends ImmutableCollection<V> { 713 @Weak private final transient ImmutableMultimap<K, V> multimap; 714 715 Values(ImmutableMultimap<K, V> multimap) { 716 this.multimap = multimap; 717 } 718 719 @Override 720 public boolean contains(@Nullable Object object) { 721 return multimap.containsValue(object); 722 } 723 724 @Override 725 public UnmodifiableIterator<V> iterator() { 726 return multimap.valueIterator(); 727 } 728 729 @GwtIncompatible // not present in emulated superclass 730 @Override 731 int copyIntoArray(Object[] dst, int offset) { 732 for (ImmutableCollection<V> valueCollection : multimap.map.values()) { 733 offset = valueCollection.copyIntoArray(dst, offset); 734 } 735 return offset; 736 } 737 738 @Override 739 public int size() { 740 return multimap.size(); 741 } 742 743 @Override 744 boolean isPartialView() { 745 return true; 746 } 747 748 private static final long serialVersionUID = 0; 749 } 750 751 private static final long serialVersionUID = 0; 752}