Top Description Inners Fields Constructors Methods
com.google.common.collect

public abstract Class ImmutableMultiset<E>

extends ImmutableMultisetGwtSerializationDependencies<E>
implements Multiset<E>
Class Inheritance
All Implemented Interfaces
com.google.common.collect.Multiset, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
com.google.common.collect.ImmutableSortedMultisetFauxverideShim, com.google.common.collect.RegularImmutableMultiset, com.google.common.collect.JdkBackedImmutableMultiset, com.google.common.collect.ImmutableMultimap.Keys
Annotations
@GwtCompatible
serializable:true
emulated:true
@SuppressWarnings:serial
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, java.util.Objects.requireNonNull

A Multiset whose contents will never change, with many other important properties detailed at ImmutableCollection.

Grouped iteration. In all current implementations, duplicate elements always appear consecutively when iterating. Elements iterate in order by the first appearance of that element when the multiset was created.

See the Guava User Guide article on immutable collections.

Authors
Jared Levy, Louis Wasserman
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ImmutableMultiset.Builder<E>

A builder for creating immutable multiset instances, especially public static final multisets ("constant multisets").

pack-priv static class
private class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private transient ImmutableList<E>
private transient ImmutableSet<Multiset.Entry<E>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final int
add(E
the element to add occurrences of; may be null only if explicitly allowed by the implementation
element
,
int
the number of occurrences of the element to add. May be zero, in which case no change will be made.
occurrences
)

Implements com.google.common.collect.Multiset.add.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the collection unmodified.
public ImmutableList<E>
asList()

Overrides com.google.common.collect.ImmutableCollection.asList.

Returns an ImmutableList containing the same elements, in the same order, as this collection.
public static <E> ImmutableMultiset.Builder<E>
builder()

Returns a new builder.

public boolean
contains(Object
the element to check for
object
)

Implements abstract com.google.common.collect.ImmutableCollection.contains.

Implements com.google.common.collect.Multiset.contains, java.util.Collection.contains.

Determines whether this multiset contains the specified element.
private static <E> ImmutableMultiset<E>
copyFromElements(E... elements)

pack-priv static <E> ImmutableMultiset<E>
copyFromEntries(Collection<? extends Multiset.Entry<? extends E>> entries)

pack-priv int
copyIntoArray(@Nullable Object[] dst, int offset)

public static <E> ImmutableMultiset<E>
copyOf(E[] elements)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

public static <E> ImmutableMultiset<E>
copyOf(Iterable<? extends E> elements)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

public static <E> ImmutableMultiset<E>
copyOf(Iterator<? extends E> elements)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

private ImmutableSet<Multiset.Entry<E>>
public abstract ImmutableSet<E>
elementSet()

Redeclares com.google.common.collect.Multiset.elementSet.

Returns the set of distinct elements contained in this multiset.
public ImmutableSet<Multiset.Entry<E>>
entrySet()

Implements com.google.common.collect.Multiset.entrySet.

Returns a view of the contents of this multiset, grouped into Multiset.Entry instances, each providing an element of the multiset and the count of that element.
public boolean
equals(Object
object to be compared for equality with this collection
object
)

Overrides java.lang.Object.equals.

Implements com.google.common.collect.Multiset.equals, java.util.Collection.equals.

Compares the specified object with this multiset for equality.
pack-priv abstract Multiset.Entry<E>
getEntry(int index)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.google.common.collect.Multiset.hashCode, java.util.Collection.hashCode.

Returns the hash code for this multiset.
public UnmodifiableIterator<E>
iterator()

Implements abstract com.google.common.collect.ImmutableCollection.iterator.

Implements com.google.common.collect.Multiset.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this collection.
public static <E> ImmutableMultiset<E>
of()

Returns the empty immutable multiset.

public static <E> ImmutableMultiset<E>
of(E element)

Returns an immutable multiset containing a single element.

public static <E> ImmutableMultiset<E>
of(E e1, E e2)

Returns an immutable multiset containing the given elements, in order.

public static <E> ImmutableMultiset<E>
of(E e1, E e2, E e3)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

public static <E> ImmutableMultiset<E>
of(E e1, E e2, E e3, E e4)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

public static <E> ImmutableMultiset<E>
of(E e1, E e2, E e3, E e4, E e5)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

public static <E> ImmutableMultiset<E>
of(E e1, E e2, E e3, E e4, E e5, E e6, E... others)

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

private void
public final int
remove(Object
the element to conditionally remove occurrences of
element
,
int
the number of occurrences of the element to remove. May be zero, in which case no change will be made.
occurrences
)

Implements com.google.common.collect.Multiset.remove.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the collection unmodified.
public final int
setCount(E
the element to add or remove occurrences of; may be null only if explicitly allowed by the implementation
element
,
int
the desired count of the element in this multiset
count
)

Implements com.google.common.collect.Multiset.setCount.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the collection unmodified.
public final boolean
setCount(E
the element to conditionally set the count of; may be null only if explicitly allowed by the implementation
element
,
int
the expected present count of the element in this multiset
oldCount
,
int
the desired count of the element in this multiset
newCount
)

Implements com.google.common.collect.Multiset.setCount.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the collection unmodified.
public static <E> Collector<E, ?, ImmutableMultiset<E>>
toImmutableMultiset()

Returns a Collector that accumulates the input elements into a new ImmutableMultiset.

public static <T extends @Nullable Object, E> Collector<T, ?, ImmutableMultiset<E>>
toImmutableMultiset(Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction)

Returns a Collector that accumulates elements into an ImmutableMultiset whose elements are the result of applying elementFunction to the inputs, with counts equal to the result of applying countFunction to the inputs.

public String
toString()

Overrides java.util.AbstractCollection.toString.

Implements com.google.common.collect.Multiset.toString.

It is recommended, though not mandatory, that this method return the result of invoking toString on the entrySet, yielding a result such as [a x 3, c, d x 2, e].

pack-priv Object