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,
 * See the License for the specific language governing permissions and
 * limitations under the License.
A Multiset implementation with predictable iteration order. Its iterator orders elements according to when the first occurrence of the element was added. When the multiset contains multiple instances of an element, those instances are consecutive in the iteration order. If all occurrences of an element are removed, after which that element is added to the multiset, the element will appear at the end of the iteration.

See the Guava User Guide article on Multiset.

Kevin Bourrillion
Jared Levy
2.0 (imported from Google Collections Library)
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial"// we're overriding default serialization
public final class LinkedHashMultiset<E> extends AbstractMapBasedMultiset<E> {

Creates a new, empty LinkedHashMultiset using the default initial capacity.
  public static <E> LinkedHashMultiset<E> create() {
    return new LinkedHashMultiset<E>();

Creates a new, empty LinkedHashMultiset with the specified expected number of distinct elements.

distinctElements the expected number of distinct elements
java.lang.IllegalArgumentException if distinctElements is negative
  public static <E> LinkedHashMultiset<E> create(int distinctElements) {
    return new LinkedHashMultiset<E>(distinctElements);

Creates a new LinkedHashMultiset containing the specified elements.

This implementation is highly efficient when elements is itself a

elements the elements that the multiset should contain
  public static <E> LinkedHashMultiset<E> create(
      Iterable<? extends E> elements) {
    LinkedHashMultiset<E> multiset =
    return multiset;
  private LinkedHashMultiset() {
    super(new LinkedHashMap<E, Count>());
  private LinkedHashMultiset(int distinctElements) {
    // Could use newLinkedHashMapWithExpectedSize() if it existed
    super(new LinkedHashMap<E, Count>(Maps.capacity(distinctElements)));
New to GrepCode? Check out our FAQ X