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.ImmutableSet.CachingAsList<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>
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.CachingAsList<E>, ImmutableSet.Indexed<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, SPLITERATOR_CHARACTERISTICS
-
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)
void
forEach(java.util.function.Consumer<? super E> action)
(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) java.lang.Object[]
internalArray()
If this collection is backed by an array of its elements in insertion order, returns it.(package private) int
internalArrayEnd()
If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements end.(package private) int
internalArrayStart()
If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements start.(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()
java.util.Spliterator<E>
spliterator()
(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, toImmutableSortedSet, unsafeCompare, unsafeCompare, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableSortedSetFauxverideShim
builder, builderWithExpectedSize, copyOf, of, of, of, of, of, of, toImmutableSet
-
Methods inherited from class com.google.common.collect.ImmutableSet.CachingAsList
asList
-
Methods inherited from class com.google.common.collect.ImmutableSet
chooseTableSize, hashCode, isHashCodeFast
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, remove, removeAll, removeIf, retainAll, toArray, toArray
-
-
-
-
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
-
internalArray
@CheckForNull java.lang.Object[] internalArray()
Description copied from class:ImmutableCollection
If this collection is backed by an array of its elements in insertion order, returns it.- Overrides:
internalArray
in classImmutableCollection<E>
-
internalArrayStart
int internalArrayStart()
Description copied from class:ImmutableCollection
If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements start.- Overrides:
internalArrayStart
in classImmutableCollection<E>
-
internalArrayEnd
int internalArrayEnd()
Description copied from class:ImmutableCollection
If this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements end.- Overrides:
internalArrayEnd
in classImmutableCollection<E>
-
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
public UnmodifiableIterator<E> descendingIterator()
- Specified by:
descendingIterator
in interfacejava.util.NavigableSet<E>
- Specified by:
descendingIterator
in classImmutableSortedSet<E>
-
spliterator
public java.util.Spliterator<E> spliterator()
- Specified by:
spliterator
in interfacejava.util.Collection<E>
- Specified by:
spliterator
in interfacejava.lang.Iterable<E>
- Specified by:
spliterator
in interfacejava.util.Set<E>
- Specified by:
spliterator
in interfacejava.util.SortedSet<E>
- Overrides:
spliterator
in classImmutableSortedSet<E>
-
forEach
public void forEach(java.util.function.Consumer<? super E> action)
-
size
public int size()
-
contains
public boolean contains(@CheckForNull 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(@CheckForNull 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
@CheckForNull public E lower(E element)
- Specified by:
lower
in interfacejava.util.NavigableSet<E>
- Overrides:
lower
in classImmutableSortedSet<E>
-
floor
@CheckForNull public E floor(E element)
- Specified by:
floor
in interfacejava.util.NavigableSet<E>
- Overrides:
floor
in classImmutableSortedSet<E>
-
ceiling
@CheckForNull public E ceiling(E element)
- Specified by:
ceiling
in interfacejava.util.NavigableSet<E>
- Overrides:
ceiling
in classImmutableSortedSet<E>
-
higher
@CheckForNull 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(@CheckForNull 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.CachingAsList<E>
-
createDescendingSet
ImmutableSortedSet<E> createDescendingSet()
- Specified by:
createDescendingSet
in classImmutableSortedSet<E>
-
-