final class EmptyImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E>
ImmutableSortedMultiset.Builder<E>
ImmutableMultiset.EntrySetSerializedForm<E>
ImmutableCollection.ArrayBasedBuilder<E>
Multiset.Entry<E>
Modifier and Type | Field and Description |
---|---|
private ImmutableSortedSet<E> |
elementSet |
descendingMultiset
Constructor and Description |
---|
EmptyImmutableSortedMultiset(java.util.Comparator<? super E> comparator) |
Modifier and Type | Method and Description |
---|---|
ImmutableList<E> |
asList()
Returns a list view of the collection.
|
boolean |
containsAll(java.util.Collection<?> targets)
Returns
true if this multiset contains at least one occurrence of
each element in the specified collection. |
(package private) int |
copyIntoArray(java.lang.Object[] dst,
int offset)
Copies the contents of this immutable collection into the specified array at the specified
offset.
|
int |
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset (the
count of the element).
|
ImmutableSortedSet<E> |
elementSet()
Returns a
NavigableSet view of the distinct elements in this multiset. |
boolean |
equals(java.lang.Object object)
Compares the specified object with this multiset for equality.
|
Multiset.Entry<E> |
firstEntry()
Returns the entry of the first element in this multiset, or
null if
this multiset is empty. |
(package private) Multiset.Entry<E> |
getEntry(int index) |
ImmutableSortedMultiset<E> |
headMultiset(E upperBound,
BoundType boundType)
Returns a view of this multiset restricted to the elements less than
upperBound , optionally including upperBound itself. |
(package private) boolean |
isPartialView()
Returns
true if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. |
UnmodifiableIterator<E> |
iterator()
Returns an unmodifiable iterator across the elements in this collection.
|
Multiset.Entry<E> |
lastEntry()
Returns the entry of the last element in this multiset, or
null if
this multiset is empty. |
int |
size() |
ImmutableSortedMultiset<E> |
tailMultiset(E lowerBound,
BoundType boundType)
Returns a view of this multiset restricted to the elements greater than
lowerBound , optionally including lowerBound itself. |
comparator, copyOf, copyOf, copyOf, copyOf, copyOf, copyOfSorted, descendingMultiset, emptyMultiset, naturalOrder, of, of, of, of, of, of, of, orderedBy, pollFirstEntry, pollLastEntry, reverseOrder, subMultiset, writeReplace
builder
add, contains, copyFromEntries, entrySet, hashCode, remove, setCount, setCount, toString
add, addAll, clear, createAsList, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
entrySet
add, add, contains, hashCode, remove, remove, removeAll, retainAll, setCount, setCount, toString
private final ImmutableSortedSet<E> elementSet
EmptyImmutableSortedMultiset(java.util.Comparator<? super E> comparator)
public Multiset.Entry<E> firstEntry()
SortedMultiset
null
if
this multiset is empty.public Multiset.Entry<E> lastEntry()
SortedMultiset
null
if
this multiset is empty.public int count(@Nullable java.lang.Object element)
Multiset
Object.equals(java.lang.Object)
-based
multiset, this gives the same result as Collections.frequency(java.util.Collection<?>, java.lang.Object)
(which would presumably perform more poorly).
Note: the utility method Iterables.frequency(java.lang.Iterable<?>, java.lang.Object)
generalizes
this operation; it correctly delegates to this method when dealing with a
multiset, but it can also accept any other iterable type.
element
- the element to count occurrences ofpublic boolean containsAll(java.util.Collection<?> targets)
Multiset
true
if this multiset contains at least one occurrence of
each element in the specified collection.
This method refines Collection.containsAll(java.util.Collection<?>)
to further specify
that it may not throw an exception in response to any of elements
being null or of the wrong type.
Note: this method does not take into account the occurrence
count of an element in the two collections; it may still return true
even if elements
contains several occurrences of an element
and this multiset contains only one. This is no different than any other
collection type like List
, but it may be unexpected to the user of
a multiset.
containsAll
in interface Multiset<E>
containsAll
in interface java.util.Collection<E>
containsAll
in class ImmutableMultiset<E>
targets
- the collection of elements to be checked for containment in
this multisettrue
if this multiset contains at least one occurrence of
each element contained in elements
public int size()
public ImmutableSortedSet<E> elementSet()
SortedMultiset
NavigableSet
view of the distinct elements in this multiset.elementSet
in interface Multiset<E>
elementSet
in interface SortedMultiset<E>
elementSet
in interface SortedMultisetBridge<E>
elementSet
in class ImmutableSortedMultiset<E>
Multiset.Entry<E> getEntry(int index)
getEntry
in class ImmutableMultiset<E>
public ImmutableSortedMultiset<E> headMultiset(E upperBound, BoundType boundType)
SortedMultiset
upperBound
, optionally including upperBound
itself. The
returned multiset is a view of this multiset, so changes to one will be
reflected in the other. The returned multiset supports all operations that
this multiset supports.
The returned multiset will throw an IllegalArgumentException
on
attempts to add elements outside its range.
headMultiset
in interface SortedMultiset<E>
headMultiset
in class ImmutableSortedMultiset<E>
public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType)
SortedMultiset
lowerBound
, optionally including lowerBound
itself. The
returned multiset is a view of this multiset, so changes to one will be
reflected in the other. The returned multiset supports all operations that
this multiset supports.
The returned multiset will throw an IllegalArgumentException
on
attempts to add elements outside its range.
tailMultiset
in interface SortedMultiset<E>
tailMultiset
in class ImmutableSortedMultiset<E>
public UnmodifiableIterator<E> iterator()
ImmutableCollection
iterator
in interface Multiset<E>
iterator
in interface SortedIterable<E>
iterator
in interface SortedMultiset<E>
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in class ImmutableMultiset<E>
public boolean equals(@Nullable java.lang.Object object)
Multiset
true
if the given object is also a multiset and contains equal
elements with equal counts, regardless of order.boolean isPartialView()
ImmutableCollection
true
if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. This is generally
used to determine whether copyOf
implementations should make an explicit copy to avoid
memory leaks.isPartialView
in class ImmutableCollection<E>
int copyIntoArray(java.lang.Object[] dst, int offset)
ImmutableCollection
offset + size()
.copyIntoArray
in class ImmutableMultiset<E>
public ImmutableList<E> asList()
ImmutableCollection
asList
in class ImmutableCollection<E>