@Beta protected class ForwardingSortedMap.StandardKeySet extends AbstractSet<E>
SortedMap.keySet()
in terms of the methods of
ForwardingSortedMap
. In many cases, you may wish to override
ForwardingMap.keySet()
to forward to this implementation or a subclass thereof.Constructor and Description |
---|
ForwardingSortedMap.StandardKeySet()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
Comparator<? super K> |
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(Object o)
Returns true if this collection contains the specified element.
|
K |
first()
Returns the first (lowest) element currently in this set.
|
SortedSet<K> |
headSet(K toElement)
Returns a view of the portion of this set whose elements are
strictly less than toElement.
|
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
Iterator<K> |
iterator()
Returns an iterator over the elements contained in this collection.
|
K |
last()
Returns the last (highest) element currently in this set.
|
boolean |
remove(Object o)
Removes a single instance of the specified element from this
collection, if it is present (optional operation).
|
boolean |
removeAll(Collection<?> c)
Removes from this set all of its elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(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.
|
SortedSet<K> |
subSet(K fromElement,
K toElement)
Returns a view of the portion of this set whose elements range
from fromElement, inclusive, to toElement,
exclusive.
|
SortedSet<K> |
tailSet(K fromElement)
Returns a view of the portion of this set whose elements are
greater than or equal to fromElement.
|
equals, hashCode
add, addAll, containsAll, toArray, toArray, toString
public ForwardingSortedMap.StandardKeySet()
public Comparator<? super K> comparator()
java.util.SortedSet
comparator
in interface SortedSet<K>
public SortedSet<K> subSet(K fromElement, K toElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
public SortedSet<K> headSet(K toElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
public SortedSet<K> tailSet(K fromElement)
java.util.SortedSet
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
public K first()
java.util.SortedSet
public K last()
java.util.SortedSet
public Iterator<K> iterator()
java.util.AbstractCollection
iterator
in interface Iterable<K>
iterator
in interface Collection<K>
iterator
in interface Set<K>
iterator
in class AbstractCollection<K>
public int size()
java.util.Collection
size
in interface Collection<K>
size
in interface Set<K>
size
in class AbstractCollection<K>
public boolean isEmpty()
java.util.AbstractCollection
This implementation returns size() == 0.
isEmpty
in interface Collection<K>
isEmpty
in interface Set<K>
isEmpty
in class AbstractCollection<K>
public boolean contains(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 Collection<K>
contains
in interface Set<K>
contains
in class AbstractCollection<K>
o
- element whose presence in this collection is to be testedpublic boolean remove(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 Collection<K>
remove
in interface Set<K>
remove
in class AbstractCollection<K>
o
- element to be removed from this collection, if presentpublic 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 Collection<K>
clear
in interface Set<K>
clear
in class AbstractCollection<K>
public boolean removeAll(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 Collection<E>
removeAll
in interface Set<E>
removeAll
in class AbstractSet<E>
c
- collection containing elements to be removed from this setAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
public boolean retainAll(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 Collection<E>
retainAll
in interface Set<E>
retainAll
in class AbstractCollection<E>
c
- collection containing elements to be retained in this collectionAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
Copyright © 2010-2013. All Rights Reserved.