Class CompositeFastList<E>
- java.lang.Object
-
- org.eclipse.collections.impl.AbstractRichIterable<T>
-
- org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection<T>
-
- org.eclipse.collections.impl.list.mutable.AbstractMutableList<E>
-
- org.eclipse.collections.impl.list.mutable.CompositeFastList<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.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>, java.io.Serializable
CompositeFastList behaves like a list, but is composed of at least one list. It is useful where you don't want the additional expense of appending several lists or allocating memory for a super list to add multiple sublists to.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CompositeFastList.CompositeIterator
private static class
CompositeFastList.ProcedureToInnerListObjectIntProcedure<E>
private static class
CompositeFastList.ProcedureToReverseInnerListObjectIntProcedure<E>
-
Nested classes/interfaces inherited from class org.eclipse.collections.impl.list.mutable.AbstractMutableList
AbstractMutableList.SubList<T>
-
-
Field Summary
Fields Modifier and Type Field Description private FastList<FastList<E>>
lists
private static Predicate2<FastList<?>,java.lang.Object>
REMOVE_PREDICATE
private static Procedure<FastList<?>>
REVERSE_LIST_PROCEDURE
private static long
serialVersionUID
private int
size
-
Constructor Summary
Constructors Constructor Description CompositeFastList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
boolean
add(E object)
boolean
addAll(int index, java.util.Collection<? extends E> collection)
boolean
addAll(java.util.Collection<? extends E> collection)
void
addComposited(java.util.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(java.util.concurrent.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 java.util.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 java.util.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(java.lang.Object object)
Returns true if the iterable has an element which responds true to element.equals(object).boolean
containsAll(java.util.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.private void
flattenLists()
convert multiple contained lists into one list and replace the contained lists with that list.<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(java.lang.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.java.util.Iterator<E>
iterator()
int
lastIndexOf(java.lang.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.java.util.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).java.util.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.private void
rangeCheck(int index)
<R extends java.util.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 java.util.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(java.lang.Object object)
boolean
removeAll(java.util.Collection<?> collection)
void
replaceAll(java.util.function.UnaryOperator<E> operator)
void
resetSize()
boolean
retainAll(java.util.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 java.util.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 java.util.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(java.util.Comparator<? super E> comparator)
java.lang.Object[]
toArray()
Converts this iterable to an array.java.lang.Object[]
toArray(java.lang.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, collectIf, 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, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, subList, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, take, takeWhile, tap, toSet, toSortedList, zip, zip, zipWithIndex, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.collection.mutable.AbstractMutableCollection
addAllIterable, countBy, countByEach, countByWith, reduce, removeAllIterable, retainAllIterable, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
asLazy, 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 class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.impl.parallel.BatchIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
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, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, collectWithIndex, flatCollect, flatCollectWith, reject, rejectWith, rejectWithIndex, select, selectWith, selectWithIndex, shuffleThis, shuffleThis, sortThis, sortThis, sortThisBy, toImmutable, toImmutableList, toReversed, with, withAll, without, withoutAll
-
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, getFirstOptional, getLastOptional, rejectWithIndex, selectWithIndex, toStack
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, appendString, asLazy, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countByEach, countByWith, detectIfNone, detectWithIfNone, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, notEmpty, reduce, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString
-
-
-
-
Field Detail
-
REMOVE_PREDICATE
private static final Predicate2<FastList<?>,java.lang.Object> REMOVE_PREDICATE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
size
private int size
-
-
Method Detail
-
clone
public MutableList<E> 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 interfacejava.util.Collection<E>
- Specified by:
size
in interfacejava.util.List<E>
- Specified by:
size
in interfaceRichIterable<E>
-
resetSize
public void resetSize()
-
batchForEach
public void batchForEach(Procedure<? super E> procedure, int sectionIndex, int sectionCount)
- Specified by:
batchForEach
in interfaceBatchIterable<E>
-
getBatchCount
public int getBatchCount(int batchSize)
- Specified by:
getBatchCount
in interfaceBatchIterable<E>
-
reverseThis
public CompositeFastList<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
public void each(Procedure<? super E> procedure)
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
public int injectInto(int injectedValue, IntObjectToIntFunction<? super E> function)
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
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super E> function)
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
public long injectInto(long injectedValue, LongObjectToLongFunction<? super E> function)
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
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super E> function)
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
public void forEachWithIndex(ObjectIntProcedure<? super E> objectIntProcedure)
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
public void reverseForEach(Procedure<? super E> procedure)
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
public void reverseForEachWithIndex(ObjectIntProcedure<? super E> procedure)
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
public <P> void forEachWith(Procedure2<? super E,? super P> procedure2, P parameter)
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 interfacejava.util.Collection<E>
- Specified by:
isEmpty
in interfacejava.util.List<E>
- Specified by:
isEmpty
in interfaceRichIterable<E>
- Overrides:
isEmpty
in classAbstractRichIterable<E>
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterable
Returns true if the iterable has an element which responds true to element.equals(object).- Specified by:
contains
in interfacejava.util.Collection<E>
- Specified by:
contains
in interfacejava.util.List<E>
- Specified by:
contains
in interfaceRichIterable<E>
- Overrides:
contains
in classAbstractMutableList<E>
-
iterator
public java.util.Iterator<E> iterator()
-
toArray
public java.lang.Object[] toArray()
Description copied from interface:RichIterable
Converts this iterable to an array.- Specified by:
toArray
in interfacejava.util.Collection<E>
- Specified by:
toArray
in interfacejava.util.List<E>
- Specified by:
toArray
in interfaceRichIterable<E>
- Overrides:
toArray
in classAbstractRichIterable<E>
- See Also:
Collection.toArray()
-
add
public boolean add(E object)
- Specified by:
add
in interfacejava.util.Collection<E>
- Specified by:
add
in interfacejava.util.List<E>
- Overrides:
add
in classAbstractMutableCollection<E>
-
remove
public boolean remove(java.lang.Object object)
- Specified by:
remove
in interfacejava.util.Collection<E>
- Specified by:
remove
in interfacejava.util.List<E>
- Overrides:
remove
in classAbstractMutableCollection<E>
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
- Specified by:
addAll
in interfacejava.util.Collection<E>
- Specified by:
addAll
in interfacejava.util.List<E>
- Overrides:
addAll
in classAbstractMutableCollection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Description copied from interface:RichIterable
Returns true if all elements in source are contained in this collection.- Specified by:
containsAll
in interfacejava.util.Collection<E>
- Specified by:
containsAll
in interfacejava.util.List<E>
- Specified by:
containsAll
in interfaceRichIterable<E>
- Overrides:
containsAll
in classAbstractMutableList<E>
- See Also:
Collection.containsAll(Collection)
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] array)
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 interfacejava.util.Collection<E>
- Specified by:
toArray
in interfacejava.util.List<E>
- Specified by:
toArray
in interfaceRichIterable<E>
- Overrides:
toArray
in classAbstractRichIterable<E>
- See Also:
Collection.toArray(Object[])
-
addComposited
public void addComposited(java.util.Collection<? extends E> collection)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> collection)
- Specified by:
addAll
in interfacejava.util.List<E>
-
clear
public void clear()
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAll
in interfacejava.util.Collection<E>
- Specified by:
retainAll
in interfacejava.util.List<E>
- Overrides:
retainAll
in classAbstractMutableList<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAll
in interfacejava.util.Collection<E>
- Specified by:
removeAll
in interfacejava.util.List<E>
- Overrides:
removeAll
in classAbstractMutableList<E>
-
get
public E get(int index)
Description copied from interface:ListIterable
Returns the item at the specified position in this list iterable.- Specified by:
get
in interfacejava.util.List<E>
- Specified by:
get
in interfaceListIterable<E>
-
rangeCheck
private void rangeCheck(int index)
-
indexOf
public int indexOf(java.lang.Object o)
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 interfacejava.util.List<E>
- Specified by:
indexOf
in interfaceOrderedIterable<E>
- Overrides:
indexOf
in classAbstractMutableList<E>
- See Also:
List.indexOf(Object)
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
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 interfacejava.util.List<E>
- Specified by:
lastIndexOf
in interfaceListIterable<E>
- Overrides:
lastIndexOf
in classAbstractMutableList<E>
-
replaceAll
public void replaceAll(java.util.function.UnaryOperator<E> operator)
- Specified by:
replaceAll
in interfacejava.util.List<E>
- Since:
- 10.0
-
sort
public void sort(java.util.Comparator<? super E> comparator)
- Specified by:
sort
in interfacejava.util.List<E>
-
listIterator
public java.util.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). 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 interfacejava.util.List<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
public java.util.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). 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 interfacejava.util.List<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
public int count(Predicate<? super E> predicate)
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
public <P> int countWith(Predicate2<? super E,? super P> predicate, P parameter)
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
public boolean anySatisfy(Predicate<? super E> predicate)
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
public <R extends java.util.Collection<E>> R select(Predicate<? super E> predicate, R target)
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 java.util.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
public <R extends java.util.Collection<E>> R reject(Predicate<? super E> predicate, R target)
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 java.util.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 java.util.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 java.util.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
public <P> boolean anySatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
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
public boolean allSatisfy(Predicate<? super E> predicate)
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
public <P> boolean allSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
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
public boolean noneSatisfy(Predicate<? super E> predicate)
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
public <P> boolean noneSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
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>
-
flattenLists
private void flattenLists()
convert multiple contained lists into one list and replace the contained lists with that list. Synchronize to prevent changes to this list whilst this process is happening
-
asParallel
public ParallelListIterable<E> asParallel(java.util.concurrent.ExecutorService executorService, int batchSize)
Description copied from interface:ListIterable
Returns a parallel iterable of this ListIterable.- Specified by:
asParallel
in interfaceListIterable<E>
- Overrides:
asParallel
in classAbstractMutableList<E>
-
-