Class ForwardingSortedMultiset.StandardElementSet
- java.lang.Object
- 
- java.util.AbstractCollection<E>
- 
- java.util.AbstractSet<E>
- 
- com.google.common.collect.ForwardingSortedMultiset.StandardElementSet
 
 
 
- 
- All Implemented Interfaces:
- Iterable<E>,- Collection<E>,- NavigableSet<E>,- Set<E>,- SortedSet<E>
 - Enclosing class:
- ForwardingSortedMultiset<E>
 
 protected class ForwardingSortedMultiset.StandardElementSet extends AbstractSet<E> A sensible implementation ofSortedMultiset.elementSet()in terms of the following methods:Collection.clear(),SortedMultiset.comparator(),Multiset.contains(java.lang.Object),Multiset.containsAll(java.util.Collection<?>),Multiset.count(java.lang.Object),SortedMultiset.firstEntry()SortedMultiset.headMultiset(E, com.google.common.collect.BoundType),Collection.isEmpty(),SortedMultiset.lastEntry(),SortedMultiset.subMultiset(E, com.google.common.collect.BoundType, E, com.google.common.collect.BoundType),SortedMultiset.tailMultiset(E, com.google.common.collect.BoundType), thesize()anditerator()methods ofSortedMultiset.entrySet(), andMultiset.remove(Object, int). In many situations, you may wish to overrideSortedMultiset.elementSet()to forward to this implementation or a subclass thereof.- Since:
- 15.0
 
- 
- 
Constructor SummaryConstructors Constructor Description StandardElementSet()Constructor for use by subclasses.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Eceiling(E e)Returns the least element in this set greater than or equal to the given element, ornullif there is no such element.voidclear()Removes all of the elements from this collection (optional operation).Comparator<? super E>comparator()Returns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.booleancontains(Object o)Returnstrueif this collection contains the specified element.booleancontainsAll(Collection<?> c)Returnstrueif this collection contains all of the elements in the specified collection.Iterator<E>descendingIterator()Returns an iterator over the elements in this set, in descending order.NavigableSet<E>descendingSet()Returns a reverse order view of the elements contained in this set.Efirst()Returns the first (lowest) element currently in this set.Efloor(E e)Returns the greatest element in this set less than or equal to the given element, ornullif there is no such element.SortedSet<E>headSet(E toElement)Returns a view of the portion of this set whose elements are strictly less thantoElement.NavigableSet<E>headSet(E toElement, boolean inclusive)Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusiveis true)toElement.Ehigher(E e)Returns the least element in this set strictly greater than the given element, ornullif there is no such element.booleanisEmpty()Returnstrueif this collection contains no elements.Iterator<E>iterator()Returns an iterator over the elements contained in this collection.Elast()Returns the last (highest) element currently in this set.Elower(E e)Returns the greatest element in this set strictly less than the given element, ornullif there is no such element.EpollFirst()Retrieves and removes the first (lowest) element, or returnsnullif this set is empty.EpollLast()Retrieves and removes the last (highest) element, or returnsnullif this set is empty.booleanremove(Object o)Removes a single instance of the specified element from this collection, if it is present (optional operation).booleanremoveAll(Collection<?> c)Removes from this set all of its elements that are contained in the specified collection (optional operation).booleanretainAll(Collection<?> c)Retains only the elements in this collection that are contained in the specified collection (optional operation).intsize()Returns the number of elements in this collection.NavigableSet<E>subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)Returns a view of the portion of this set whose elements range fromfromElementtotoElement.SortedSet<E>subSet(E fromElement, E toElement)Returns a view of the portion of this set whose elements range fromfromElement, inclusive, totoElement, exclusive.SortedSet<E>tailSet(E fromElement)Returns a view of the portion of this set whose elements are greater than or equal tofromElement.NavigableSet<E>tailSet(E fromElement, boolean inclusive)Returns a view of the portion of this set whose elements are greater than (or equal to, ifinclusiveis true)fromElement.- 
Methods inherited from class java.util.AbstractSetequals, hashCode
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArray
 - 
Methods inherited from interface java.util.NavigableSetheadSet, iterator, subSet, tailSet
 - 
Methods inherited from interface java.util.Setadd, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 - 
Methods inherited from interface java.util.SortedSetcomparator, first, last, spliterator
 
- 
 
- 
- 
- 
Constructor Detail- 
StandardElementSetpublic StandardElementSet() Constructor for use by subclasses.
 
- 
 - 
Method Detail- 
lowerpublic E lower(E e) Description copied from interface:java.util.NavigableSetReturns the greatest element in this set strictly less than the given element, ornullif there is no such element.- Specified by:
- lowerin interface- NavigableSet<E>
- Parameters:
- e- the value to match
- Returns:
- the greatest element less than e, ornullif there is no such element
 
 - 
floorpublic E floor(E e) Description copied from interface:java.util.NavigableSetReturns the greatest element in this set less than or equal to the given element, ornullif there is no such element.- Specified by:
- floorin interface- NavigableSet<E>
- Parameters:
- e- the value to match
- Returns:
- the greatest element less than or equal to e, ornullif there is no such element
 
 - 
ceilingpublic E ceiling(E e) Description copied from interface:java.util.NavigableSetReturns the least element in this set greater than or equal to the given element, ornullif there is no such element.- Specified by:
- ceilingin interface- NavigableSet<E>
- Parameters:
- e- the value to match
- Returns:
- the least element greater than or equal to e, ornullif there is no such element
 
 - 
higherpublic E higher(E e) Description copied from interface:java.util.NavigableSetReturns the least element in this set strictly greater than the given element, ornullif there is no such element.- Specified by:
- higherin interface- NavigableSet<E>
- Parameters:
- e- the value to match
- Returns:
- the least element greater than e, ornullif there is no such element
 
 - 
descendingSetpublic NavigableSet<E> descendingSet() Description copied from interface:java.util.NavigableSetReturns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa. If either set is modified while an iteration over either set is in progress (except through the iterator's ownremoveoperation), the results of the iteration are undefined.The returned set has an ordering equivalent to Collections.reverseOrder(comparator()). The expressions.descendingSet().descendingSet()returns a view ofsessentially equivalent tos.- Specified by:
- descendingSetin interface- NavigableSet<E>
- Returns:
- a reverse order view of this set
 
 - 
descendingIteratorpublic Iterator<E> descendingIterator() Description copied from interface:java.util.NavigableSetReturns an iterator over the elements in this set, in descending order. Equivalent in effect todescendingSet().iterator().- Specified by:
- descendingIteratorin interface- NavigableSet<E>
- Returns:
- an iterator over the elements in this set, in descending order
 
 - 
pollFirstpublic E pollFirst() Description copied from interface:java.util.NavigableSetRetrieves and removes the first (lowest) element, or returnsnullif this set is empty.- Specified by:
- pollFirstin interface- NavigableSet<E>
- Returns:
- the first element, or nullif this set is empty
 
 - 
pollLastpublic E pollLast() Description copied from interface:java.util.NavigableSetRetrieves and removes the last (highest) element, or returnsnullif this set is empty.- Specified by:
- pollLastin interface- NavigableSet<E>
- Returns:
- the last element, or nullif this set is empty
 
 - 
subSetpublic NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) Description copied from interface:java.util.NavigableSetReturns a view of the portion of this set whose elements range fromfromElementtotoElement. IffromElementandtoElementare equal, the returned set is empty unlessfromInclusiveandtoInclusiveare both true. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.- Specified by:
- subSetin interface- NavigableSet<E>
- Parameters:
- fromElement- low endpoint of the returned set
- fromInclusive-- trueif the low endpoint is to be included in the returned view
- toElement- high endpoint of the returned set
- toInclusive-- trueif the high endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements range from
         fromElement, inclusive, totoElement, exclusive
 
 - 
headSetpublic NavigableSet<E> headSet(E toElement, boolean inclusive) Description copied from interface:java.util.NavigableSetReturns a view of the portion of this set whose elements are less than (or equal to, ifinclusiveis true)toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.- Specified by:
- headSetin interface- NavigableSet<E>
- Parameters:
- toElement- high endpoint of the returned set
- inclusive-- trueif the high endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements are less than
         (or equal to, if inclusiveis true)toElement
 
 - 
tailSetpublic NavigableSet<E> tailSet(E fromElement, boolean inclusive) Description copied from interface:java.util.NavigableSetReturns a view of the portion of this set whose elements are greater than (or equal to, ifinclusiveis true)fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.- Specified by:
- tailSetin interface- NavigableSet<E>
- Parameters:
- fromElement- low endpoint of the returned set
- inclusive-- trueif the low endpoint is to be included in the returned view
- Returns:
- a view of the portion of this set whose elements are greater
         than or equal to fromElement
 
 - 
iteratorpublic Iterator<E> iterator() Description copied from class:java.util.AbstractCollectionReturns an iterator over the elements contained in this collection.
 - 
comparatorpublic Comparator<? super E> comparator() Description copied from interface:java.util.SortedSetReturns the comparator used to order the elements in this set, ornullif this set uses the natural ordering of its elements.- Specified by:
- comparatorin interface- SortedSet<E>
- Returns:
- the comparator used to order the elements in this set,
         or nullif this set uses the natural ordering of its elements
 
 - 
subSetpublic SortedSet<E> subSet(E fromElement, E toElement) Description copied from interface:java.util.SortedSetReturns a view of the portion of this set whose elements range fromfromElement, inclusive, totoElement, exclusive. (IffromElementandtoElementare equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.
 - 
headSetpublic SortedSet<E> headSet(E toElement) Description copied from interface:java.util.SortedSetReturns a view of the portion of this set whose elements are strictly less thantoElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.
 - 
tailSetpublic SortedSet<E> tailSet(E fromElement) Description copied from interface:java.util.SortedSetReturns a view of the portion of this set whose elements are greater than or equal tofromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.The returned set will throw an IllegalArgumentExceptionon an attempt to insert an element outside its range.
 - 
firstpublic E first() Description copied from interface:java.util.SortedSetReturns the first (lowest) element currently in this set.
 - 
lastpublic E last() Description copied from interface:java.util.SortedSetReturns the last (highest) element currently in this set.
 - 
clearpublic void clear() Description copied from class:java.util.AbstractCollectionRemoves all of the elements from this collection (optional operation). The collection will be empty after this method returns.- Specified by:
- clearin interface- Collection<E>
- Specified by:
- clearin interface- Set<E>
- Overrides:
- clearin class- AbstractCollection<E>
 
 - 
containspublic boolean contains(Object o) Description copied from class:java.util.AbstractCollectionReturnstrueif this collection contains the specified element. More formally, returnstrueif and only if this collection contains at least one elementesuch thatObjects.equals(o, e).- Specified by:
- containsin interface- Collection<E>
- Specified by:
- containsin interface- Set<E>
- Overrides:
- containsin class- AbstractCollection<E>
- Parameters:
- o- element whose presence in this collection is to be tested
- Returns:
- trueif this collection contains the specified element
 
 - 
containsAllpublic boolean containsAll(Collection<?> c) Description copied from class:java.util.AbstractCollectionReturnstrueif this collection contains all of the elements in the specified collection.- Specified by:
- containsAllin interface- Collection<E>
- Specified by:
- containsAllin interface- Set<E>
- Overrides:
- containsAllin class- AbstractCollection<E>
- Parameters:
- c- collection to be checked for containment in this collection
- Returns:
- trueif this collection contains all of the elements in the specified collection
- See Also:
- AbstractCollection.contains(Object)
 
 - 
isEmptypublic boolean isEmpty() Description copied from class:java.util.AbstractCollectionReturnstrueif this collection contains no elements.- Specified by:
- isEmptyin interface- Collection<E>
- Specified by:
- isEmptyin interface- Set<E>
- Overrides:
- isEmptyin class- AbstractCollection<E>
- Returns:
- trueif this collection contains no elements
 
 - 
removepublic boolean remove(Object o) Description copied from class:java.util.AbstractCollectionRemoves a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an elementesuch thatObjects.equals(o, e), if this collection contains one or more such elements. Returnstrueif this collection contained the specified element (or equivalently, if this collection changed as a result of the call).- Specified by:
- removein interface- Collection<E>
- Specified by:
- removein interface- Set<E>
- Overrides:
- removein class- AbstractCollection<E>
- Parameters:
- o- element to be removed from this collection, if present
- Returns:
- trueif an element was removed as a result of this call
 
 - 
sizepublic int size() Description copied from interface:java.util.CollectionReturns the number of elements in this collection. If this collection contains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Specified by:
- sizein interface- Collection<E>
- Specified by:
- sizein interface- Set<E>
- Specified by:
- sizein class- AbstractCollection<E>
- Returns:
- the number of elements in this collection
 
 - 
removeAllpublic boolean removeAll(Collection<?> c) Description copied from class:java.util.AbstractSetRemoves from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.This implementation determines which is the smaller of this set and the specified collection, by invoking the sizemethod on each. If this set has fewer elements, then the implementation iterates over this set, checking each element returned by the iterator in turn to see if it is contained in the specified collection. If it is so contained, it is removed from this set with the iterator'sremovemethod. If the specified collection has fewer elements, then the implementation iterates over the specified collection, removing from this set each element returned by the iterator, using this set'sremovemethod.Note that this implementation will throw an UnsupportedOperationExceptionif the iterator returned by theiteratormethod does not implement theremovemethod.- Specified by:
- removeAllin interface- Collection<E>
- Specified by:
- removeAllin interface- Set<E>
- Overrides:
- removeAllin class- AbstractSet<E>
- Parameters:
- c- collection containing elements to be removed from this set
- Returns:
- trueif this set changed as a result of the call
- See Also:
- AbstractCollection.remove(Object),- AbstractCollection.contains(Object)
 
 - 
retainAllpublic boolean retainAll(Collection<?> c) Description copied from class:java.util.AbstractCollectionRetains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.- Specified by:
- retainAllin interface- Collection<E>
- Specified by:
- retainAllin interface- Set<E>
- Overrides:
- retainAllin class- AbstractCollection<E>
- Parameters:
- c- collection containing elements to be retained in this collection
- Returns:
- trueif this collection changed as a result of the call
- See Also:
- AbstractCollection.remove(Object),- AbstractCollection.contains(Object)
 
 
- 
 
-