Class CompositeFastList<E>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,MutableCollection<E>
,InternalIterable<E>
,ListIterable<E>
,MutableList<E>
,OrderedIterable<E>
,ReversibleIterable<E>
,RichIterable<E>
,BatchIterable<E>
public final class CompositeFastList<E> extends AbstractMutableList<E> implements BatchIterable<E>, Serializable
Note: mutation operations (e.g. add and remove, sorting) will change the underlying lists - so be sure to only use a composite list where it will be the only reference to the sublists (for example, a composite list which contains multiple query results is OK as long as it is the only thing that references the lists)
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description CompositeFastList()
-
Method Summary
Modifier and Type Method Description void
add(int index, E element)
boolean
add(E object)
boolean
addAll(int index, Collection<? extends E> collection)
boolean
addAll(Collection<? extends E> collection)
void
addComposited(Collection<? extends E> collection)
boolean
allSatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.<P> boolean
allSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
Returns true if the predicate evaluates to true for every element of the collection, or returns false.boolean
anySatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.<P> boolean
anySatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.ParallelListIterable<E>
asParallel(ExecutorService executorService, int batchSize)
Returns a parallel iterable of this ListIterable.void
batchForEach(Procedure<? super E> procedure, int sectionIndex, int sectionCount)
void
clear()
MutableList<E>
clone()
<V, R extends Collection<V>>
Rcollect(Function<? super E,? extends V> function, R target)
Same asRichIterable.collect(Function)
, except that the results are gathered into the specifiedtarget
collection.<P, A, R extends Collection<A>>
RcollectWith(Function2<? super E,? super P,? extends A> function, P parameter, R target)
Same as collectWith but with a targetCollection parameter to gather the results.boolean
contains(Object object)
Returns true if the iterable has an element which responds true to element.equals(object).boolean
containsAll(Collection<?> collection)
Returns true if all elements in source are contained in this collection.int
count(Predicate<? super E> predicate)
Return the total number of elements that answer true to the specified predicate.<P> int
countWith(Predicate2<? super E,? super P> predicate, P parameter)
Returns the total number of elements that evaluate to true for the specified predicate.void
each(Procedure<? super E> procedure)
The procedure is executed for each element in the iterable.<P> void
forEachWith(Procedure2<? super E,? super P> procedure2, P parameter)
The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.void
forEachWithIndex(ObjectIntProcedure<? super E> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.E
get(int index)
Returns the item at the specified position in this list iterable.int
getBatchCount(int batchSize)
int
indexOf(Object o)
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.double
injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super E> function)
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.float
injectInto(float injectedValue, FloatObjectToFloatFunction<? super E> function)
Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.int
injectInto(int injectedValue, IntObjectToIntFunction<? super E> function)
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.long
injectInto(long injectedValue, LongObjectToLongFunction<? super E> function)
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<IV> IV
injectInto(IV injectedValue, Function2<? super IV,? super E,? extends IV> function)
Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.boolean
isEmpty()
Returns true if this iterable has zero items.Iterator<E>
iterator()
int
lastIndexOf(Object o)
Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.ListIterator<E>
listIterator()
a list iterator is a problem for a composite list as going back in the order of the list is an issue, as are the other methods like set() and add() (and especially, remove).ListIterator<E>
listIterator(int index)
a list iterator is a problem for a composite list as going back in the order of the list is an issue, as are the other methods like set() and add() (and especially, remove).boolean
noneSatisfy(Predicate<? super E> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.<P> boolean
noneSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.<R extends Collection<E>>
Rreject(Predicate<? super E> predicate, R target)
Same as the reject method with one parameter but uses the specified target collection for the results.<P, R extends Collection<E>>
RrejectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)
Similar toRichIterable.reject(Predicate, Collection)
, except with an evaluation parameter for the second generic argument inPredicate2
.E
remove(int index)
boolean
remove(Object object)
boolean
removeAll(Collection<?> collection)
void
replaceAll(UnaryOperator<E> operator)
void
resetSize()
boolean
retainAll(Collection<?> collection)
void
reverseForEach(Procedure<? super E> procedure)
Evaluates the procedure for each element of the list iterating in reverse order.void
reverseForEachWithIndex(ObjectIntProcedure<? super E> procedure)
Evaluates the procedure for each element and it's index in reverse order.CompositeFastList<E>
reverseThis()
Mutates this list by reversing its order and returns the current list as a result.<R extends Collection<E>>
Rselect(Predicate<? super E> predicate, R target)
Same as the select method with one parameter but uses the specified target collection for the results.<P, R extends Collection<E>>
RselectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)
Similar toRichIterable.select(Predicate, Collection)
, except with an evaluation parameter for the second generic argument inPredicate2
.E
set(int index, E element)
int
size()
Returns the number of items in this iterable.void
sort(Comparator<? super E> comparator)
Object[]
toArray()
Converts this iterable to an array.Object[]
toArray(Object[] array)
Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.Methods inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
appendString, appendString, asReversed, asSynchronized, asUnmodifiable, binarySearch, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, corresponds, detect, detectIndex, detectLastIndex, detectOptional, detectWith, detectWithOptional, distinct, distinct, distinctBy, drop, dropWhile, equals, flatCollect, forEach, forEachWithIndex, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, hashCode, injectIntoWith, max, max, maxBy, min, min, minBy, newEmpty, partition, partitionWhile, partitionWith, removeIf, removeIfWith, selectAndRejectWith, selectInstancesOf, sortThisBy, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, subList, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, tap, toSet, toSortedList, toStack, zip, zip, zipWithIndex, zipWithIndex
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
addAllIterable, aggregateInPlaceBy, countBy, countByEach, countByWith, reduce, removeAllIterable, retainAllIterable, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, detectWithIfNone, forEach, groupBy, groupByEach, groupByUniqueKey, into, toBag, toBiMap, toList, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
Methods inherited from interface org.eclipse.collections.api.list.ListIterable
binarySearch, forEachInBoth
Methods inherited from interface org.eclipse.collections.api.collection.MutableCollection
addAllIterable, aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, removeAllIterable, retainAllIterable, sumByDouble, sumByFloat, sumByInt, sumByLong
Methods inherited from interface org.eclipse.collections.api.list.MutableList
collect, collectIf, collectWith, collectWithIndex, flatCollect, flatCollectWith, reject, rejectWith, select, selectWith, shuffleThis, shuffleThis, sortThis, sortThis, toImmutable, toReversed, with, withAll, without, withoutAll
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, getFirstOptional, getLastOptional
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, appendString, asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, containsBy, countBy, countByEach, countByWith, detectIfNone, detectWithIfNone, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, into, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toBag, toBiMap, toList, toMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
Constructor Details
-
CompositeFastList
public CompositeFastList()
-
-
Method Details
-
clone
- Specified by:
clone
in interfaceMutableList<E>
- Overrides:
clone
in classAbstractMutableList<E>
-
size
public int size()Description copied from interface:RichIterable
Returns the number of items in this iterable.- Specified by:
size
in interfaceBatchIterable<E>
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in interfaceRichIterable<E>
-
resetSize
public void resetSize() -
batchForEach
- Specified by:
batchForEach
in interfaceBatchIterable<E>
-
getBatchCount
public int getBatchCount(int batchSize)- Specified by:
getBatchCount
in interfaceBatchIterable<E>
-
reverseThis
Description copied from interface:MutableList
Mutates this list by reversing its order and returns the current list as a result.- Specified by:
reverseThis
in interfaceMutableList<E>
-
each
Description copied from interface:RichIterable
The procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });
This method is a variant ofInternalIterable.forEach(Procedure)
that has a signature conflict withIterable.forEach(java.util.function.Consumer)
.- Specified by:
each
in interfaceRichIterable<E>
- Overrides:
each
in classAbstractMutableList<E>
- See Also:
InternalIterable.forEach(Procedure)
,Iterable.forEach(java.util.function.Consumer)
-
injectInto
public <IV> IV injectInto(IV injectedValue, Function2<? super IV,? super E,? extends IV> function)Description copied from interface:RichIterable
Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.- Specified by:
injectInto
in interfaceRichIterable<E>
- Overrides:
injectInto
in classAbstractMutableList<E>
-
injectInto
Description copied from interface:RichIterable
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectInto
in interfaceRichIterable<E>
- Overrides:
injectInto
in classAbstractMutableList<E>
-
injectInto
Description copied from interface:RichIterable
Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectInto
in interfaceRichIterable<E>
- Overrides:
injectInto
in classAbstractMutableList<E>
-
injectInto
Description copied from interface:RichIterable
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectInto
in interfaceRichIterable<E>
- Overrides:
injectInto
in classAbstractMutableList<E>
-
injectInto
Description copied from interface:RichIterable
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectInto
in interfaceRichIterable<E>
- Overrides:
injectInto
in classAbstractRichIterable<E>
-
forEachWithIndex
Description copied from interface:InternalIterable
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
- Specified by:
forEachWithIndex
in interfaceInternalIterable<E>
- Specified by:
forEachWithIndex
in interfaceOrderedIterable<E>
- Overrides:
forEachWithIndex
in classAbstractMutableList<E>
-
reverseForEach
Description copied from interface:ReversibleIterable
Evaluates the procedure for each element of the list iterating in reverse order.e.g. people.reverseForEach(person -> LOGGER.info(person.getName()));
- Specified by:
reverseForEach
in interfaceReversibleIterable<E>
-
reverseForEachWithIndex
Description copied from interface:ReversibleIterable
Evaluates the procedure for each element and it's index in reverse order.e.g. people.reverseForEachWithIndex((person, index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
- Specified by:
reverseForEachWithIndex
in interfaceReversibleIterable<E>
-
forEachWith
Description copied from interface:InternalIterable
The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) -> { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } }, fred);
Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
- Specified by:
forEachWith
in interfaceInternalIterable<E>
- Overrides:
forEachWith
in classAbstractMutableList<E>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterable
Returns true if this iterable has zero items.- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceList<E>
- Specified by:
isEmpty
in interfaceRichIterable<E>
- Overrides:
isEmpty
in classAbstractRichIterable<E>
-
contains
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceList<E>
- Specified by:
contains
in interfaceRichIterable<E>
- Overrides:
contains
in classAbstractMutableList<E>
-
iterator
-
toArray
Description copied from interface:RichIterable
Converts this iterable to an array.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceList<E>
- Specified by:
toArray
in interfaceRichIterable<E>
- Overrides:
toArray
in classAbstractRichIterable<E>
- See Also:
Collection.toArray()
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Overrides:
add
in classAbstractMutableCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceList<E>
- Overrides:
remove
in classAbstractMutableCollection<E>
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceList<E>
- Overrides:
addAll
in classAbstractMutableCollection<E>
-
containsAll
Description copied from interface:RichIterable
Returns true if all elements in source are contained in this collection.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
- Specified by:
containsAll
in interfaceRichIterable<E>
- Overrides:
containsAll
in classAbstractMutableList<E>
- See Also:
Collection.containsAll(Collection)
-
toArray
Description copied from interface:RichIterable
Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceList<E>
- Specified by:
toArray
in interfaceRichIterable<E>
- Overrides:
toArray
in classAbstractRichIterable<E>
- See Also:
Collection.toArray(Object[])
-
addComposited
-
addAll
-
clear
public void clear() -
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceList<E>
- Overrides:
retainAll
in classAbstractMutableList<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceList<E>
- Overrides:
removeAll
in classAbstractMutableList<E>
-
get
Description copied from interface:ListIterable
Returns the item at the specified position in this list iterable. -
set
-
add
-
remove
-
indexOf
Description copied from interface:OrderedIterable
Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.- Specified by:
indexOf
in interfaceList<E>
- Specified by:
indexOf
in interfaceOrderedIterable<E>
- Overrides:
indexOf
in classAbstractMutableList<E>
- See Also:
List.indexOf(Object)
-
lastIndexOf
Description copied from interface:ListIterable
Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.- Specified by:
lastIndexOf
in interfaceList<E>
- Specified by:
lastIndexOf
in interfaceListIterable<E>
- Overrides:
lastIndexOf
in classAbstractMutableList<E>
-
replaceAll
- Specified by:
replaceAll
in interfaceList<E>
- Since:
- 10.0
-
sort
-
listIterator
a list iterator is a problem for a composite list as going back in the order of the list is an issue, as are the other methods like set() and add() (and especially, remove). Convert the internal lists to one list (if not already just one list) and return that list's list iterator.AFAIK list iterator is only commonly used in sorting.
- Specified by:
listIterator
in interfaceList<E>
- Specified by:
listIterator
in interfaceListIterable<E>
- Overrides:
listIterator
in classAbstractMutableList<E>
- Returns:
- a ListIterator for this, with internal state converted to one list if needed.
- See Also:
List.listIterator()
-
listIterator
a list iterator is a problem for a composite list as going back in the order of the list is an issue, as are the other methods like set() and add() (and especially, remove). Convert the internal lists to one list (if not already just one list) and return that list's list iterator.AFAIK list iterator is only commonly used in sorting.
- Specified by:
listIterator
in interfaceList<E>
- Specified by:
listIterator
in interfaceListIterable<E>
- Overrides:
listIterator
in classAbstractMutableList<E>
- Returns:
- a ListIterator for this, with internal state converted to one list if needed.
- See Also:
List.listIterator(int)
-
count
Description copied from interface:RichIterable
Return the total number of elements that answer true to the specified predicate.Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));
Example using an anonymous inner class:
int count = people.count(new Predicate<Person>() { public boolean accept(Person person) { return person.getAddress().getState().getName().equals("New York"); } });
- Specified by:
count
in interfaceRichIterable<E>
- Overrides:
count
in classAbstractMutableList<E>
-
countWith
Description copied from interface:RichIterable
Returns the total number of elements that evaluate to true for the specified predicate.e.g. return lastNames.countWith(Predicates2.equal(), "Smith");
- Specified by:
countWith
in interfaceRichIterable<E>
- Overrides:
countWith
in classAbstractMutableList<E>
-
anySatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfy
in interfaceRichIterable<E>
- Overrides:
anySatisfy
in classAbstractMutableList<E>
-
select
Description copied from interface:RichIterable
Same as the select method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> selected = people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> selected = people.select(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());
- Specified by:
select
in interfaceRichIterable<E>
- Overrides:
select
in classAbstractMutableList<E>
- Parameters:
predicate
- aPredicate
to use as the select criteriatarget
- the Collection to append to for all elements in thisRichIterable
that meet select criteriapredicate
- Returns:
target
, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate)
-
selectWith
public <P, R extends Collection<E>> R selectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)Description copied from interface:RichIterable
Similar toRichIterable.select(Predicate, Collection)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> selected = people.selectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge()>= age; } }, Integer.valueOf(18), Lists.mutable.empty());
- Specified by:
selectWith
in interfaceRichIterable<E>
- Overrides:
selectWith
in classAbstractMutableList<E>
- Parameters:
predicate
- aPredicate2
to use as the select criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
target
- the Collection to append to for all elements in thisRichIterable
that meet select criteriapredicate
- Returns:
targetCollection
, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate)
,RichIterable.select(Predicate, Collection)
-
reject
Description copied from interface:RichIterable
Same as the reject method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> rejected = people.reject(new Predicate<Person>() { public boolean accept(Person person) { return person.person.getLastName().equals("Smith"); } }, Lists.mutable.empty());
- Specified by:
reject
in interfaceRichIterable<E>
- Overrides:
reject
in classAbstractMutableList<E>
- Parameters:
predicate
- aPredicate
to use as the reject criteriatarget
- the Collection to append to for all elements in thisRichIterable
that causePredicate#accept(Object)
method to evaluate to false- Returns:
target
, which contains appended elements as a result of the reject criteria
-
rejectWith
public <P, R extends Collection<E>> R rejectWith(Predicate2<? super E,? super P> predicate, P parameter, R target)Description copied from interface:RichIterable
Similar toRichIterable.reject(Predicate, Collection)
, except with an evaluation parameter for the second generic argument inPredicate2
.E.g. return a
Collection
of Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<Person> rejected = people.rejectWith(new Predicate2<Person, Integer>() { public boolean accept(Person person, Integer age) { return person.getAge() < age; } }, Integer.valueOf(18), Lists.mutable.empty());
- Specified by:
rejectWith
in interfaceRichIterable<E>
- Overrides:
rejectWith
in classAbstractMutableList<E>
- Parameters:
predicate
- aPredicate2
to use as the reject criteriaparameter
- a parameter to pass in for evaluation of the second argumentP
inpredicate
target
- the Collection to append to for all elements in thisRichIterable
that causePredicate#accept(Object)
method to evaluate to false- Returns:
targetCollection
, which contains appended elements as a result of the reject criteria- See Also:
RichIterable.reject(Predicate)
,RichIterable.reject(Predicate, Collection)
-
collect
public <V, R extends Collection<V>> R collect(Function<? super E,? extends V> function, R target)Description copied from interface:RichIterable
Same asRichIterable.collect(Function)
, except that the results are gathered into the specifiedtarget
collection.Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());
Example using an anonymous inner class:
MutableList<String> names = people.collect(new Function<Person, String>() { public String valueOf(Person person) { return person.getFirstName() + " " + person.getLastName(); } }, Lists.mutable.empty());
- Specified by:
collect
in interfaceRichIterable<E>
- Overrides:
collect
in classAbstractMutableList<E>
- Parameters:
function
- aFunction
to use as the collect transformation functiontarget
- the Collection to append to for all elements in thisRichIterable
that meet select criteriafunction
- Returns:
target
, which contains appended elements as a result of the collect transformation- See Also:
RichIterable.collect(Function)
-
collectWith
public <P, A, R extends Collection<A>> R collectWith(Function2<? super E,? super P,? extends A> function, P parameter, R target)Description copied from interface:RichIterable
Same as collectWith but with a targetCollection parameter to gather the results.Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());
Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction = new Function2<Integer, Integer, Integer>() { public Integer value(final Integer each, final Integer parameter) { return each + parameter; } }; MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());
- Specified by:
collectWith
in interfaceRichIterable<E>
- Overrides:
collectWith
in classAbstractMutableList<E>
- Parameters:
function
- aFunction2
to use as the collect transformation functionparameter
- a parameter to pass in for evaluation of the second argumentP
infunction
target
- the Collection to append to for all elements in thisRichIterable
that meet select criteriafunction
- Returns:
targetCollection
, which contains appended elements as a result of the collect transformation
-
anySatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWith
in interfaceRichIterable<E>
- Overrides:
anySatisfyWith
in classAbstractMutableList<E>
-
allSatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfy
in interfaceRichIterable<E>
- Overrides:
allSatisfy
in classAbstractMutableList<E>
-
allSatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWith
in interfaceRichIterable<E>
- Overrides:
allSatisfyWith
in classAbstractMutableList<E>
-
noneSatisfy
Description copied from interface:RichIterable
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfy
in interfaceRichIterable<E>
- Overrides:
noneSatisfy
in classAbstractMutableList<E>
-
noneSatisfyWith
Description copied from interface:RichIterable
Returns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWith
in interfaceRichIterable<E>
- Overrides:
noneSatisfyWith
in classAbstractMutableList<E>
-
asParallel
Description copied from interface:ListIterable
Returns a parallel iterable of this ListIterable.- Specified by:
asParallel
in interfaceListIterable<E>
- Overrides:
asParallel
in classAbstractMutableList<E>
-