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 classImmutableTreeSet.ImmutableTreeSetBatchprivate classImmutableTreeSet.SortedSetIterableParallelIterable
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>comparatorprivate T[]delegateprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description privateImmutableTreeSet(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 intcompare(T o1, T o2)intcompareTo(SortedSetIterable<T> otherSet)booleancontains(java.lang.Object object)Returns true if the iterable has an element which responds true to element.equals(object).<S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)Returns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother.intdetectIndex(Predicate<? super T> predicate)Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.ImmutableSortedSet<T>drop(int count)Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.booleanequals(java.lang.Object obj)Follows the same general contract asSet.equals(Object).Tfirst()voidforEach(int fromIndex, int toIndex, Procedure<? super T> procedure)Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the section of the iterable covered by the specified inclusive indexes.inthashCode()Follows the same general contract asSet.hashCode().intindexOf(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()Tlast()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)intsize()Returns the number of items in this iterable.ImmutableSortedSet<T>take(int count)Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.private java.lang.ObjectwriteReplace()-
Methods inherited from class org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet
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, toArray, toArray
-
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, 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, reduceBy, 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
asReversed, 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, reduceBy, 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:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfacejava.util.Collection<T>- Specified by:
sizein interfaceRichIterable<T>- Specified by:
sizein interfacejava.util.Set<T>
-
writeReplace
private java.lang.Object writeReplace()
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:SetIterableFollows the same general contract asSet.equals(Object).- Specified by:
equalsin interfacejava.util.Collection<T>- Specified by:
equalsin interfacejava.util.Set<T>- Specified by:
equalsin interfaceSetIterable<T>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Description copied from interface:SetIterableFollows the same general contract asSet.hashCode().- Specified by:
hashCodein interfacejava.util.Collection<T>- Specified by:
hashCodein interfacejava.util.Set<T>- Specified by:
hashCodein interfaceSetIterable<T>- Overrides:
hashCodein classjava.lang.Object
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfacejava.util.Collection<T>- Specified by:
containsin interfaceRichIterable<T>- Specified by:
containsin interfacejava.util.Set<T>- Overrides:
containsin classAbstractRichIterable<T>
-
iterator
public java.util.Iterator<T> iterator()
-
each
public void each(Procedure<? super T> procedure)
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(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:
eachin 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:OrderedIterableReturns a new OrderedIterable using results obtained by applying the specified function to each element and its corresponding index.- Specified by:
collectWithIndexin interfaceImmutableSortedSet<T>- Specified by:
collectWithIndexin interfaceOrderedIterable<T>- Specified by:
collectWithIndexin interfaceReversibleIterable<T>- Specified by:
collectWithIndexin interfaceSortedSetIterable<T>- Since:
- 9.1.
-
comparator
public java.util.Comparator<? super T> comparator()
Description copied from interface:SortedSetIterableReturns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.- Specified by:
comparatorin interfaceSortedIterable<T>- Specified by:
comparatorin interfacejava.util.SortedSet<T>- Specified by:
comparatorin interfaceSortedSetIterable<T>
-
compareTo
public int compareTo(SortedSetIterable<T> otherSet)
- Specified by:
compareToin interfacejava.lang.Comparable<T>
-
asParallel
public ParallelSortedSetIterable<T> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
Description copied from interface:SortedSetIterableReturns a parallel iterable of this SortedSetIterable.- Specified by:
asParallelin interfaceSetIterable<T>- Specified by:
asParallelin interfaceSortedSetIterable<T>- Overrides:
asParallelin classAbstractImmutableSortedSet<T>
-
detectIndex
public int detectIndex(Predicate<? super T> predicate)
Description copied from interface:OrderedIterableReturns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectIndexin interfaceOrderedIterable<T>- Overrides:
detectIndexin classAbstractImmutableSortedSet<T>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super T,? super S> predicate)
Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<T>- Overrides:
correspondsin classAbstractImmutableSortedSet<T>
-
forEach
public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure)Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<T>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure)Description copied from interface:OrderedIterableIterates 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, (person, index) -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<T>
-
indexOf
public int indexOf(java.lang.Object object)
Description copied from interface:OrderedIterableReturns 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:
indexOfin interfaceOrderedIterable<T>- See Also:
List.indexOf(Object)
-
take
public ImmutableSortedSet<T> take(int count)
Description copied from interface:ReversibleIterableReturns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.- Specified by:
takein interfaceImmutableSortedSet<T>- Specified by:
takein interfaceReversibleIterable<T>- Specified by:
takein interfaceSortedSetIterable<T>- Parameters:
count- the number of items to take.
-
drop
public ImmutableSortedSet<T> drop(int count)
Description copied from interface:ReversibleIterableReturns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.- Specified by:
dropin interfaceImmutableSortedSet<T>- Specified by:
dropin interfaceReversibleIterable<T>- Specified by:
dropin interfaceSortedSetIterable<T>- Parameters:
count- the number of items to drop.
-
-