Top Description Methods
org.eclipse.collections.api.collection

public Interface FixedSizeCollection<T>

extends MutableCollection<T>
Known Direct Subinterfaces
org.eclipse.collections.api.list.FixedSizeList, org.eclipse.collections.api.set.FixedSizeSet
Imports
java.util.Collection, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure

A FixedSizeCollection is a collection that may be mutated, but cannot grow or shrink in size. It is up to the underlying implementation to decide which mutations are allowable.

Method Summary

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

Redeclares java.util.Collection.add.

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

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

Redeclares java.util.Collection.addAll.

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

public boolean
public void
clear()

Redeclares java.util.Collection.clear.

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

public boolean
remove(Object o)

Redeclares 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)

Redeclares java.util.Collection.removeAll.

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

public boolean
public boolean
removeIf(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.collection.MutableCollection.removeIf.

Removes all elements in the collection that evaluate to true for the specified predicate.

public <P> boolean
removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.collection.MutableCollection.removeIfWith.

Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.

public boolean
retainAll(Collection<?> collection)

Redeclares java.util.Collection.retainAll.

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

public boolean
public FixedSizeCollection<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.collection.MutableCollection.tap.

Executes the Procedure for each element in the iterable and returns this.

public MutableCollection<T>
with(T element)

Redeclares org.eclipse.collections.api.collection.MutableCollection.with.

This method allows fixed size collections the ability to add elements to their existing elements.

public MutableCollection<T>
withAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.MutableCollection.withAll.

This method allows fixed size collections the ability to add multiple elements to their existing elements.

public MutableCollection<T>
without(T element)

Redeclares org.eclipse.collections.api.collection.MutableCollection.without.

This method allows fixed size collections the ability to remove elements from their existing elements.

public MutableCollection<T>
withoutAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.MutableCollection.withoutAll.

This method allows fixed size collections the ability to remove multiple elements from their existing elements.

Inherited from org.eclipse.collections.api.collection.MutableCollection:
aggregateByaggregateInPlaceByasSynchronizedasUnmodifiablecollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcountBycountByEachcountByWithflatCollectflatCollectWithgroupBygroupByEachgroupByUniqueKeyinjectIntoWithnewEmptypartitionpartitionWithrejectrejectWithselectselectAndRejectWithselectInstancesOfselectWithsumByDoublesumByFloatsumByIntsumByLongtoArraytoArraytoImmutablezipzipWithIndex

Method Detail

addback to summary
public boolean add(T t)

Redeclares 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
Exceptions
UnsupportedOperationException:
the add operation is not supported by this collection.
addAllback to summary
public boolean addAll(Collection<? extends T> collection)

Redeclares 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
Exceptions
UnsupportedOperationException:
the addAll operation is not supported by this collection.
addAllIterableback to summary
public boolean addAllIterable(Iterable<? extends T> iterable)

Redeclares org.eclipse.collections.api.collection.MutableCollection.addAllIterable.

Annotations
@Override
Exceptions
UnsupportedOperationException:
the addAllIterable operation is not supported by this collection.
clearback to summary
public void clear()

Redeclares 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
Exceptions
UnsupportedOperationException:
the clear method is not supported by this collection.
removeback to summary
public boolean remove(Object o)

Redeclares 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
Exceptions
UnsupportedOperationException:
the remove operation is not supported by this collection.
removeAllback to summary
public boolean removeAll(Collection<?> collection)

Redeclares 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
Exceptions
UnsupportedOperationException:
the removeAll method is not supported by this collection.
removeAllIterableback to summary
public boolean removeAllIterable(Iterable<?> iterable)

Redeclares org.eclipse.collections.api.collection.MutableCollection.removeAllIterable.

Annotations
@Override
Exceptions
UnsupportedOperationException:
the removeAllIterable method is not supported by this collection.
removeIfback to summary
public boolean removeIf(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.collection.MutableCollection.removeIf.

Doc from org.eclipse.collections.api.collection.MutableCollection.removeIf.

Removes all elements in the collection that evaluate to true for the specified predicate.

e.g.
return lastNames.removeIf(Predicates.isNull());
Annotations
@Override
Exceptions
UnsupportedOperationException:
the removeIf method is not supported by this collection.
removeIfWithback to summary
public <P> boolean removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.collection.MutableCollection.removeIfWith.

Doc from org.eclipse.collections.api.collection.MutableCollection.removeIfWith.

Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.

return lastNames.removeIfWith(Predicates2.isNull(), null);
Annotations
@Override
Exceptions
UnsupportedOperationException:
the removeIfWith method is not supported by this collection.
retainAllback to summary
public boolean retainAll(Collection<?> collection)

Redeclares 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
Exceptions
UnsupportedOperationException:
the retainAll method is not supported by this collection.
retainAllIterableback to summary
public boolean retainAllIterable(Iterable<?> iterable)

Redeclares org.eclipse.collections.api.collection.MutableCollection.retainAllIterable.

Annotations
@Override
Exceptions
UnsupportedOperationException:
the retainAllIterable method is not supported by this collection.
tapback to summary
public FixedSizeCollection<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.collection.MutableCollection.tap.

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

Executes the Procedure for each element in the iterable and returns this.

Example using a Java 8 lambda expression:

RichIterable<Person> tapped =
    people.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
withback to summary
public MutableCollection<T> with(T element)

Redeclares org.eclipse.collections.api.collection.MutableCollection.with.

This method allows fixed size collections the ability to add elements to their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the new element added. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.with("1");
list = list.with("2");
return list;
Annotations
@Override
See Also
add(Object)
withAllback to summary
public MutableCollection<T> withAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.MutableCollection.withAll.

This method allows fixed size collections the ability to add multiple elements to their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with all the new elements addAll(Collection) added. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.withAll(FastList.newListWith("1", "2"));
return list;
Annotations
@Override
See Also
addAll(Collection)
withoutback to summary
public MutableCollection<T> without(T element)

Redeclares org.eclipse.collections.api.collection.MutableCollection.without.

This method allows fixed size collections the ability to remove elements from their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the element removed. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.without("1");
list = list.without("2");
return list;
Annotations
@Override
See Also
remove(Object)
withoutAllback to summary
public MutableCollection<T> withoutAll(Iterable<? extends T> elements)

Redeclares org.eclipse.collections.api.collection.MutableCollection.withoutAll.

This method allows fixed size collections the ability to remove multiple elements from their existing elements. A new instance of MutableCollection is returned containing the elements of the original collection with the given elements removed. Implementations will return a new FixedSizeCollection where possible. In order to use this method properly with mutable and fixed size collections the following approach must be taken:

MutableCollection<String> list;
list = list.withoutAll(FastList.newListWith("1", "2"));
return list;
Annotations
@Override
See Also
removeAll(Collection)