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>
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>
-
-
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
HASH_FLOODING_FPP, MAX_RUN_MULTIPLIER, 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 Eceiling(E element)booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> targets)(package private) intcopyIntoArray(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()booleanequals(java.lang.Object object)Efirst()Efloor(E element)voidforEach(java.util.function.Consumer<? super E> action)(package private) RegularImmutableSortedSet<E>getSubSet(int newFromIndex, int newToIndex)(package private) intheadIndex(E toElement, boolean inclusive)(package private) ImmutableSortedSet<E>headSetImpl(E toElement, boolean inclusive)Ehigher(E element)(package private) intindexOf(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) intinternalArrayEnd()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) intinternalArrayStart()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) booleanisPartialView()Returnstrueif 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.Elast()Elower(E element)intsize()java.util.Spliterator<E>spliterator()(package private) ImmutableSortedSet<E>subSetImpl(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)(package private) inttailIndex(E fromElement, boolean inclusive)(package private) ImmutableSortedSet<E>tailSetImpl(E fromElement, boolean inclusive)private intunsafeBinarySearch(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
asList, chooseTableSize, hashCode, hashFloodingDetected, isHashCodeFast, rebuildHashTable
-
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
java.lang.Object[] internalArray()
Description copied from class:ImmutableCollectionIf this collection is backed by an array of its elements in insertion order, returns it.- Overrides:
internalArrayin classImmutableCollection<E>
-
internalArrayStart
int internalArrayStart()
Description copied from class:ImmutableCollectionIf this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements start.- Overrides:
internalArrayStartin classImmutableCollection<E>
-
internalArrayEnd
int internalArrayEnd()
Description copied from class:ImmutableCollectionIf this collection is backed by an array of its elements in insertion order, returns the offset where this collection's elements end.- Overrides:
internalArrayEndin classImmutableCollection<E>
-
iterator
public UnmodifiableIterator<E> iterator()
Description copied from class:ImmutableCollectionReturns an unmodifiable iterator across the elements in this collection.- Specified by:
iteratorin interfacejava.util.Collection<E>- Specified by:
iteratorin interfacejava.lang.Iterable<E>- Specified by:
iteratorin interfacejava.util.NavigableSet<E>- Specified by:
iteratorin interfacejava.util.Set<E>- Specified by:
iteratorin interfaceSortedIterable<E>- Specified by:
iteratorin classImmutableSortedSet<E>
-
descendingIterator
public UnmodifiableIterator<E> descendingIterator()
- Specified by:
descendingIteratorin interfacejava.util.NavigableSet<E>- Specified by:
descendingIteratorin classImmutableSortedSet<E>
-
spliterator
public java.util.Spliterator<E> spliterator()
- Specified by:
spliteratorin interfacejava.util.Collection<E>- Specified by:
spliteratorin interfacejava.lang.Iterable<E>- Specified by:
spliteratorin interfacejava.util.Set<E>- Specified by:
spliteratorin interfacejava.util.SortedSet<E>- Overrides:
spliteratorin classImmutableSortedSet<E>
-
forEach
public void forEach(java.util.function.Consumer<? super E> action)
-
size
public int size()
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<E>- Specified by:
containsin interfacejava.util.Set<E>- Specified by:
containsin 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:ImmutableCollectionReturnstrueif 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 whethercopyOfimplementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialViewin classImmutableCollection<E>
-
copyIntoArray
int copyIntoArray(java.lang.Object[] dst, int offset)Description copied from class:ImmutableCollectionCopies the contents of this immutable collection into the specified array at the specified offset. Returnsoffset + size().- Overrides:
copyIntoArrayin classImmutableCollection<E>
-
equals
public boolean equals(java.lang.Object object)
- Specified by:
equalsin interfacejava.util.Collection<E>- Specified by:
equalsin interfacejava.util.Set<E>- Overrides:
equalsin classImmutableSet<E>
-
first
public E first()
- Specified by:
firstin interfacejava.util.SortedSet<E>- Overrides:
firstin classImmutableSortedSet<E>
-
last
public E last()
- Specified by:
lastin interfacejava.util.SortedSet<E>- Overrides:
lastin classImmutableSortedSet<E>
-
lower
public E lower(E element)
- Specified by:
lowerin interfacejava.util.NavigableSet<E>- Overrides:
lowerin classImmutableSortedSet<E>
-
floor
public E floor(E element)
- Specified by:
floorin interfacejava.util.NavigableSet<E>- Overrides:
floorin classImmutableSortedSet<E>
-
ceiling
public E ceiling(E element)
- Specified by:
ceilingin interfacejava.util.NavigableSet<E>- Overrides:
ceilingin classImmutableSortedSet<E>
-
higher
public E higher(E element)
- Specified by:
higherin interfacejava.util.NavigableSet<E>- Overrides:
higherin classImmutableSortedSet<E>
-
headSetImpl
ImmutableSortedSet<E> headSetImpl(E toElement, boolean inclusive)
- Specified by:
headSetImplin classImmutableSortedSet<E>
-
headIndex
int headIndex(E toElement, boolean inclusive)
-
subSetImpl
ImmutableSortedSet<E> subSetImpl(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
- Specified by:
subSetImplin classImmutableSortedSet<E>
-
tailSetImpl
ImmutableSortedSet<E> tailSetImpl(E fromElement, boolean inclusive)
- Specified by:
tailSetImplin 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(java.lang.Object target)
Description copied from class:ImmutableSortedSetReturns the position of an element within the set, or -1 if not present.- Specified by:
indexOfin classImmutableSortedSet<E>
-
createAsList
ImmutableList<E> createAsList()
- Overrides:
createAsListin classImmutableSet<E>
-
createDescendingSet
ImmutableSortedSet<E> createDescendingSet()
- Specified by:
createDescendingSetin classImmutableSortedSet<E>
-
-