Class ForwardingNavigableMap.StandardNavigableKeySet
- java.lang.Object
- 
- java.util.AbstractCollection<E>
- 
- java.util.AbstractSet<E>
- 
- com.google.common.collect.ForwardingNavigableMap.StandardNavigableKeySet
 
 
 
- 
- All Implemented Interfaces:
- Iterable<K>,- Collection<K>,- NavigableSet<K>,- Set<K>,- SortedSet<K>
 - Enclosing class:
- ForwardingNavigableMap<K,V>
 
 @Beta protected class ForwardingNavigableMap.StandardNavigableKeySet extends AbstractSet<E> A sensible implementation ofNavigableMap.navigableKeySet()in terms of the methods of thisNavigableMap. In many cases, you may wish to overrideForwardingNavigableMap.navigableKeySet()to forward to this implementation or a subclass thereof.- Since:
- 12.0
 
- 
- 
Constructor SummaryConstructors Constructor Description StandardNavigableKeySet()Constructor for use by subclasses.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Kceiling(K 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 K>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.Iterator<K>descendingIterator()Returns an iterator over the elements in this set, in descending order.NavigableSet<K>descendingSet()Returns a reverse order view of the elements contained in this set.Kfirst()Returns the first (lowest) element currently in this set.Kfloor(K e)Returns the greatest element in this set less than or equal to the given element, ornullif there is no such element.voidforEach(Consumer<? super K> action)Performs the given action for each element of theIterableuntil all elements have been processed or the action throws an exception.SortedSet<K>headSet(K toElement)Returns a view of the portion of this set whose elements are strictly less thantoElement.NavigableSet<K>headSet(K toElement, boolean inclusive)Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusiveis true)toElement.Khigher(K 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<K>iterator()Returns an iterator over the elements contained in this collection.Klast()Returns the last (highest) element currently in this set.Klower(K e)Returns the greatest element in this set strictly less than the given element, ornullif there is no such element.KpollFirst()Retrieves and removes the first (lowest) element, or returnsnullif this set is empty.KpollLast()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<K>subSet(K fromElement, boolean fromInclusive, K toElement, boolean toInclusive)Returns a view of the portion of this set whose elements range fromfromElementtotoElement.SortedSet<K>subSet(K fromElement, K toElement)Returns a view of the portion of this set whose elements range fromfromElement, inclusive, totoElement, exclusive.SortedSet<K>tailSet(K fromElement)Returns a view of the portion of this set whose elements are greater than or equal tofromElement.NavigableSet<K>tailSet(K 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.util.AbstractCollectionadd, addAll, containsAll, toArray, toArray, toString
 - 
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.NavigableSetiterator
 - 
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- 
StandardNavigableKeySetpublic StandardNavigableKeySet() Constructor for use by subclasses.
 
- 
 - 
Method Detail- 
lowerpublic K lower(K 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<K>
- Parameters:
- e- the value to match
- Returns:
- the greatest element less than e, ornullif there is no such element
 
 - 
floorpublic K floor(K 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<K>
- Parameters:
- e- the value to match
- Returns:
- the greatest element less than or equal to e, ornullif there is no such element
 
 - 
ceilingpublic K ceiling(K 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<K>
- Parameters:
- e- the value to match
- Returns:
- the least element greater than or equal to e, ornullif there is no such element
 
 - 
higherpublic K higher(K 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<K>
- Parameters:
- e- the value to match
- Returns:
- the least element greater than e, ornullif there is no such element
 
 - 
pollFirstpublic K 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<K>
- Returns:
- the first element, or nullif this set is empty
 
 - 
pollLastpublic K 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<K>
- Returns:
- the last element, or nullif this set is empty
 
 - 
descendingSetpublic NavigableSet<K> 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<K>
- Returns:
- a reverse order view of this set
 
 - 
descendingIteratorpublic Iterator<K> 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<K>
- Returns:
- an iterator over the elements in this set, in descending order
 
 - 
subSetpublic NavigableSet<K> subSet(K fromElement, boolean fromInclusive, K 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<K>
- 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
 
 - 
subSetpublic SortedSet<K> subSet(K fromElement, K 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.- Specified by:
- subSetin interface- NavigableSet<K>
- Specified by:
- subSetin interface- SortedSet<K>
- Parameters:
- fromElement- low endpoint (inclusive) of the returned set
- toElement- high endpoint (exclusive) of the returned set
- Returns:
- a view of the portion of this set whose elements range from
         fromElement, inclusive, totoElement, exclusive
 
 - 
headSetpublic NavigableSet<K> headSet(K 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<K>
- 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
 
 - 
headSetpublic SortedSet<K> headSet(K 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.- Specified by:
- headSetin interface- NavigableSet<K>
- Specified by:
- headSetin interface- SortedSet<K>
- Parameters:
- toElement- high endpoint (exclusive) of the returned set
- Returns:
- a view of the portion of this set whose elements are strictly
         less than toElement
 
 - 
tailSetpublic NavigableSet<K> tailSet(K 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<K>
- 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
 
 - 
tailSetpublic SortedSet<K> tailSet(K 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.- Specified by:
- tailSetin interface- NavigableSet<K>
- Specified by:
- tailSetin interface- SortedSet<K>
- Parameters:
- fromElement- low endpoint (inclusive) of the returned set
- Returns:
- a view of the portion of this set whose elements are greater
         than or equal to fromElement
 
 - 
comparatorpublic Comparator<? super K> 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<K>
- Returns:
- the comparator used to order the elements in this set,
         or nullif this set uses the natural ordering of its elements
 
 - 
firstpublic K first() Description copied from interface:java.util.SortedSetReturns the first (lowest) element currently in this set.
 - 
lastpublic K last() Description copied from interface:java.util.SortedSetReturns the last (highest) element currently in this set.
 - 
iteratorpublic Iterator<K> iterator() Description copied from class:java.util.AbstractCollectionReturns an iterator over the elements contained in this collection.- Specified by:
- iteratorin interface- Collection<K>
- Specified by:
- iteratorin interface- Iterable<K>
- Specified by:
- iteratorin interface- Set<K>
- Specified by:
- iteratorin class- AbstractCollection<K>
- Returns:
- an iterator over the elements contained in this collection
 
 - 
forEachpublic void forEach(Consumer<? super K> action) Description copied from interface:java.lang.IterablePerforms the given action for each element of theIterableuntil all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy. - Parameters:
- action- The action to be performed for each element
 
 - 
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<K>
- Specified by:
- sizein interface- Set<K>
- Specified by:
- sizein class- AbstractCollection<K>
- Returns:
- the number of elements in this collection
 
 - 
isEmptypublic boolean isEmpty() Description copied from class:java.util.AbstractCollectionReturnstrueif this collection contains no elements.- Specified by:
- isEmptyin interface- Collection<K>
- Specified by:
- isEmptyin interface- Set<K>
- Overrides:
- isEmptyin class- AbstractCollection<K>
- Returns:
- trueif this collection contains no elements
 
 - 
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<K>
- Specified by:
- containsin interface- Set<K>
- Overrides:
- containsin class- AbstractCollection<K>
- Parameters:
- o- element whose presence in this collection is to be tested
- Returns:
- trueif this collection contains the specified element
 
 - 
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<K>
- Specified by:
- removein interface- Set<K>
- Overrides:
- removein class- AbstractCollection<K>
- Parameters:
- o- element to be removed from this collection, if present
- Returns:
- trueif an element was removed as a result of this call
 
 - 
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<K>
- Specified by:
- clearin interface- Set<K>
- Overrides:
- clearin class- AbstractCollection<K>
 
 - 
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)
 
 
- 
 
-