Class ImmutableSortedSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableSet<E>
-
- com.google.common.collect.ImmutableSortedSet<E>
-
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,NavigableSet<E>
,Set<E>
,SortedSet<E>
- Direct Known Subclasses:
ContiguousSet
@GwtCompatible(serializable=true, emulated=true) public abstract class ImmutableSortedSet<E> extends ImmutableSet<E> implements NavigableSet<E>
ANavigableSet
whose contents will never change, with many other important properties detailed atImmutableCollection
.Warning: as with any sorted collection, you are strongly advised not to use a
Comparator
orComparable
type whose comparison behavior is inconsistent with equals. That is,a.compareTo(b)
orcomparator.compare(a, b)
should equal zero if and only ifa.equals(b)
. If this advice is not followed, the resulting collection will not correctly obey its specification.See the Guava User Guide article on immutable collections.
- Since:
- 2.0 (implements
NavigableSet
since 12.0) - Author:
- Jared Levy, Louis Wasserman
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableSortedSet.Builder<E>
A builder for creating immutable sorted set instances, especiallypublic static final
sets ("constant sets"), with a given comparator.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <E> ImmutableSortedSet.Builder<E>
builder()
Deprecated.UsenaturalOrder()
, which offers better type-safety.static <E> ImmutableSortedSet.Builder<E>
builderWithExpectedSize(int expectedSize)
Deprecated.Not supported by ImmutableSortedSet.E
ceiling(E e)
Returns the least element in this set greater than or equal to the given element, ornull
if there is no such element.Comparator<? super E>
comparator()
Returns the comparator that orders the elements, which isOrdering.natural()
when the natural ordering of the elements is used.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>copyOf(E[] elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
copyOf(E[] elements)
Deprecated.Pass parameters of typeComparable
to usecopyOf(Comparable[])
.static <E> ImmutableSortedSet<E>
copyOf(Iterable<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
copyOf(Collection<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
copyOf(Comparator<? super E> comparator, Iterable<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
.static <E> ImmutableSortedSet<E>
copyOf(Comparator<? super E> comparator, Collection<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
.static <E> ImmutableSortedSet<E>
copyOf(Comparator<? super E> comparator, Iterator<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
.static <E> ImmutableSortedSet<E>
copyOf(Iterator<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
copyOfSorted(SortedSet<E> sortedSet)
Returns an immutable sorted set containing the elements of a sorted set, sorted by the sameComparator
.abstract UnmodifiableIterator<E>
descendingIterator()
Returns an iterator over the elements in this set, in descending order.ImmutableSortedSet<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, ornull
if there is no such element.ImmutableSortedSet<E>
headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less thantoElement
.ImmutableSortedSet<E>
headSet(E toElement, boolean inclusive)
Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusive
is true)toElement
.E
higher(E e)
Returns the least element in this set strictly greater than the given element, ornull
if there is no such element.abstract UnmodifiableIterator<E>
iterator()
Returns an unmodifiable iterator across the elements 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, ornull
if there is no such element.static <E extends Comparable<?>>
ImmutableSortedSet.Builder<E>naturalOrder()
Returns a builder that creates immutable sorted sets whose elements are ordered by their natural ordering.static <E> ImmutableSortedSet<E>
of()
Returns the empty immutable sorted set.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E element)
Returns an immutable sorted set containing a single element.static <E> ImmutableSortedSet<E>
of(E element)
Deprecated.Pass a parameter of typeComparable
to useof(Comparable)
.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E e1, E e2)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
of(E e1, E e2)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable)
.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E e1, E e2, E e3)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
of(E e1, E e2, E e3)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable)
.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E e1, E e2, E e3, E e4)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
of(E e1, E e2, E e3, E e4)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable, Comparable)
.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E e1, E e2, E e3, E e4, E e5)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
of(E e1, E e2, E e3, E e4, E e5)
Deprecated.Pass the parameters of typeComparable
to useof( Comparable, Comparable, Comparable, Comparable, Comparable)
.static <E extends Comparable<? super E>>
ImmutableSortedSet<E>of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining)
Returns an immutable sorted set containing the given elements sorted by their natural ordering.static <E> ImmutableSortedSet<E>
of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable, Comparable, Comparable, Comparable, Comparable...)
.static <E> ImmutableSortedSet.Builder<E>
orderedBy(Comparator<E> comparator)
Returns a builder that creates immutable sorted sets with an explicit comparator.E
pollFirst()
Deprecated.Unsupported operation.E
pollLast()
Deprecated.Unsupported operation.static <E extends Comparable<?>>
ImmutableSortedSet.Builder<E>reverseOrder()
Returns a builder that creates immutable sorted sets whose elements are ordered by the reverse of their natural ordering.ImmutableSortedSet<E>
subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Returns a view of the portion of this set whose elements range fromfromElement
totoElement
.ImmutableSortedSet<E>
subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range fromfromElement
, inclusive, totoElement
, exclusive.ImmutableSortedSet<E>
tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal tofromElement
.ImmutableSortedSet<E>
tailSet(E fromElement, boolean inclusive)
Returns a view of the portion of this set whose elements are greater than (or equal to, ifinclusive
is true)fromElement
.-
Methods inherited from class com.google.common.collect.ImmutableSet
asList, equals, hashCode
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, contains, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, size, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
-
Methods inherited from interface java.util.SortedSet
spliterator
-
-
-
-
Method Detail
-
of
public static <E> ImmutableSortedSet<E> of()
Returns the empty immutable sorted set.- Type Parameters:
E
- theSet
's element type- Returns:
- an empty
Set
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E element)
Returns an immutable sorted set containing a single element.- Type Parameters:
E
- theSet
's element type- Parameters:
element
- the single element- Returns:
- a
Set
containing the specified element
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second element- Returns:
- a
Set
containing the specified elements - Throws:
NullPointerException
- if any element is null
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2, E e3)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third element- Returns:
- a
Set
containing the specified elements - Throws:
NullPointerException
- if any element is null
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth element- Returns:
- a
Set
containing the specified elements - Throws:
NullPointerException
- if any element is null
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth element- Returns:
- a
Set
containing the specified elements - Throws:
NullPointerException
- if any element is null
-
of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth elemente6
- the sixth elementremaining
- the seventh element- Returns:
- a
Set
containing the specified elements - Throws:
NullPointerException
- if any element is null- Since:
- 3.0 (source-compatible since 2.0)
-
copyOf
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> copyOf(E[] elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according toComparable.compareTo(T)
, only the first one specified is included.- Throws:
NullPointerException
- if any ofelements
is null- Since:
- 3.0
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Iterable<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according tocompareTo()
, only the first one specified is included. To create a copy of aSortedSet
that preserves the comparator, callcopyOfSorted(java.util.SortedSet<E>)
instead. This method iterates overelements
at most once.Note that if
s
is aSet<String>
, thenImmutableSortedSet.copyOf(s)
returns anImmutableSortedSet<String>
containing each of the strings ins
, whileImmutableSortedSet.of(s)
returns anImmutableSortedSet<Set<String>>
containing one element (the given set itself).Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
This method is not type-safe, as it may be called on elements that are not mutually comparable.
- Throws:
ClassCastException
- if the elements are not mutually comparableNullPointerException
- if any ofelements
is null
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Collection<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according tocompareTo()
, only the first one specified is included. To create a copy of aSortedSet
that preserves the comparator, callcopyOfSorted(java.util.SortedSet<E>)
instead. This method iterates overelements
at most once.Note that if
s
is aSet<String>
, thenImmutableSortedSet.copyOf(s)
returns anImmutableSortedSet<String>
containing each of the strings ins
, whileImmutableSortedSet.of(s)
returns anImmutableSortedSet<Set<String>>
containing one element (the given set itself).Note: Despite what the method name suggests, if
elements
is anImmutableSortedSet
, it may be returned instead of a copy.This method is not type-safe, as it may be called on elements that are not mutually comparable.
This method is safe to use even when
elements
is a synchronized or concurrent collection that is currently being modified by another thread.- Type Parameters:
E
- theSet
's element type- Parameters:
elements
- aCollection
from which elements are drawn, must be non-null- Returns:
- a
Set
containing the elements of the givenCollection
- Throws:
ClassCastException
- if the elements are not mutually comparableNullPointerException
- if any ofelements
is null- Since:
- 7.0 (source-compatible since 2.0)
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Iterator<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by their natural ordering. When multiple elements are equivalent according tocompareTo()
, only the first one specified is included.This method is not type-safe, as it may be called on elements that are not mutually comparable.
- Throws:
ClassCastException
- if the elements are not mutually comparableNullPointerException
- if any ofelements
is null
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Comparator<? super E> comparator, Iterator<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
. When multiple elements are equivalent according tocompareTo()
, only the first one specified is included.- Throws:
NullPointerException
- ifcomparator
or any ofelements
is null
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Comparator<? super E> comparator, Iterable<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
. When multiple elements are equivalent according tocompare()
, only the first one specified is included. This method iterates overelements
at most once.Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
- Throws:
NullPointerException
- ifcomparator
or any ofelements
is null
-
copyOf
public static <E> ImmutableSortedSet<E> copyOf(Comparator<? super E> comparator, Collection<? extends E> elements)
Returns an immutable sorted set containing the given elements sorted by the givenComparator
. When multiple elements are equivalent according tocompareTo()
, only the first one specified is included.Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
This method is safe to use even when
elements
is a synchronized or concurrent collection that is currently being modified by another thread.- Throws:
NullPointerException
- ifcomparator
or any ofelements
is null- Since:
- 7.0 (source-compatible since 2.0)
-
copyOfSorted
public static <E> ImmutableSortedSet<E> copyOfSorted(SortedSet<E> sortedSet)
Returns an immutable sorted set containing the elements of a sorted set, sorted by the sameComparator
. That behavior differs fromcopyOf(Iterable)
, which always uses the natural ordering of the elements.Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
This method is safe to use even when
sortedSet
is a synchronized or concurrent collection that is currently being modified by another thread.- Throws:
NullPointerException
- ifsortedSet
or any of its elements is null
-
orderedBy
public static <E> ImmutableSortedSet.Builder<E> orderedBy(Comparator<E> comparator)
Returns a builder that creates immutable sorted sets with an explicit comparator. If the comparator has a more general type than the set being generated, such as creating aSortedSet<Integer>
with aComparator<Number>
, use theImmutableSortedSet.Builder
constructor instead.- Throws:
NullPointerException
- ifcomparator
is null
-
reverseOrder
public static <E extends Comparable<?>> ImmutableSortedSet.Builder<E> reverseOrder()
Returns a builder that creates immutable sorted sets whose elements are ordered by the reverse of their natural ordering.
-
naturalOrder
public static <E extends Comparable<?>> ImmutableSortedSet.Builder<E> naturalOrder()
Returns a builder that creates immutable sorted sets whose elements are ordered by their natural ordering. The sorted sets useOrdering.natural()
as the comparator. This method provides more type-safety thanbuilder()
, as it can be called only for classes that implementComparable
.
-
comparator
public Comparator<? super E> comparator()
Returns the comparator that orders the elements, which isOrdering.natural()
when the natural ordering of the elements is used. Note that its behavior is not consistent withSortedSet.comparator()
, which returnsnull
to indicate natural ordering.- Specified by:
comparator
in interfaceSortedSet<E>
- Returns:
- the comparator used to order the elements in this set,
or
null
if this set uses the natural ordering of its elements
-
iterator
public abstract UnmodifiableIterator<E> iterator()
Description copied from class:ImmutableCollection
Returns an unmodifiable iterator across the elements in this collection.- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in interfaceNavigableSet<E>
- Specified by:
iterator
in interfaceSet<E>
- Specified by:
iterator
in classImmutableSet<E>
- Returns:
- an iterator over the elements contained in this collection
-
headSet
public ImmutableSortedSet<E> headSet(E toElement)
Returns 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
IllegalArgumentException
on an attempt to insert an element outside its range.Equivalent to
headSet(toElement, false)
.This method returns a serializable
ImmutableSortedSet
.The
SortedSet.headSet(E)
documentation states that a subset of a subset throws anIllegalArgumentException
if passed atoElement
greater than an earliertoElement
. However, this method doesn't throw an exception in that situation, but instead keeps the originaltoElement
.
-
headSet
public ImmutableSortedSet<E> headSet(E toElement, boolean inclusive)
Description copied from interface:java.util.NavigableSet
Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusive
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.- Specified by:
headSet
in interfaceNavigableSet<E>
- Parameters:
toElement
- high endpoint of the returned setinclusive
-true
if 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
inclusive
is true)toElement
- Since:
- 12.0
-
subSet
public ImmutableSortedSet<E> subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range fromfromElement
, inclusive, totoElement
, exclusive. (IffromElement
andtoElement
are 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
IllegalArgumentException
on an attempt to insert an element outside its range.Equivalent to
subSet(fromElement, true, toElement, false)
.This method returns a serializable
ImmutableSortedSet
.The
SortedSet.subSet(E, E)
documentation states that a subset of a subset throws anIllegalArgumentException
if passed afromElement
smaller than an earlierfromElement
. However, this method doesn't throw an exception in that situation, but instead keeps the originalfromElement
. Similarly, this method keeps the originaltoElement
, instead of throwing an exception, if passed atoElement
greater than an earliertoElement
.- Specified by:
subSet
in interfaceNavigableSet<E>
- Specified by:
subSet
in interfaceSortedSet<E>
- Parameters:
fromElement
- low endpoint (inclusive) of the returned settoElement
- high endpoint (exclusive) of the returned set- Returns:
- a view of the portion of this set whose elements range from
fromElement
, inclusive, totoElement
, exclusive
-
subSet
@GwtIncompatible public ImmutableSortedSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Description copied from interface:java.util.NavigableSet
Returns a view of the portion of this set whose elements range fromfromElement
totoElement
. IffromElement
andtoElement
are equal, the returned set is empty unlessfromInclusive
andtoInclusive
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.- Specified by:
subSet
in interfaceNavigableSet<E>
- Parameters:
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 view- Returns:
- a view of the portion of this set whose elements range from
fromElement
, inclusive, totoElement
, exclusive - Since:
- 12.0
-
tailSet
public ImmutableSortedSet<E> tailSet(E fromElement)
Returns 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
IllegalArgumentException
on an attempt to insert an element outside its range.Equivalent to
tailSet(fromElement, true)
.This method returns a serializable
ImmutableSortedSet
.The
SortedSet.tailSet(E)
documentation states that a subset of a subset throws anIllegalArgumentException
if passed afromElement
smaller than an earlierfromElement
. However, this method doesn't throw an exception in that situation, but instead keeps the originalfromElement
.
-
tailSet
public ImmutableSortedSet<E> tailSet(E fromElement, boolean inclusive)
Description copied from interface:java.util.NavigableSet
Returns a view of the portion of this set whose elements are greater than (or equal to, ifinclusive
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.- Specified by:
tailSet
in interfaceNavigableSet<E>
- Parameters:
fromElement
- low endpoint of the returned setinclusive
-true
if 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
- Since:
- 12.0
-
lower
@GwtIncompatible public E lower(E e)
Description copied from interface:java.util.NavigableSet
Returns the greatest element in this set strictly less than the given element, ornull
if there is no such element.- Specified by:
lower
in interfaceNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the greatest element less than
e
, ornull
if there is no such element - Since:
- 12.0
-
floor
public E floor(E e)
Description copied from interface:java.util.NavigableSet
Returns the greatest element in this set less than or equal to the given element, ornull
if there is no such element.- Specified by:
floor
in interfaceNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the greatest element less than or equal to
e
, ornull
if there is no such element - Since:
- 12.0
-
ceiling
public E ceiling(E e)
Description copied from interface:java.util.NavigableSet
Returns the least element in this set greater than or equal to the given element, ornull
if there is no such element.- Specified by:
ceiling
in interfaceNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the least element greater than or equal to
e
, ornull
if there is no such element - Since:
- 12.0
-
higher
@GwtIncompatible public E higher(E e)
Description copied from interface:java.util.NavigableSet
Returns the least element in this set strictly greater than the given element, ornull
if there is no such element.- Specified by:
higher
in interfaceNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the least element greater than
e
, ornull
if there is no such element - Since:
- 12.0
-
first
public E first()
Description copied from interface:java.util.SortedSet
Returns the first (lowest) element currently in this set.
-
last
public E last()
Description copied from interface:java.util.SortedSet
Returns the last (highest) element currently in this set.
-
pollFirst
@CanIgnoreReturnValue @Deprecated @GwtIncompatible public final E pollFirst()
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the set unmodified.- Specified by:
pollFirst
in interfaceNavigableSet<E>
- Returns:
- the first element, or
null
if this set is empty - Throws:
UnsupportedOperationException
- always- Since:
- 12.0
-
pollLast
@CanIgnoreReturnValue @Deprecated @GwtIncompatible public final E pollLast()
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the set unmodified.- Specified by:
pollLast
in interfaceNavigableSet<E>
- Returns:
- the last element, or
null
if this set is empty - Throws:
UnsupportedOperationException
- always- Since:
- 12.0
-
descendingSet
@GwtIncompatible public ImmutableSortedSet<E> descendingSet()
Description copied from interface:java.util.NavigableSet
Returns 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 ownremove
operation), 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 ofs
essentially equivalent tos
.- Specified by:
descendingSet
in interfaceNavigableSet<E>
- Returns:
- a reverse order view of this set
- Since:
- 12.0
-
descendingIterator
@GwtIncompatible public abstract UnmodifiableIterator<E> descendingIterator()
Description copied from interface:java.util.NavigableSet
Returns an iterator over the elements in this set, in descending order. Equivalent in effect todescendingSet().iterator()
.- Specified by:
descendingIterator
in interfaceNavigableSet<E>
- Returns:
- an iterator over the elements in this set, in descending order
- Since:
- 12.0
-
builder
@Deprecated public static <E> ImmutableSortedSet.Builder<E> builder()
Deprecated.UsenaturalOrder()
, which offers better type-safety.Not supported. UsenaturalOrder()
, which offers better type-safety, instead. This method exists only to hideImmutableSet.builder()
from consumers ofImmutableSortedSet
.- Throws:
UnsupportedOperationException
- always
-
builderWithExpectedSize
@Deprecated public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize)
Deprecated.Not supported by ImmutableSortedSet.Not supported. This method exists only to hideImmutableSet.builderWithExpectedSize(int)
from consumers ofImmutableSortedSet
.- Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E element)
Deprecated.Pass a parameter of typeComparable
to useof(Comparable)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
element
- the single element- Returns:
- a
Set
containing the specified element - Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second element- Returns:
- a
Set
containing the specified elements - Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third element- Returns:
- a
Set
containing the specified elements - Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable, Comparable)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth element- Returns:
- a
Set
containing the specified elements - Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5)
Deprecated.Pass the parameters of typeComparable
to useof( Comparable, Comparable, Comparable, Comparable, Comparable)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth element- Returns:
- a
Set
containing the specified elements - Throws:
UnsupportedOperationException
- always
-
of
@Deprecated public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining)
Deprecated.Pass the parameters of typeComparable
to useof(Comparable, Comparable, Comparable, Comparable, Comparable, Comparable, Comparable...)
.Not supported. You are attempting to create a set that may contain a non-Comparable
element. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Type Parameters:
E
- theSet
's element type- Parameters:
e1
- the first elemente2
- the second elemente3
- the third elemente4
- the fourth elemente5
- the fifth elemente6
- the sixth elementremaining
- the seventh element- Returns:
- a
Set
containing the specified elements - Throws:
UnsupportedOperationException
- always
-
copyOf
@Deprecated public static <E> ImmutableSortedSet<E> copyOf(E[] elements)
Deprecated.Pass parameters of typeComparable
to usecopyOf(Comparable[])
.Not supported. You are attempting to create a set that may contain non-Comparable
elements. Proper calls will resolve to the version inImmutableSortedSet
, not this dummy version.- Throws:
UnsupportedOperationException
- always
-
-