com.google.common.collect
Class Multisets

java.lang.Object
  extended by com.google.common.collect.Multisets

public final class Multisets
extends Object

Provides static utility methods for creating and working with Multiset instances.

Author:
Kevin Bourrillion, Mike Bostock

Method Summary
static
<E> Multiset.Entry<E>
immutableEntry(E e, int n)
          Returns an immutable multiset entry with the specified element and count.
static
<E> Multiset<E>
unmodifiableMultiset(Multiset<? extends E> multiset)
          Returns an unmodifiable view of the specified multiset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unmodifiableMultiset

public static <E> Multiset<E> unmodifiableMultiset(Multiset<? extends E> multiset)
Returns an unmodifiable view of the specified multiset. Query operations on the returned multiset "read through" to the specified multiset, and attempts to modify the returned multiset result in an UnsupportedOperationException.

The returned multiset will be serializable if the specified multiset is serializable.

Parameters:
multiset - the multiset for which an unmodifiable view is to be generated
Returns:
an unmodifiable view of the multiset

immutableEntry

public static <E> Multiset.Entry<E> immutableEntry(@Nullable
                                                   E e,
                                                   int n)
Returns an immutable multiset entry with the specified element and count.

Parameters:
e - the element to be associated with the returned entry
n - the count to be associated with the returned entry
Throws:
IllegalArgumentException - if n is negative