Interface FixedSizeCollection<T>
- All Superinterfaces:
Collection<T>
,InternalIterable<T>
,Iterable<T>
,MutableCollection<T>
,RichIterable<T>
- All Known Subinterfaces:
FixedSizeList<T>
,FixedSizeSet<T>
- All Known Implementing Classes:
AbstractMemoryEfficientMutableList
,ArrayAdapter
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 TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> collection) boolean
addAllIterable
(Iterable<? extends T> iterable) void
clear()
boolean
boolean
removeAll
(Collection<?> collection) boolean
removeAllIterable
(Iterable<?> iterable) boolean
Removes all elements in the collection that evaluate to true for the specified predicate.<P> boolean
removeIfWith
(Predicate2<? super T, ? super P> predicate, P parameter) Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.boolean
retainAll
(Collection<?> collection) boolean
retainAllIterable
(Iterable<?> iterable) Executes the Procedure for each element in the iterable and returnsthis
.This method allows fixed size collections the ability to add elements to their existing elements.This method allows fixed size collections the ability to add multiple elements to their existing elements.This method allows fixed size collections the ability to remove elements from their existing elements.withoutAll
(Iterable<? extends T> elements) This method allows fixed size collections the ability to remove multiple elements from their existing elements.Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, size, spliterator, stream, toArray, toArray, toArray
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndex
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, countBy, countByEach, countByWith, flatCollect, flatCollectWith, groupBy, groupByEach, groupByUniqueKey, injectIntoWith, newEmpty, partition, partitionWith, reject, rejectWith, select, selectAndRejectWith, selectInstancesOf, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, toImmutable, zip, zipWithIndex
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, contains, containsAll, containsAllArguments, containsAllIterable, containsBy, 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, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, 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 Details
-
with
This method allows fixed size collections the ability to add elements to their existing elements. A new instance ofMutableCollection
is returned containing the elements of the original collection with the new elementadded
. 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;
- Specified by:
with
in interfaceMutableCollection<T>
- See Also:
-
without
This method allows fixed size collections the ability to remove elements from their existing elements. A new instance ofMutableCollection
is returned containing the elements of the original collection with the elementremoved
. 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;
- Specified by:
without
in interfaceMutableCollection<T>
- See Also:
-
withAll
This method allows fixed size collections the ability to add multiple elements to their existing elements. A new instance ofMutableCollection
is returned containing the elements of the original collection with all of the new elementsadded
. 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;
- Specified by:
withAll
in interfaceMutableCollection<T>
- See Also:
-
withoutAll
This method allows fixed size collections the ability to remove multiple elements from their existing elements. A new instance ofMutableCollection
is returned containing the elements of the original collection with the given elementsremoved
. 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;
- Specified by:
withoutAll
in interfaceMutableCollection<T>
- See Also:
-
add
- Specified by:
add
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theadd
operation is not supported by this collection.
-
addAllIterable
- Specified by:
addAllIterable
in interfaceMutableCollection<T>
- Throws:
UnsupportedOperationException
- theaddAllIterable
operation is not supported by this collection.- See Also:
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theaddAll
operation is not supported by this collection.
-
remove
- Specified by:
remove
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theremove
operation is not supported by this collection.
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theremoveAll
method is not supported by this collection.
-
removeAllIterable
- Specified by:
removeAllIterable
in interfaceMutableCollection<T>
- Throws:
UnsupportedOperationException
- theremoveAllIterable
method is not supported by this collection.- See Also:
-
removeIf
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIf
in interfaceMutableCollection<T>
- Throws:
UnsupportedOperationException
- theremoveIf
method is not supported by this collection.
-
removeIfWith
Description copied from interface:MutableCollection
Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWith
in interfaceMutableCollection<T>
- Throws:
UnsupportedOperationException
- theremoveIfWith
method is not supported by this collection.
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theretainAll
method is not supported by this collection.
-
retainAllIterable
- Specified by:
retainAllIterable
in interfaceMutableCollection<T>
- Throws:
UnsupportedOperationException
- theretainAllIterable
method is not supported by this collection.- See Also:
-
clear
void clear()- Specified by:
clear
in interfaceCollection<T>
- Throws:
UnsupportedOperationException
- theclear
method is not supported by this collection.
-
tap
Description copied from interface:RichIterable
Executes the Procedure for each element in the iterable and returnsthis
.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
RichIterable<Person> tapped = people.tap(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
- Specified by:
tap
in interfaceMutableCollection<T>
- Specified by:
tap
in interfaceRichIterable<T>
- See Also:
-