Interface FixedSizeCollection<T>
-
- All Superinterfaces:
Collection<T>,InternalIterable<T>,Iterable<T>,MutableCollection<T>,RichIterable<T>
- All Known Subinterfaces:
FixedSizeList<T>,FixedSizeSet<T>
public interface FixedSizeCollection<T> extends MutableCollection<T>
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanadd(T t)booleanaddAll(Collection<? extends T> collection)booleanaddAllIterable(Iterable<? extends T> iterable)voidclear()booleanremove(Object o)booleanremoveAll(Collection<?> collection)booleanremoveAllIterable(Iterable<?> iterable)booleanremoveIf(Predicate<? super T> predicate)Removes 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)FixedSizeCollection<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.MutableCollection<T>with(T element)This method allows fixed size collections the ability to add elements to their existing elements.MutableCollection<T>withAll(Iterable<? extends T> elements)This method allows fixed size collections the ability to add multiple elements to their existing elements.MutableCollection<T>without(T element)This method allows fixed size collections the ability to remove elements from their existing elements.MutableCollection<T>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, 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, 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 Detail
-
with
MutableCollection<T> with(T element)
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:
add(Object)
-
without
MutableCollection<T> without(T element)
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:
remove(Object)
-
withAll
MutableCollection<T> withAll(Iterable<? extends T> elements)
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 the new elementsaddAll(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;- Specified by:
withAllin interfaceMutableCollection<T>- See Also:
addAll(Collection)
-
withoutAll
MutableCollection<T> withoutAll(Iterable<? extends T> elements)
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:
removeAll(Collection)
-
add
boolean add(T t)
- Specified by:
addin interfaceCollection<T>- Throws:
UnsupportedOperationException- theaddoperation is not supported by this collection.
-
addAllIterable
boolean addAllIterable(Iterable<? extends T> iterable)
- Specified by:
addAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theaddAllIterableoperation is not supported by this collection.- See Also:
Collection.addAll(Collection)
-
addAll
boolean addAll(Collection<? extends T> collection)
- Specified by:
addAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theaddAlloperation is not supported by this collection.
-
remove
boolean remove(Object o)
- Specified by:
removein interfaceCollection<T>- Throws:
UnsupportedOperationException- theremoveoperation is not supported by this collection.
-
removeAll
boolean removeAll(Collection<?> collection)
- Specified by:
removeAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theremoveAllmethod is not supported by this collection.
-
removeAllIterable
boolean removeAllIterable(Iterable<?> iterable)
- Specified by:
removeAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theremoveAllIterablemethod is not supported by this collection.- See Also:
Collection.removeAll(Collection)
-
removeIf
boolean removeIf(Predicate<? super T> predicate)
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
<P> boolean removeIfWith(Predicate2<? super T,? super P> predicate, P parameter)
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
boolean retainAll(Collection<?> collection)
- Specified by:
retainAllin interfaceCollection<T>- Throws:
UnsupportedOperationException- theretainAllmethod is not supported by this collection.
-
retainAllIterable
boolean retainAllIterable(Iterable<?> iterable)
- Specified by:
retainAllIterablein interfaceMutableCollection<T>- Throws:
UnsupportedOperationException- theretainAllIterablemethod is not supported by this collection.- See Also:
Collection.retainAll(Collection)
-
clear
void clear()
- Specified by:
clearin interfaceCollection<T>- Throws:
UnsupportedOperationException- theclearmethod is not supported by this collection.
-
tap
FixedSizeCollection<T> tap(Procedure<? super T> procedure)
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()));- Specified by:
tapin interfaceMutableCollection<T>- Specified by:
tapin interfaceRichIterable<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
-