Package com.google.common.collect
Class RegularImmutableSortedSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableSet<E>
-
- com.google.common.collect.ImmutableSortedSetFauxverideShim<E>
-
- com.google.common.collect.ImmutableSortedSet<E>
-
- com.google.common.collect.RegularImmutableSortedSet<E>
-
- All Implemented Interfaces:
SortedIterable<E>
,java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.NavigableSet<E>
,java.util.Set<E>
,java.util.SortedSet<E>
@GwtCompatible(serializable=true, emulated=true) final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E>
An immutable sorted set with one or more elements. TODO(jlevy): Consider separate class for a single-element sorted set.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableSortedSet
ImmutableSortedSet.Builder<E>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableSet
ImmutableSet.Indexed<E>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableCollection
ImmutableCollection.ArrayBasedBuilder<E>
-
-
Field Summary
Fields Modifier and Type Field Description private ImmutableList<E>
elements
(package private) static RegularImmutableSortedSet<java.lang.Comparable>
NATURAL_EMPTY_SET
-
Fields inherited from class com.google.common.collect.ImmutableSortedSet
comparator, descendingSet
-
Fields inherited from class com.google.common.collect.ImmutableSet
MAX_TABLE_SIZE
-
-
Constructor Summary
Constructors Constructor Description RegularImmutableSortedSet(ImmutableList<E> elements, java.util.Comparator<? super E> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
ceiling(E element)
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> targets)
(package private) int
copyIntoArray(java.lang.Object[] dst, int offset)
Copies the contents of this immutable collection into the specified array at the specified offset.(package private) ImmutableList<E>
createAsList()
(package private) ImmutableSortedSet<E>
createDescendingSet()
UnmodifiableIterator<E>
descendingIterator()
boolean
equals(java.lang.Object object)
E
first()
E
floor(E element)
(package private) RegularImmutableSortedSet<E>
getSubSet(int newFromIndex, int newToIndex)
(package private) int
headIndex(E toElement, boolean inclusive)
(package private) ImmutableSortedSet<E>
headSetImpl(E toElement, boolean inclusive)
E
higher(E element)
(package private) int
indexOf(java.lang.Object target)
Returns the position of an element within the set, or -1 if not present.(package private) boolean
isPartialView()
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.UnmodifiableIterator<E>
iterator()
Returns an unmodifiable iterator across the elements in this collection.E
last()
E
lower(E element)
int
size()
(package private) ImmutableSortedSet<E>
subSetImpl(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
(package private) int
tailIndex(E fromElement, boolean inclusive)
(package private) ImmutableSortedSet<E>
tailSetImpl(E fromElement, boolean inclusive)
private int
unsafeBinarySearch(java.lang.Object key)
(package private) java.util.Comparator<java.lang.Object>
unsafeComparator()
-
Methods inherited from class com.google.common.collect.ImmutableSortedSet
comparator, construct, copyOf, copyOf, copyOf, copyOf, copyOf, copyOf, copyOf, copyOfSorted, descendingSet, emptySet, headSet, headSet, naturalOrder, of, of, of, of, of, of, of, orderedBy, pollFirst, pollLast, reverseOrder, subSet, subSet, tailSet, tailSet, unsafeCompare, unsafeCompare, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableSortedSetFauxverideShim
builder, copyOf, of, of, of, of, of, of
-
Methods inherited from class com.google.common.collect.ImmutableSet
asList, chooseTableSize, hashCode, isHashCodeFast
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
NATURAL_EMPTY_SET
static final RegularImmutableSortedSet<java.lang.Comparable> NATURAL_EMPTY_SET
-
elements
private final transient ImmutableList<E> elements
-
-
Constructor Detail
-
RegularImmutableSortedSet
RegularImmutableSortedSet(ImmutableList<E> elements, java.util.Comparator<? super E> comparator)
-
-
Method Detail
-
iterator
public UnmodifiableIterator<E> iterator()
Description copied from class:ImmutableCollection
Returns an unmodifiable iterator across the elements in this collection.- Specified by:
iterator
in interfacejava.util.Collection<E>
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
- Specified by:
iterator
in interfacejava.util.NavigableSet<E>
- Specified by:
iterator
in interfacejava.util.Set<E>
- Specified by:
iterator
in interfaceSortedIterable<E>
- Specified by:
iterator
in classImmutableSortedSet<E>
-
descendingIterator
@GwtIncompatible public UnmodifiableIterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.NavigableSet<E>
- Specified by:
descendingIterator
in classImmutableSortedSet<E>
-
size
public int size()
-
contains
public boolean contains(@Nullable java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<E>
- Specified by:
contains
in interfacejava.util.Set<E>
- Specified by:
contains
in classImmutableCollection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> targets)
-
unsafeBinarySearch
private int unsafeBinarySearch(java.lang.Object key) throws java.lang.ClassCastException
- Throws:
java.lang.ClassCastException
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollection
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whethercopyOf
implementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialView
in classImmutableCollection<E>
-
copyIntoArray
int copyIntoArray(java.lang.Object[] dst, int offset)
Description copied from class:ImmutableCollection
Copies the contents of this immutable collection into the specified array at the specified offset. Returnsoffset + size()
.- Overrides:
copyIntoArray
in classImmutableCollection<E>
-
equals
public boolean equals(@Nullable java.lang.Object object)
- Specified by:
equals
in interfacejava.util.Collection<E>
- Specified by:
equals
in interfacejava.util.Set<E>
- Overrides:
equals
in classImmutableSet<E>
-
first
public E first()
- Specified by:
first
in interfacejava.util.SortedSet<E>
- Overrides:
first
in classImmutableSortedSet<E>
-
last
public E last()
- Specified by:
last
in interfacejava.util.SortedSet<E>
- Overrides:
last
in classImmutableSortedSet<E>
-
lower
public E lower(E element)
- Specified by:
lower
in interfacejava.util.NavigableSet<E>
- Overrides:
lower
in classImmutableSortedSet<E>
-
floor
public E floor(E element)
- Specified by:
floor
in interfacejava.util.NavigableSet<E>
- Overrides:
floor
in classImmutableSortedSet<E>
-
ceiling
public E ceiling(E element)
- Specified by:
ceiling
in interfacejava.util.NavigableSet<E>
- Overrides:
ceiling
in classImmutableSortedSet<E>
-
higher
public E higher(E element)
- Specified by:
higher
in interfacejava.util.NavigableSet<E>
- Overrides:
higher
in classImmutableSortedSet<E>
-
headSetImpl
ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive)
- Specified by:
headSetImpl
in classImmutableSortedSet<E>
-
headIndex
int headIndex(E toElement, boolean inclusive)
-
subSetImpl
ImmutableSortedSet<E> subSetImpl(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
- Specified by:
subSetImpl
in classImmutableSortedSet<E>
-
tailSetImpl
ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive)
- Specified by:
tailSetImpl
in classImmutableSortedSet<E>
-
tailIndex
int tailIndex(E fromElement, boolean inclusive)
-
unsafeComparator
java.util.Comparator<java.lang.Object> unsafeComparator()
-
getSubSet
RegularImmutableSortedSet<E> getSubSet(int newFromIndex, int newToIndex)
-
indexOf
int indexOf(@Nullable java.lang.Object target)
Description copied from class:ImmutableSortedSet
Returns the position of an element within the set, or -1 if not present.- Specified by:
indexOf
in classImmutableSortedSet<E>
-
createAsList
ImmutableList<E> createAsList()
- Overrides:
createAsList
in classImmutableSet<E>
-
createDescendingSet
ImmutableSortedSet<E> createDescendingSet()
- Overrides:
createDescendingSet
in classImmutableSortedSet<E>
-
-