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 classCompositeFastList.CompositeIteratorprivate static classCompositeFastList.ProcedureToInnerListObjectIntProcedure<E>private static classCompositeFastList.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>>listsprivate static Predicate2<FastList<?>,java.lang.Object>REMOVE_PREDICATEprivate static Procedure<FastList<?>>REVERSE_LIST_PROCEDUREprivate static longserialVersionUIDprivate intsize
-
Constructor Summary
Constructors Constructor Description CompositeFastList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E element)booleanadd(E object)booleanaddAll(int index, java.util.Collection<? extends E> collection)booleanaddAll(java.util.Collection<? extends E> collection)voidaddComposited(java.util.Collection<? extends E> collection)booleanallSatisfy(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> booleanallSatisfyWith(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.booleananySatisfy(Predicate<? super E> predicate)Returns true if the predicate evaluates to true for any element of the iterable.<P> booleananySatisfyWith(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.voidbatchForEach(Procedure<? super E> procedure, int sectionIndex, int sectionCount)voidclear()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 specifiedtargetcollection.<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.booleancontains(java.lang.Object object)Returns true if the iterable has an element which responds true to element.equals(object).booleancontainsAll(java.util.Collection<?> collection)Returns true if all elements in source are contained in this collection.intcount(Predicate<? super E> predicate)Return the total number of elements that answer true to the specified predicate.<P> intcountWith(Predicate2<? super E,? super P> predicate, P parameter)Returns the total number of elements that evaluate to true for the specified predicate.voideach(Procedure<? super E> procedure)The procedure is executed for each element in the iterable.private voidflattenLists()convert multiple contained lists into one list and replace the contained lists with that list.<P> voidforEachWith(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.voidforEachWithIndex(ObjectIntProcedure<? super E> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Eget(int index)Returns the item at the specified position in this list iterable.intgetBatchCount(int batchSize)intindexOf(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.doubleinjectInto(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.floatinjectInto(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.intinjectInto(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.longinjectInto(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> IVinjectInto(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.booleanisEmpty()Returns true if this iterable has zero items.java.util.Iterator<E>iterator()intlastIndexOf(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).booleannoneSatisfy(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> booleannoneSatisfyWith(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 voidrangeCheck(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.Eremove(int index)booleanremove(java.lang.Object object)booleanremoveAll(java.util.Collection<?> collection)voidreplaceAll(java.util.function.UnaryOperator<E> operator)voidresetSize()booleanretainAll(java.util.Collection<?> collection)voidreverseForEach(Procedure<? super E> procedure)Evaluates the procedure for each element of the list iterating in reverse order.voidreverseForEachWithIndex(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.Eset(int index, E element)intsize()Returns the number of items in this iterable.voidsort(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, removeRange, selectAndRejectWith, selectInstancesOf, sortThisByBoolean, sortThisByByte, sortThisByChar, sortThisByDouble, sortThisByFloat, sortThisByInt, sortThisByLong, sortThisByShort, subList, subListRangeCheck, 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, reduceBy, reduceBy, 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:
clonein interfaceMutableList<E>- Overrides:
clonein classAbstractMutableList<E>
-
size
public int size()
Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceBatchIterable<E>- Specified by:
sizein interfacejava.util.Collection<E>- Specified by:
sizein interfacejava.util.List<E>- Specified by:
sizein interfaceRichIterable<E>
-
resetSize
public void resetSize()
-
batchForEach
public void batchForEach(Procedure<? super E> procedure, int sectionIndex, int sectionCount)
- Specified by:
batchForEachin interfaceBatchIterable<E>
-
getBatchCount
public int getBatchCount(int batchSize)
- Specified by:
getBatchCountin interfaceBatchIterable<E>
-
reverseThis
public CompositeFastList<E> reverseThis()
Description copied from interface:MutableListMutates this list by reversing its order and returns the current list as a result.- Specified by:
reverseThisin interfaceMutableList<E>
-
each
public void each(Procedure<? super E> procedure)
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(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:
eachin interfaceRichIterable<E>- Overrides:
eachin 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:RichIterableReturns 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:
injectIntoin interfaceRichIterable<E>- Overrides:
injectIntoin classAbstractMutableList<E>
-
injectInto
public int injectInto(int injectedValue, IntObjectToIntFunction<? super E> function)Description copied from interface:RichIterableReturns 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:
injectIntoin interfaceRichIterable<E>- Overrides:
injectIntoin classAbstractMutableList<E>
-
injectInto
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super E> function)Description copied from interface:RichIterableReturns 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:
injectIntoin interfaceRichIterable<E>- Overrides:
injectIntoin classAbstractMutableList<E>
-
injectInto
public long injectInto(long injectedValue, LongObjectToLongFunction<? super E> function)Description copied from interface:RichIterableReturns 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:
injectIntoin interfaceRichIterable<E>- Overrides:
injectIntoin classAbstractMutableList<E>
-
injectInto
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super E> function)Description copied from interface:RichIterableReturns 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:
injectIntoin interfaceRichIterable<E>- Overrides:
injectIntoin classAbstractRichIterable<E>
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super E> objectIntProcedure)
Description copied from interface:InternalIterableIterates 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:
forEachWithIndexin interfaceInternalIterable<E>- Specified by:
forEachWithIndexin interfaceOrderedIterable<E>- Overrides:
forEachWithIndexin classAbstractMutableList<E>
-
reverseForEach
public void reverseForEach(Procedure<? super E> procedure)
Description copied from interface:ReversibleIterableEvaluates the procedure for each element of the list iterating in reverse order.e.g. people.reverseForEach(person -> LOGGER.info(person.getName()));
- Specified by:
reverseForEachin interfaceReversibleIterable<E>
-
reverseForEachWithIndex
public void reverseForEachWithIndex(ObjectIntProcedure<? super E> procedure)
Description copied from interface:ReversibleIterableEvaluates 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:
reverseForEachWithIndexin interfaceReversibleIterable<E>
-
forEachWith
public <P> void forEachWith(Procedure2<? super E,? super P> procedure2, P parameter)
Description copied from interface:InternalIterableThe 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:
forEachWithin interfaceInternalIterable<E>- Overrides:
forEachWithin classAbstractMutableList<E>
-
isEmpty
public boolean isEmpty()
Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfacejava.util.Collection<E>- Specified by:
isEmptyin interfacejava.util.List<E>- Specified by:
isEmptyin interfaceRichIterable<E>- Overrides:
isEmptyin classAbstractRichIterable<E>
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfacejava.util.Collection<E>- Specified by:
containsin interfacejava.util.List<E>- Specified by:
containsin interfaceRichIterable<E>- Overrides:
containsin classAbstractMutableList<E>
-
iterator
public java.util.Iterator<E> iterator()
-
toArray
public java.lang.Object[] toArray()
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfacejava.util.Collection<E>- Specified by:
toArrayin interfacejava.util.List<E>- Specified by:
toArrayin interfaceMutableCollection<E>- Specified by:
toArrayin interfaceMutableList<E>- Specified by:
toArrayin interfaceRichIterable<E>- See Also:
Collection.toArray()
-
add
public boolean add(E object)
- Specified by:
addin interfacejava.util.Collection<E>- Specified by:
addin interfacejava.util.List<E>- Overrides:
addin classAbstractMutableCollection<E>
-
remove
public boolean remove(java.lang.Object object)
- Specified by:
removein interfacejava.util.Collection<E>- Specified by:
removein interfacejava.util.List<E>- Overrides:
removein classAbstractMutableCollection<E>
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
- Specified by:
addAllin interfacejava.util.Collection<E>- Specified by:
addAllin interfacejava.util.List<E>- Overrides:
addAllin classAbstractMutableCollection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllin interfacejava.util.Collection<E>- Specified by:
containsAllin interfacejava.util.List<E>- Specified by:
containsAllin interfaceRichIterable<E>- Overrides:
containsAllin classAbstractMutableList<E>- See Also:
Collection.containsAll(Collection)
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] array)
Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfacejava.util.Collection<E>- Specified by:
toArrayin interfacejava.util.List<E>- Specified by:
toArrayin interfaceMutableCollection<E>- Specified by:
toArrayin interfaceMutableList<E>- Specified by:
toArrayin interfaceRichIterable<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:
addAllin interfacejava.util.List<E>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<E>- Specified by:
clearin interfacejava.util.List<E>- Overrides:
clearin classAbstractMutableList<E>
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
- Specified by:
retainAllin interfacejava.util.Collection<E>- Specified by:
retainAllin interfacejava.util.List<E>- Overrides:
retainAllin classAbstractMutableList<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
- Specified by:
removeAllin interfacejava.util.Collection<E>- Specified by:
removeAllin interfacejava.util.List<E>- Overrides:
removeAllin classAbstractMutableList<E>
-
get
public E get(int index)
Description copied from interface:ListIterableReturns the item at the specified position in this list iterable.- Specified by:
getin interfacejava.util.List<E>- Specified by:
getin interfaceListIterable<E>
-
rangeCheck
private void rangeCheck(int index)
-
indexOf
public int indexOf(java.lang.Object o)
Description copied from interface:OrderedIterableReturns 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:
indexOfin interfacejava.util.List<E>- Specified by:
indexOfin interfaceMutableList<E>- Specified by:
indexOfin interfaceOrderedIterable<E>- Overrides:
indexOfin classAbstractMutableList<E>- See Also:
List.indexOf(Object)
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
Description copied from interface:ListIterableReturns 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:
lastIndexOfin interfacejava.util.List<E>- Specified by:
lastIndexOfin interfaceListIterable<E>- Overrides:
lastIndexOfin classAbstractMutableList<E>
-
replaceAll
public void replaceAll(java.util.function.UnaryOperator<E> operator)
- Specified by:
replaceAllin interfacejava.util.List<E>- Since:
- 10.0
-
sort
public void sort(java.util.Comparator<? super E> comparator)
- Specified by:
sortin 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:
listIteratorin interfacejava.util.List<E>- Specified by:
listIteratorin interfaceListIterable<E>- Overrides:
listIteratorin 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:
listIteratorin interfacejava.util.List<E>- Specified by:
listIteratorin interfaceListIterable<E>- Overrides:
listIteratorin 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:RichIterableReturn 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"));- Specified by:
countin interfaceRichIterable<E>- Overrides:
countin classAbstractMutableList<E>
-
countWith
public <P> int countWith(Predicate2<? super E,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns the total number of elements that evaluate to true for the specified predicate.e.g. return lastNames.countWith(Predicates2.equal(), "Smith");
- Specified by:
countWithin interfaceRichIterable<E>- Overrides:
countWithin classAbstractMutableList<E>
-
anySatisfy
public boolean anySatisfy(Predicate<? super E> predicate)
Description copied from interface:RichIterableReturns 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:
anySatisfyin interfaceRichIterable<E>- Overrides:
anySatisfyin classAbstractMutableList<E>
-
select
public <R extends java.util.Collection<E>> R select(Predicate<? super E> predicate, R target)
Description copied from interface:RichIterableSame 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());- Specified by:
selectin interfaceRichIterable<E>- Overrides:
selectin classAbstractMutableList<E>- Parameters:
predicate- aPredicateto use as the select criteriatarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableSimilar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof 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());- Specified by:
selectWithin interfaceRichIterable<E>- Overrides:
selectWithin classAbstractMutableList<E>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableSame 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());- Specified by:
rejectin interfaceRichIterable<E>- Overrides:
rejectin classAbstractMutableList<E>- Parameters:
predicate- aPredicateto use as the reject criteriatarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableSimilar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof 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());- Specified by:
rejectWithin interfaceRichIterable<E>- Overrides:
rejectWithin classAbstractMutableList<E>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());- Specified by:
collectin interfaceRichIterable<E>- Overrides:
collectin classAbstractMutableList<E>- Parameters:
function- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableSame 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());- Specified by:
collectWithin interfaceRichIterable<E>- Overrides:
collectWithin classAbstractMutableList<E>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontarget- the Collection to append to for all elements in thisRichIterablethat 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:RichIterableReturns 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:
anySatisfyWithin interfaceRichIterable<E>- Overrides:
anySatisfyWithin classAbstractMutableList<E>
-
allSatisfy
public boolean allSatisfy(Predicate<? super E> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<E>- Overrides:
allSatisfyin classAbstractMutableList<E>
-
allSatisfyWith
public <P> boolean allSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWithin interfaceRichIterable<E>- Overrides:
allSatisfyWithin classAbstractMutableList<E>
-
noneSatisfy
public boolean noneSatisfy(Predicate<? super E> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<E>- Overrides:
noneSatisfyin classAbstractMutableList<E>
-
noneSatisfyWith
public <P> boolean noneSatisfyWith(Predicate2<? super E,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns 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:
noneSatisfyWithin interfaceRichIterable<E>- Overrides:
noneSatisfyWithin 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:ListIterableReturns a parallel iterable of this ListIterable.- Specified by:
asParallelin interfaceListIterable<E>- Overrides:
asParallelin classAbstractMutableList<E>
-
-