Class ImmutableTreeSet<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection<T>
-
- org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet<T>
-
- org.eclipse.collections.impl.set.sorted.immutable.ImmutableTreeSet<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<SortedSetIterable<T>>
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Set<T>
,java.util.SortedSet<T>
,ImmutableCollection<T>
,InternalIterable<T>
,OrderedIterable<T>
,ReversibleIterable<T>
,SortedIterable<T>
,RichIterable<T>
,ImmutableSetIterable<T>
,SetIterable<T>
,ImmutableSortedSet<T>
,SortedSetIterable<T>
final class ImmutableTreeSet<T> extends AbstractImmutableSortedSet<T> implements java.io.Serializable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ImmutableTreeSet.ImmutableTreeSetBatch
private class
ImmutableTreeSet.SortedSetIterableParallelIterable
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>
comparator
private T[]
delegate
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
ImmutableTreeSet(T[] input, java.util.Comparator<? super T> inputComparator, boolean isSortedAndUnique)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParallelSortedSetIterable<T>
asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
Returns a parallel iterable of this SortedSetIterable.<V> ImmutableList<V>
collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.java.util.Comparator<? super T>
comparator()
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.private int
compare(T o1, T o2)
int
compareTo(SortedSetIterable<T> otherSet)
boolean
contains(java.lang.Object object)
Returns true if the iterable has an element which responds true to element.equals(object).<S> boolean
corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Returns true if both OrderedIterables have the same length andpredicate
returns true for all corresponding elements e1 of thisOrderedIterable
and e2 ofother
.int
detectIndex(Predicate<? super T> predicate)
Returns the index of the first element of theOrderedIterable
for which thepredicate
evaluates to true.ImmutableSortedSet<T>
drop(int count)
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.void
each(Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.boolean
equals(java.lang.Object obj)
Follows the same general contract asSet.equals(Object)
.T
first()
void
forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)
Iterates over the section of the iterable covered by the specified inclusive indexes.void
forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the section of the iterable covered by the specified inclusive indexes.int
hashCode()
Follows the same general contract asSet.hashCode()
.int
indexOf(java.lang.Object object)
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.java.util.Iterator<T>
iterator()
T
last()
static <T> ImmutableSortedSet<T>
newSet(java.util.SortedSet<? super T> set)
static <T> ImmutableSortedSet<T>
newSetFromIterable(java.lang.Iterable<? extends T> iterable)
static <T> ImmutableSortedSet<T>
newSetFromIterable(java.util.Comparator<? super T> comparator, java.lang.Iterable<? extends T> iterable)
static <T> ImmutableSortedSet<T>
newSetWith(java.util.Comparator<? super T> comparator, T... elements)
static <T> ImmutableSortedSet<T>
newSetWith(T... elements)
int
size()
Returns the number of items in this iterable.ImmutableSortedSet<T>
take(int count)
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.private java.lang.Object
writeReplace()
-
Methods inherited from class org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet
asReversed, cartesianProduct, castToSortedSet, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, detectLastIndex, difference, differenceInto, distinct, dropWhile, flatCollect, getFirst, getLast, groupBy, groupByEach, headSet, intersect, intersectInto, isProperSubsetOf, isSubsetOf, newMutable, newWith, newWithAll, newWithout, newWithoutAll, partition, partitionWhile, partitionWith, powerSet, reject, rejectWith, select, selectInstancesOf, selectWith, subSet, symmetricDifference, symmetricDifferenceInto, tailSet, takeWhile, tap, toImmutable, toReversed, toStack, union, unionInto, zip, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection
add, addAll, castToCollection, chunk, clear, countBy, countByEach, countByWith, groupByUniqueKey, parallelStream, reduce, remove, removeAll, removeAllFrom, retainAll, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, castToCollection, countBy, countByEach, countByWith, flatCollectWith, groupByUniqueKey, parallelStream, spliterator, stream, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from interface org.eclipse.collections.api.set.sorted.ImmutableSortedSet
flatCollectWith, toImmutableSortedSet
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, forEachWithIndex, getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Methods inherited from interface java.util.Set
add, addAll, clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from interface org.eclipse.collections.api.ordered.SortedIterable
max, min
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
delegate
private final T[] delegate
-
comparator
private final java.util.Comparator<? super T> comparator
-
-
Method Detail
-
newSetWith
public static <T> ImmutableSortedSet<T> newSetWith(T... elements)
-
newSetWith
public static <T> ImmutableSortedSet<T> newSetWith(java.util.Comparator<? super T> comparator, T... elements)
-
newSet
public static <T> ImmutableSortedSet<T> newSet(java.util.SortedSet<? super T> set)
-
newSetFromIterable
public static <T> ImmutableSortedSet<T> newSetFromIterable(java.lang.Iterable<? extends T> iterable)
-
newSetFromIterable
public static <T> ImmutableSortedSet<T> newSetFromIterable(java.util.Comparator<? super T> comparator, java.lang.Iterable<? extends T> iterable)
-
size
public int size()
Description copied from interface:RichIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacejava.util.Collection<T>
- Specified by:
size
in interfaceRichIterable<T>
- Specified by:
size
in interfacejava.util.Set<T>
-
writeReplace
private java.lang.Object writeReplace()
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:SetIterable
Follows the same general contract asSet.equals(Object)
.- Specified by:
equals
in interfacejava.util.Collection<T>
- Specified by:
equals
in interfacejava.util.Set<T>
- Specified by:
equals
in interfaceSetIterable<T>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Description copied from interface:SetIterable
Follows the same general contract asSet.hashCode()
.- Specified by:
hashCode
in interfacejava.util.Collection<T>
- Specified by:
hashCode
in interfacejava.util.Set<T>
- Specified by:
hashCode
in interfaceSetIterable<T>
- Overrides:
hashCode
in classjava.lang.Object
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfacejava.util.Collection<T>
- Specified by:
contains
in interfaceRichIterable<T>
- Specified by:
contains
in interfacejava.util.Set<T>
- Overrides:
contains
in classAbstractRichIterable<T>
-
iterator
public java.util.Iterator<T> iterator()
-
each
public void each(Procedure<? super T> procedure)
Description copied from interface:RichIterable
The procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This method is a variant ofInternalIterable.forEach(Procedure)
that has a signature conflict withIterable.forEach(java.util.function.Consumer)
.- Specified by:
each
in interfaceRichIterable<T>
- See Also:
InternalIterable.forEach(Procedure)
,Iterable.forEach(java.util.function.Consumer)
-
collectWithIndex
public <V> ImmutableList<V> collectWithIndex(ObjectIntToObjectFunction<? super T,? extends V> function)
Description copied from interface:OrderedIterable
Returns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndex
in interfaceImmutableSortedSet<T>
- Specified by:
collectWithIndex
in interfaceOrderedIterable<T>
- Specified by:
collectWithIndex
in interfaceReversibleIterable<T>
- Specified by:
collectWithIndex
in interfaceSortedSetIterable<T>
- Since:
- 9.1.
-
comparator
public java.util.Comparator<? super T> comparator()
Description copied from interface:SortedSetIterable
Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.- Specified by:
comparator
in interfaceSortedIterable<T>
- Specified by:
comparator
in interfacejava.util.SortedSet<T>
- Specified by:
comparator
in interfaceSortedSetIterable<T>
-
compareTo
public int compareTo(SortedSetIterable<T> otherSet)
- Specified by:
compareTo
in interfacejava.lang.Comparable<T>
-
asParallel
public ParallelSortedSetIterable<T> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
Description copied from interface:SortedSetIterable
Returns a parallel iterable of this SortedSetIterable.- Specified by:
asParallel
in interfaceSetIterable<T>
- Specified by:
asParallel
in interfaceSortedSetIterable<T>
- Overrides:
asParallel
in classAbstractImmutableSortedSet<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
Description copied from interface:OrderedIterable
Returns the index of the first element of theOrderedIterable
for which thepredicate
evaluates to true. Returns -1 if no element evaluates true for thepredicate
.- Specified by:
detectIndex
in interfaceOrderedIterable<T>
- Overrides:
detectIndex
in classAbstractImmutableSortedSet<T>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Description copied from interface:OrderedIterable
Returns true if both OrderedIterables have the same length andpredicate
returns true for all corresponding elements e1 of thisOrderedIterable
and e2 ofother
. Thepredicate
is evaluated for each element at the same position of eachOrderedIterable
in a forward iteration order. This is a short circuit pattern.- Specified by:
corresponds
in interfaceOrderedIterable<T>
- Overrides:
corresponds
in classAbstractImmutableSortedSet<T>
-
forEach
public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)
Description copied from interface:OrderedIterable
Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEach
in interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)
Description copied from interface:OrderedIterable
Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info(person.getName()); } });
This code would output ted and mary's names.
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<T>
-
indexOf
public int indexOf(java.lang.Object object)
Description copied from interface:OrderedIterable
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.- Specified by:
indexOf
in interfaceOrderedIterable<T>
- See Also:
List.indexOf(Object)
-
take
public ImmutableSortedSet<T> take(int count)
Description copied from interface:ReversibleIterable
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.- Specified by:
take
in interfaceImmutableSortedSet<T>
- Specified by:
take
in interfaceReversibleIterable<T>
- Specified by:
take
in interfaceSortedSetIterable<T>
- Parameters:
count
- the number of items to take.
-
drop
public ImmutableSortedSet<T> drop(int count)
Description copied from interface:ReversibleIterable
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.- Specified by:
drop
in interfaceImmutableSortedSet<T>
- Specified by:
drop
in interfaceReversibleIterable<T>
- Specified by:
drop
in interfaceSortedSetIterable<T>
- Parameters:
count
- the number of items to drop.
-
-