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.ImmutableSortedSet<E>
com.google.common.collect.RegularImmutableSortedSet<E>
- All Implemented Interfaces:
SortedIterable<E>
,Serializable
,Iterable<E>
,Collection<E>
,NavigableSet<E>
,SequencedCollection<E>
,SequencedSet<E>
,Set<E>
,SortedSet<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
FieldsModifier and TypeFieldDescriptionprivate final ImmutableList
<E> (package private) static final RegularImmutableSortedSet
<Comparable> 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
ConstructorsConstructorDescriptionRegularImmutableSortedSet
(ImmutableList<E> elements, Comparator<? super E> comparator) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
containsAll
(Collection<?> targets) (package private) int
copyIntoArray
(Object[] dst, int offset) Copies the contents of this immutable collection into the specified array at the specified offset.(package private) ImmutableList
<E> (package private) ImmutableSortedSet
<E> boolean
first()
void
(package private) RegularImmutableSortedSet
<E> getSubSet
(int newFromIndex, int newToIndex) (package private) int
(package private) ImmutableSortedSet
<E> headSetImpl
(E toElement, boolean inclusive) (package private) int
Returns the position of an element within the set, or -1 if not present.(package private) Object[]
If this collection is backed by an array of its elements in insertion order, returns it.(package private) int
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
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
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.iterator()
Returns an unmodifiable iterator across the elements in this collection.last()
int
size()
(package private) ImmutableSortedSet
<E> subSetImpl
(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) (package private) int
(package private) ImmutableSortedSet
<E> tailSetImpl
(E fromElement, boolean inclusive) private int
unsafeBinarySearch
(Object key) (package private) Comparator
<Object> (package private) Object
Methods inherited from class com.google.common.collect.ImmutableSortedSet
builder, builderWithExpectedSize, comparator, construct, copyOf, 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, toImmutableSet, toImmutableSortedSet, unsafeCompare, unsafeCompare
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
Methods inherited from class java.util.AbstractCollection
isEmpty, 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.NavigableSet
removeFirst, removeLast, reversed
-
Field Details
-
NATURAL_EMPTY_SET
-
elements
-
-
Constructor Details
-
RegularImmutableSortedSet
RegularImmutableSortedSet(ImmutableList<E> elements, Comparator<? super E> comparator)
-
-
Method Details
-
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
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 interfaceSortedIterable<E>
- Specified by:
iterator
in classImmutableSortedSet<E>
-
descendingIterator
- Specified by:
descendingIterator
in interfaceNavigableSet<E>
- Specified by:
descendingIterator
in classImmutableSortedSet<E>
-
spliterator
- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceSet<E>
- Specified by:
spliterator
in interfaceSortedSet<E>
- Overrides:
spliterator
in classImmutableSortedSet<E>
-
forEach
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Specified by:
contains
in classImmutableCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
unsafeBinarySearch
- Throws:
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
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
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceSet<E>
- Overrides:
equals
in classImmutableSet<E>
-
first
-
last
-
lower
- Specified by:
lower
in interfaceNavigableSet<E>
- Overrides:
lower
in classImmutableSortedSet<E>
-
floor
- Specified by:
floor
in interfaceNavigableSet<E>
- Overrides:
floor
in classImmutableSortedSet<E>
-
ceiling
- Specified by:
ceiling
in interfaceNavigableSet<E>
- Overrides:
ceiling
in classImmutableSortedSet<E>
-
higher
- Specified by:
higher
in interfaceNavigableSet<E>
- Overrides:
higher
in classImmutableSortedSet<E>
-
headSetImpl
- Specified by:
headSetImpl
in classImmutableSortedSet<E>
-
headIndex
-
subSetImpl
ImmutableSortedSet<E> subSetImpl(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) - Specified by:
subSetImpl
in classImmutableSortedSet<E>
-
tailSetImpl
- Specified by:
tailSetImpl
in classImmutableSortedSet<E>
-
tailIndex
-
unsafeComparator
Comparator<Object> unsafeComparator() -
getSubSet
-
indexOf
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>
-
writeReplace
Object writeReplace()- Overrides:
writeReplace
in classImmutableSortedSet<E>
-