Top Constructors Methods
org.eclipse.collections.impl.collection.immutable

public abstract Class AbstractImmutableCollection<T>

extends AbstractRichIterable<T>
implements ImmutableCollection<T>, Collection<T>
Class Inheritance
All Implemented Interfaces
java.util.Collection, java.lang.Iterable, org.eclipse.collections.api.collection.ImmutableCollection, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable
Known Direct Subclasses
org.eclipse.collections.impl.list.immutable.AbstractImmutableList, org.eclipse.collections.impl.set.immutable.AbstractImmutableSet, org.eclipse.collections.impl.set.sorted.immutable.AbstractImmutableSortedSet
Imports
java.util.Collection, .Iterator, .List, .Optional, .Set, .Spliterator, .Spliterators, java.util.function.BinaryOperator, java.util.stream.Stream, .StreamSupport, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.ImmutableBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, org.eclipse.collections.api.collection.ImmutableCollection, .MutableCollection, org.eclipse.collections.api.factory.Bags, .Lists, .Sets, org.eclipse.collections.api.factory.primitive.ObjectDoubleMaps, .ObjectLongMaps, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.map.ImmutableMap, .MutableMap, org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap, .ImmutableObjectLongMap, .MutableObjectDoubleMap, .MutableObjectLongMap, org.eclipse.collections.impl.AbstractRichIterable, org.eclipse.collections.impl.block.factory.PrimitiveFunctions, org.eclipse.collections.impl.utility.Iterate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(T t)

Implements java.util.Collection.add.

Ensures that this collection contains the specified element (optional operation).

public boolean
addAll(Collection<? extends T> collection)

Implements java.util.Collection.addAll.

Adds all of the elements in the specified collection to this collection (optional operation).

public Collection<T>
castToCollection()

Implements org.eclipse.collections.api.collection.ImmutableCollection.castToCollection.

This can be overridden in most implementations to just return this.

public RichIterable<RichIterable<T>>
chunk(int size)

Implements org.eclipse.collections.api.RichIterable.chunk.

Partitions elements in fixed size chunks.

public void
clear()

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).

public <V> ImmutableBag<V>
countBy(Function<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countBy, org.eclipse.collections.api.RichIterable.countBy.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

public <V> ImmutableBag<V>
countByEach(Function<? super T, ? extends Iterable<V>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countByEach, org.eclipse.collections.api.RichIterable.countByEach.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

public <V, P> ImmutableBag<V>
countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countByWith, org.eclipse.collections.api.RichIterable.countByWith.

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.

public <V> ImmutableMap<V, T>
groupByUniqueKey(Function<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.groupByUniqueKey.

Implements org.eclipse.collections.api.RichIterable.groupByUniqueKey.

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)

public Stream<T>
parallelStream()

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.parallelStream, java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source.

public Optional<T>
reduce(BinaryOperator<T> accumulator)

Overrides default org.eclipse.collections.api.RichIterable.reduce.

This method produces the equivalent result as Stream#reduce(BinaryOperator).

public boolean
remove(Object o)

Implements java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation).

public boolean
removeAll(Collection<?> collection)

Implements java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation).

protected void
removeAllFrom(Iterable<? extends T> elements, MutableCollection<T> result)

public boolean
retainAll(Collection<?> collection)

Implements java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation).

public Spliterator<T>
public Stream<T>
stream()

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.stream, java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.

public <V> ImmutableObjectDoubleMap<V>
sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByDouble, org.eclipse.collections.api.RichIterable.sumByDouble.

Groups and sums the values using the two specified functions.

public <V> ImmutableObjectDoubleMap<V>
sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByFloat, org.eclipse.collections.api.RichIterable.sumByFloat.

Groups and sums the values using the two specified functions.

public <V> ImmutableObjectLongMap<V>
sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByInt, org.eclipse.collections.api.RichIterable.sumByInt.

Groups and sums the values using the two specified functions.

public <V> ImmutableObjectLongMap<V>
sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

public Object[]
toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection.

public <E> E[]
toArray(E[] array)

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

Inherited from org.eclipse.collections.impl.AbstractRichIterable:
allSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringasLazycollectcollectIfcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecountcountWithdetectdetectOptionaldetectWithdetectWithIfNonedetectWithOptionalflatCollectforEachforEachWithforEachWithIndexgroupBygroupByEachgroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntointoisEmptymaxmaxmaxByminminminBynoneSatisfynoneSatisfyWithrejectrejectWithselectselectWithsumOfDoublesumOfFloatsumOfIntsumOfLongtoBagtoBiMaptoListtoMaptoSettoSortedBagtoSortedBagtoSortedBagBytoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoSortedSetBytoStringzipzipWithIndex

Constructor Detail

AbstractImmutableCollectionback to summary
public AbstractImmutableCollection()

Method Detail

addback to summary
public boolean add(T t)

Implements java.util.Collection.add.

Doc from java.util.Collection.add.

Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends T> collection)

Implements java.util.Collection.addAll.

Doc from java.util.Collection.addAll.

Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.

Annotations
@Override
castToCollectionback to summary
public Collection<T> castToCollection()

Implements org.eclipse.collections.api.collection.ImmutableCollection.castToCollection.

Doc from org.eclipse.collections.api.collection.ImmutableCollection.castToCollection.

This can be overridden in most implementations to just return this.

Annotations
@Override
Since
9.0
chunkback to summary
public RichIterable<RichIterable<T>> chunk(int size)

Implements org.eclipse.collections.api.RichIterable.chunk.

Doc from org.eclipse.collections.api.RichIterable.chunk.

Partitions elements in fixed size chunks.

Annotations
@Override
clearback to summary
public void clear()

Implements java.util.Collection.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
countByback to summary
public <V> ImmutableBag<V> countBy(Function<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countBy, org.eclipse.collections.api.RichIterable.countBy.

Doc from org.eclipse.collections.api.RichIterable.countBy.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

Annotations
@Override
Since
9.0
countByEachback to summary
public <V> ImmutableBag<V> countByEach(Function<? super T, ? extends Iterable<V>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countByEach, org.eclipse.collections.api.RichIterable.countByEach.

Doc from org.eclipse.collections.api.RichIterable.countByEach.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

Annotations
@Override
Since
10.0.0
countByWithback to summary
public <V, P> ImmutableBag<V> countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.countByWith, org.eclipse.collections.api.RichIterable.countByWith.

Doc from org.eclipse.collections.api.RichIterable.countByWith.

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.

Annotations
@Override
Since
9.0
groupByUniqueKeyback to summary
public <V> ImmutableMap<V, T> groupByUniqueKey(Function<? super T, ? extends V> function)

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.groupByUniqueKey.

Implements org.eclipse.collections.api.RichIterable.groupByUniqueKey.

Doc from org.eclipse.collections.api.RichIterable.groupByUniqueKey.

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. The generated keys must each be unique, or else an exception is thrown.

Annotations
@Override
newMutableback to summary
protected abstract MutableCollection<T> newMutable(int size)
parallelStreamback to summary
public Stream<T> parallelStream()

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.parallelStream, java.util.Collection.parallelStream.

Doc from java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source. It is allowable for this method to return a sequential stream.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Annotations
@Override
Since
9.0
reduceback to summary
public Optional<T> reduce(BinaryOperator<T> accumulator)

Overrides default org.eclipse.collections.api.RichIterable.reduce.

Doc from org.eclipse.collections.api.RichIterable.reduce.

This method produces the equivalent result as Stream#reduce(BinaryOperator).

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Implements java.util.Collection.remove.

Doc from java.util.Collection.remove.

Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Annotations
@Override
removeAllback to summary
public boolean removeAll(Collection<?> collection)

Implements java.util.Collection.removeAll.

Doc from java.util.Collection.removeAll.

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Annotations
@Override
removeAllFromback to summary
protected void removeAllFrom(Iterable<? extends T> elements, MutableCollection<T> result)
retainAllback to summary
public boolean retainAll(Collection<?> collection)

Implements java.util.Collection.retainAll.

Doc from java.util.Collection.retainAll.

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Annotations
@Override
spliteratorback to summary
public Spliterator<T> spliterator()

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.spliterator, java.util.Collection.spliterator, java.lang.Iterable.spliterator.

Doc from java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator#SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the stream() and parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the stream() and parallelStream() methods to create streams using a Supplier of the spliterator, as in:

Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)

These requirements ensure that streams produced by the stream() and parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Annotations
@Override
Since
9.0
streamback to summary
public Stream<T> stream()

Overrides default org.eclipse.collections.api.collection.ImmutableCollection.stream, java.util.Collection.stream.

Doc from java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Annotations
@Override
Since
9.0
sumByDoubleback to summary
public <V> ImmutableObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByDouble, org.eclipse.collections.api.RichIterable.sumByDouble.

Doc from org.eclipse.collections.api.RichIterable.sumByDouble.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByFloatback to summary
public <V> ImmutableObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByFloat, org.eclipse.collections.api.RichIterable.sumByFloat.

Doc from org.eclipse.collections.api.RichIterable.sumByFloat.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByIntback to summary
public <V> ImmutableObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByInt, org.eclipse.collections.api.RichIterable.sumByInt.

Doc from org.eclipse.collections.api.RichIterable.sumByInt.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByLongback to summary
public <V> ImmutableObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function)

Implements org.eclipse.collections.api.collection.ImmutableCollection.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

Doc from org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

Annotations
@Override
toArrayback to summary
public Object[] toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's runtime component type is Object.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

Annotations
@Override
toArrayback to summary
public <E> E[] toArray(E[] array)

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Implements java.util.Collection.toArray.

Doc from java.util.Collection.toArray.

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Annotations
@Override