Class AbstractImmutableCollection<T>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.immutable.AbstractImmutableCollection<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,ImmutableCollection<T>,InternalIterable<T>,RichIterable<T>
- Direct Known Subclasses:
AbstractImmutableList,AbstractImmutableSet,AbstractImmutableSortedSet
public abstract class AbstractImmutableCollection<T> extends AbstractRichIterable<T> implements ImmutableCollection<T>, java.util.Collection<T>
-
-
Constructor Summary
Constructors Constructor Description AbstractImmutableCollection()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(T t)booleanaddAll(java.util.Collection<? extends T> collection)java.util.Collection<T>castToCollection()This can be overridden in most implementations to just return this.RichIterable<RichIterable<T>>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> ImmutableBag<V>countBy(Function<? super T,? extends V> function)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V> ImmutableBag<V>countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.<V,P>
ImmutableBag<V>countByWith(Function2<? super T,? super P,? extends V> function, P parameter)This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.<V> ImmutableMap<V,T>groupByUniqueKey(Function<? super T,? extends V> function)For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key.protected abstract MutableCollection<T>newMutable(int size)java.util.stream.Stream<T>parallelStream()java.util.Optional<T>reduce(java.util.function.BinaryOperator<T> accumulator)This method produces the equivalent result asStream.reduce(BinaryOperator).booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> collection)protected voidremoveAllFrom(java.lang.Iterable<? extends T> elements, MutableCollection<T> result)booleanretainAll(java.util.Collection<?> collection)java.util.Spliterator<T>spliterator()java.util.stream.Stream<T>stream()<V> ImmutableObjectDoubleMap<V>sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectDoubleMap<V>sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectLongMap<V>sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ImmutableObjectLongMap<V>sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)Groups and sums the values using the two specified functions.java.lang.Object[]toArray()Converts this iterable to an array.<E> E[]toArray(E[] array)Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, asLazy, collect, collectIf, collectWith, contains, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, removeIf, size, toArray
-
Methods inherited from interface org.eclipse.collections.api.collection.ImmutableCollection
aggregateBy, aggregateInPlaceBy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flatCollectWith, groupBy, groupByEach, newWith, newWithAll, newWithout, newWithoutAll, partition, partitionWith, reduceBy, reject, rejectWith, select, selectInstancesOf, selectWith, tap, zip, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndex
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
-
-
-
Method Detail
-
newMutable
protected abstract MutableCollection<T> newMutable(int size)
-
toArray
public java.lang.Object[] toArray()
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfacejava.util.Collection<T>- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
Collection.toArray()
-
toArray
public <E> E[] toArray(E[] array)
Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfacejava.util.Collection<T>- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
Collection.toArray(Object[])
-
reduce
public java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
Description copied from interface:RichIterableThis method produces the equivalent result asStream.reduce(BinaryOperator).- Specified by:
reducein interfaceRichIterable<T>
-
sumByInt
public <V> ImmutableObjectLongMap<V> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByIntin interfaceImmutableCollection<T>- Specified by:
sumByIntin interfaceRichIterable<T>
-
sumByFloat
public <V> ImmutableObjectDoubleMap<V> sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByFloatin interfaceImmutableCollection<T>- Specified by:
sumByFloatin interfaceRichIterable<T>
-
sumByLong
public <V> ImmutableObjectLongMap<V> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByLongin interfaceImmutableCollection<T>- Specified by:
sumByLongin interfaceRichIterable<T>
-
sumByDouble
public <V> ImmutableObjectDoubleMap<V> sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByDoublein interfaceImmutableCollection<T>- Specified by:
sumByDoublein interfaceRichIterable<T>
-
groupByUniqueKey
public <V> ImmutableMap<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
Description copied from interface:RichIterableFor each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key. The generated keys must each be unique, or else an exception is thrown.- Specified by:
groupByUniqueKeyin interfaceImmutableCollection<T>- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
RichIterable.groupBy(Function)
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<T>
-
addAll
public boolean addAll(java.util.Collection<? extends T> collection)
- Specified by:
addAllin interfacejava.util.Collection<T>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAllin interfacejava.util.Collection<T>
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAllin interfacejava.util.Collection<T>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<T>
-
removeAllFrom
protected void removeAllFrom(java.lang.Iterable<? extends T> elements, MutableCollection<T> result)
-
chunk
public RichIterable<RichIterable<T>> chunk(int size)
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
countBy
public <V> ImmutableBag<V> countBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByin interfaceImmutableCollection<T>- Specified by:
countByin interfaceRichIterable<T>- Since:
- 9.0
-
countByWith
public <V,P> ImmutableBag<V> countByWith(Function2<? super T,? super P,? extends V> function, P parameter)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.- Specified by:
countByWithin interfaceImmutableCollection<T>- Specified by:
countByWithin interfaceRichIterable<T>- Since:
- 9.0
-
countByEach
public <V> ImmutableBag<V> countByEach(Function<? super T,? extends java.lang.Iterable<V>> function)
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceImmutableCollection<T>- Specified by:
countByEachin interfaceRichIterable<T>- Overrides:
countByEachin classAbstractRichIterable<T>- Since:
- 10.0.0
-
stream
public java.util.stream.Stream<T> stream()
- Specified by:
streamin interfacejava.util.Collection<T>- Specified by:
streamin interfaceImmutableCollection<T>- Since:
- 9.0
-
parallelStream
public java.util.stream.Stream<T> parallelStream()
- Specified by:
parallelStreamin interfacejava.util.Collection<T>- Specified by:
parallelStreamin interfaceImmutableCollection<T>- Since:
- 9.0
-
spliterator
public java.util.Spliterator<T> spliterator()
- Specified by:
spliteratorin interfacejava.util.Collection<T>- Specified by:
spliteratorin interfaceImmutableCollection<T>- Specified by:
spliteratorin interfacejava.lang.Iterable<T>- Since:
- 9.0
-
castToCollection
public java.util.Collection<T> castToCollection()
Description copied from interface:ImmutableCollectionThis can be overridden in most implementations to just return this.- Specified by:
castToCollectionin interfaceImmutableCollection<T>- Since:
- 9.0
-
-