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 TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> collection) booleanaddAllIterable(Iterable<? extends T> iterable) voidclear()booleanbooleanremoveAll(Collection<?> collection) booleanremoveAllIterable(Iterable<?> iterable) booleanRemoves all elements in the collection that evaluate to true for the specified predicate.<P> booleanremoveIfWith(Predicate2<? super T, ? super P> predicate, P parameter) Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.booleanretainAll(Collection<?> collection) booleanretainAllIterable(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, toArrayMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEach, forEachWith, forEachWithIndexMethods 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, zipWithIndexMethods 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 ofMutableCollectionis 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:
within interfaceMutableCollection<T>- See Also:
-
without
This method allows fixed size collections the ability to remove elements from their existing elements. A new instance ofMutableCollectionis 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:
withoutin interfaceMutableCollection<T>- See Also:
-
withAll
This method allows fixed size collections the ability to add multiple elements to their existing elements. A new instance ofMutableCollectionis 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:
withAllin interfaceMutableCollection<T>- See Also:
-
withoutAll
This method allows fixed size collections the ability to remove multiple elements from their existing elements. A new instance ofMutableCollectionis 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:
withoutAllin interfaceMutableCollection<T>- See Also:
-
add
- Specified by:
addin interfaceCollection<T>- Throws:
UnsupportedOperationException- theaddoperation is not supported by this collection.
-
addAllIterable
- Specified by:
addAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theaddAllIterableoperation is not supported by this collection.- See Also:
-
addAll
- Specified by:
addAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theaddAlloperation is not supported by this collection.
-
remove
- Specified by:
removein interfaceCollection<T>- Throws:
UnsupportedOperationException- theremoveoperation is not supported by this collection.
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theremoveAllmethod is not supported by this collection.
-
removeAllIterable
- Specified by:
removeAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theremoveAllIterablemethod is not supported by this collection.- See Also:
-
removeIf
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate.e.g. return lastNames.removeIf(Predicates.isNull());
- Specified by:
removeIfin interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theremoveIfmethod is not supported by this collection.
-
removeIfWith
Description copied from interface:MutableCollectionRemoves all elements in the collection that evaluate to true for the specified predicate2 and parameter.return lastNames.removeIfWith(Predicates2.isNull(), null);
- Specified by:
removeIfWithin interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theremoveIfWithmethod is not supported by this collection.
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theretainAllmethod is not supported by this collection.
-
retainAllIterable
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theretainAllIterablemethod is not supported by this collection.- See Also:
-
clear
void clear()- Specified by:
clearin interfaceCollection<T>- Throws:
UnsupportedOperationException- theclearmethod is not supported by this collection.
-
tap
Description copied from interface:RichIterableExecutes 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:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceRichIterable<T>- See Also:
-