protected class ForwardingSortedMultiset.StandardElementSet extends java.util.AbstractSet<E>
SortedMultiset.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)
, the size()
and iterator()
methods of
SortedMultiset.entrySet()
, and Multiset.remove(Object, int)
. In many
situations, you may wish to override SortedMultiset.elementSet()
to forward to this
implementation or a subclass thereof.Constructor and Description |
---|
StandardElementSet()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
E |
ceiling(E e)
Returns the least element in this set greater than or equal to
the given element, or
null if there is no such element. |
void |
clear()
Removes all of the elements from this collection (optional operation).
|
java.util.Comparator<? super E> |
comparator()
Returns the comparator used to order the elements in this set,
or null if this set uses the natural ordering of its elements.
|
boolean |
contains(java.lang.Object o)
Returns true if this collection contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this collection contains all of the elements
in the specified collection.
|
java.util.Iterator<E> |
descendingIterator()
Returns an iterator over the elements in this set, in descending order.
|
java.util.NavigableSet<E> |
descendingSet()
Returns a reverse order view of the elements contained in this set.
|
E |
first()
Returns the first (lowest) element currently in this set.
|
E |
floor(E e)
Returns the greatest element in this set less than or equal to
the given element, or
null if there is no such element. |
java.util.SortedSet<E> |
headSet(E toElement)
Returns a view of the portion of this set whose elements are
strictly less than toElement.
|
java.util.NavigableSet<E> |
headSet(E toElement,
boolean inclusive)
Returns a view of the portion of this set whose elements are less than
(or equal to, if
inclusive is true) toElement . |
E |
higher(E e)
Returns the least element in this set strictly greater than the
given element, or
null if there is no such element. |
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements contained in this collection.
|
E |
last()
Returns the last (highest) element currently in this set.
|
E |
lower(E e)
Returns the greatest element in this set strictly less than the
given element, or
null if there is no such element. |
E |
pollFirst()
Retrieves and removes the first (lowest) element,
or returns
null if this set is empty. |
E |
pollLast()
Retrieves and removes the last (highest) element,
or returns
null if this set is empty. |
boolean |
remove(java.lang.Object o)
Removes a single instance of the specified element from this
collection, if it is present (optional operation).
|
boolean |
removeAll(java.util.Collection<?> c)
Removes from this set all of its elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
int |
size()
Returns the number of elements in this collection.
|
java.util.NavigableSet<E> |
subSet(E fromElement,
boolean fromInclusive,
E toElement,
boolean toInclusive)
Returns a view of the portion of this set whose elements range from
fromElement to toElement . |
java.util.SortedSet<E> |
subSet(E fromElement,
E toElement)
Returns a view of the portion of this set whose elements range
from fromElement, inclusive, to toElement,
exclusive.
|
java.util.SortedSet<E> |
tailSet(E fromElement)
Returns a view of the portion of this set whose elements are
greater than or equal to fromElement.
|
java.util.NavigableSet<E> |
tailSet(E fromElement,
boolean inclusive)
Returns a view of the portion of this set whose elements are greater
than (or equal to, if
inclusive is true) fromElement . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public StandardElementSet()
public E lower(E e)
java.util.NavigableSet
null
if there is no such element.lower
in interface java.util.NavigableSet<E>
e
- the value to matche
,
or null
if there is no such elementpublic E floor(E e)
java.util.NavigableSet
null
if there is no such element.floor
in interface java.util.NavigableSet<E>
e
- the value to matche
,
or null
if there is no such elementpublic E ceiling(E e)
java.util.NavigableSet
null
if there is no such element.ceiling
in interface java.util.NavigableSet<E>
e
- the value to matche
,
or null
if there is no such elementpublic E higher(E e)
java.util.NavigableSet
null
if there is no such element.higher
in interface java.util.NavigableSet<E>
e
- the value to matche
,
or null
if there is no such elementpublic java.util.NavigableSet<E> descendingSet()
java.util.NavigableSet
remove
operation), the results of
the iteration are undefined.
The returned set has an ordering equivalent to
Collections.reverseOrder
(comparator()).
The expression s.descendingSet().descendingSet()
returns a
view of s
essentially equivalent to s
.
descendingSet
in interface java.util.NavigableSet<E>
public java.util.Iterator<E> descendingIterator()
java.util.NavigableSet
descendingSet().iterator()
.descendingIterator
in interface java.util.NavigableSet<E>
public E pollFirst()
java.util.NavigableSet
null
if this set is empty.pollFirst
in interface java.util.NavigableSet<E>
null
if this set is emptypublic E pollLast()
java.util.NavigableSet
null
if this set is empty.pollLast
in interface java.util.NavigableSet<E>
null
if this set is emptypublic java.util.NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
java.util.NavigableSet
fromElement
to toElement
. If fromElement
and
toElement
are equal, the returned set is empty unless fromInclusive
and toInclusive
are 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 IllegalArgumentException
on an attempt to insert an element outside its range.
subSet
in interface java.util.NavigableSet<E>
fromElement
- low endpoint of the returned setfromInclusive
- true
if the low endpoint
is to be included in the returned viewtoElement
- high endpoint of the returned settoInclusive
- true
if the high endpoint
is to be included in the returned viewfromElement
, inclusive, to toElement
, exclusivepublic java.util.NavigableSet<E> headSet(E toElement, boolean inclusive)
java.util.NavigableSet
inclusive
is 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 IllegalArgumentException
on an attempt to insert an element outside its range.
headSet
in interface java.util.NavigableSet<E>
toElement
- high endpoint of the returned setinclusive
- true
if the high endpoint
is to be included in the returned viewinclusive
is true) toElement
public java.util.NavigableSet<E> tailSet(E fromElement, boolean inclusive)
java.util.NavigableSet
inclusive
is 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 IllegalArgumentException
on an attempt to insert an element outside its range.
tailSet
in interface java.util.NavigableSet<E>
fromElement
- low endpoint of the returned setinclusive
- true
if the low endpoint
is to be included in the returned viewfromElement
public java.util.Iterator<E> iterator()
java.util.AbstractCollection
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.Set<E>
public java.util.Comparator<? super E> comparator()
java.util.SortedSet
comparator
in interface java.util.SortedSet<E>
public java.util.SortedSet<E> subSet(E fromElement, E toElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
subSet
in interface java.util.SortedSet<E>
fromElement
- low endpoint (inclusive) of the returned settoElement
- high endpoint (exclusive) of the returned setpublic java.util.SortedSet<E> headSet(E toElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
headSet
in interface java.util.SortedSet<E>
toElement
- high endpoint (exclusive) of the returned setpublic java.util.SortedSet<E> tailSet(E fromElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
tailSet
in interface java.util.SortedSet<E>
fromElement
- low endpoint (inclusive) of the returned setpublic E first()
java.util.SortedSet
first
in interface java.util.SortedSet<E>
public E last()
java.util.SortedSet
last
in interface java.util.SortedSet<E>
public void clear()
java.util.AbstractCollection
This implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.
clear
in interface java.util.Collection<E>
clear
in interface java.util.Set<E>
clear
in class java.util.AbstractCollection<E>
public boolean contains(java.lang.Object o)
java.util.AbstractCollection
This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
contains
in interface java.util.Collection<E>
contains
in interface java.util.Set<E>
contains
in class java.util.AbstractCollection<E>
o
- element whose presence in this collection is to be testedpublic boolean containsAll(java.util.Collection<?> c)
java.util.AbstractCollection
This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.Set<E>
containsAll
in class java.util.AbstractCollection<E>
c
- collection to be checked for containment in this collectionAbstractCollection.contains(Object)
public boolean isEmpty()
java.util.AbstractCollection
This implementation returns size() == 0.
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.Set<E>
isEmpty
in class java.util.AbstractCollection<E>
public boolean remove(java.lang.Object o)
java.util.AbstractCollection
This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.
Note that this implementation throws an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection contains the specified object.
remove
in interface java.util.Collection<E>
remove
in interface java.util.Set<E>
remove
in class java.util.AbstractCollection<E>
o
- element to be removed from this collection, if presentpublic int size()
java.util.Collection
size
in interface java.util.Collection<E>
size
in interface java.util.Set<E>
size
in class java.util.AbstractCollection<E>
public boolean removeAll(java.util.Collection<?> c)
java.util.AbstractSet
This implementation determines which is the smaller of this set and the specified collection, by invoking the size method 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's remove method. 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's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method.
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.Set<E>
removeAll
in class java.util.AbstractSet<E>
c
- collection containing elements to be removed from this setAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
public boolean retainAll(java.util.Collection<?> c)
java.util.AbstractCollection
This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.
Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.Set<E>
retainAll
in class java.util.AbstractCollection<E>
c
- collection containing elements to be retained in this collectionAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
Copyright © 2010–2019 JBoss by Red Hat. All rights reserved.