Class ArrayListIterate
java.lang.Object
org.eclipse.collections.impl.utility.ArrayListIterate
This utility class provides optimized iteration pattern implementations that work with java.util.ArrayList.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,K, V> MutableMap<K, V> aggregateBy(ArrayList<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) static <T,K, V> MutableMap<K, V> aggregateInPlaceBy(ArrayList<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) static <T> booleanallSatisfy(ArrayList<T> list, Predicate<? super T> predicate) static <T,IV> boolean allSatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T> booleananySatisfy(ArrayList<T> list, Predicate<? super T> predicate) static <T,P> boolean anySatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T,A> ArrayList<A> static <T,A, R extends Collection<A>>
Rstatic <T> MutableBooleanListcollectBoolean(ArrayList<T> list, BooleanFunction<? super T> booleanFunction) static <T,R extends MutableBooleanCollection>
RcollectBoolean(ArrayList<T> list, BooleanFunction<? super T> booleanFunction, R target) static <T> MutableByteListcollectByte(ArrayList<T> list, ByteFunction<? super T> byteFunction) static <T,R extends MutableByteCollection>
RcollectByte(ArrayList<T> list, ByteFunction<? super T> byteFunction, R target) static <T> MutableCharListcollectChar(ArrayList<T> list, CharFunction<? super T> charFunction) static <T,R extends MutableCharCollection>
RcollectChar(ArrayList<T> list, CharFunction<? super T> charFunction, R target) static <T> MutableDoubleListcollectDouble(ArrayList<T> list, DoubleFunction<? super T> doubleFunction) static <T,R extends MutableDoubleCollection>
RcollectDouble(ArrayList<T> list, DoubleFunction<? super T> doubleFunction, R target) static <T> MutableFloatListcollectFloat(ArrayList<T> list, FloatFunction<? super T> floatFunction) static <T,R extends MutableFloatCollection>
RcollectFloat(ArrayList<T> list, FloatFunction<? super T> floatFunction, R target) static <T,A> ArrayList<A> collectIf(ArrayList<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function) static <T,A, R extends Collection<A>>
RcollectIf(ArrayList<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function, R targetCollection) static <T> MutableIntListcollectInt(ArrayList<T> list, IntFunction<? super T> intFunction) static <T,R extends MutableIntCollection>
RcollectInt(ArrayList<T> list, IntFunction<? super T> intFunction, R target) static <T> MutableLongListcollectLong(ArrayList<T> list, LongFunction<? super T> longFunction) static <T,R extends MutableLongCollection>
RcollectLong(ArrayList<T> list, LongFunction<? super T> longFunction, R target) static <T> MutableShortListcollectShort(ArrayList<T> list, ShortFunction<? super T> shortFunction) static <T,R extends MutableShortCollection>
RcollectShort(ArrayList<T> list, ShortFunction<? super T> shortFunction, R target) static <T,P, A> ArrayList<A> collectWith(ArrayList<T> list, Function2<? super T, ? super P, ? extends A> function, P parameter) static <T,P, A, R extends Collection<A>>
RcollectWith(ArrayList<T> list, Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) static <T> intstatic <T,P> int countWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> Tstatic <T> TdetectIfNone(ArrayList<T> list, Predicate<? super T> predicate, T ifNone) static <T> intdetectIndex(ArrayList<T> list, Predicate<? super T> predicate) static <T,P> int detectIndexWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> intdetectLastIndex(ArrayList<T> list, Predicate<? super T> predicate) static <T> Optional<T>detectOptional(ArrayList<T> list, Predicate<? super T> predicate) static <T,P> T detectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T,IV> T detectWithIfNone(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue, T ifNone) static <T,P> Optional<T> detectWithOptional(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> ArrayList<T>static <T> ArrayList<T>distinct(ArrayList<T> list, HashingStrategy<? super T> hashingStrategy) static <T,R extends List<T>>
RDeprecated.in 7.0.static <T,V> ArrayList<T> distinctBy(ArrayList<T> list, Function<? super T, ? extends V> function) static <T> ArrayList<T>static <T,R extends Collection<T>>
Rstatic <T> MutableList<T>static <T,A> ArrayList<A> flatCollect(ArrayList<T> list, Function<? super T, ? extends Iterable<A>> function) static <T,A, R extends Collection<A>>
RflatCollect(ArrayList<T> list, Function<? super T, ? extends Iterable<A>> function, R targetCollection) static <T> voidIterates over the section of the list covered by the specified indexes.static <T> voidstatic <T1,T2> void forEachInBoth(ArrayList<T1> list1, ArrayList<T2> list2, Procedure2<? super T1, ? super T2> procedure) static <T,P> void forEachWith(ArrayList<T> list, Procedure2<? super T, ? super P> procedure, P parameter) static <T> voidforEachWithIndex(ArrayList<T> list, int from, int to, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the section of the list covered by the specified indexes.static <T> voidforEachWithIndex(ArrayList<T> list, ObjectIntProcedure<? super T> objectIntProcedure) static <T,V> FastListMultimap<V, T> static <T,V, R extends MutableMultimap<V, T>>
Rstatic <T,V> FastListMultimap<V, T> groupByEach(ArrayList<T> list, Function<? super T, ? extends Iterable<V>> function) static <T,V, R extends MutableMultimap<V, T>>
RgroupByEach(ArrayList<T> list, Function<? super T, ? extends Iterable<V>> function, R target) static <T,V> MutableMap<V, T> groupByUniqueKey(ArrayList<T> list, Function<? super T, ? extends V> function) static <T,V, R extends MutableMapIterable<V, T>>
RgroupByUniqueKey(ArrayList<T> list, Function<? super T, ? extends V> function, R target) static <T> doubleinjectInto(double injectValue, ArrayList<T> list, DoubleObjectToDoubleFunction<? super T> function) static <T> floatinjectInto(float injectValue, ArrayList<T> list, FloatObjectToFloatFunction<? super T> function) static <T> intinjectInto(int injectValue, ArrayList<T> list, IntObjectToIntFunction<? super T> function) static <T> longinjectInto(long injectValue, ArrayList<T> list, LongObjectToLongFunction<? super T> function) static <T,IV> IV injectInto(IV injectValue, ArrayList<T> list, Function2<? super IV, ? super T, ? extends IV> function) static <T,IV, P> IV injectIntoWith(IV injectedValue, ArrayList<T> list, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter) static <T> booleannoneSatisfy(ArrayList<T> list, Predicate<? super T> predicate) static <T,IV> boolean noneSatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T> PartitionMutableList<T>static <T> PartitionMutableList<T>partitionWhile(ArrayList<T> list, Predicate<? super T> predicate) static <T,P> PartitionMutableList<T> partitionWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> ArrayList<T>static <T,R extends Collection<T>>
Rstatic <T,IV> ArrayList<T> rejectWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T,P, R extends Collection<T>>
RrejectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P injectedValue, R targetCollection) static <T> booleanstatic <T,P> boolean removeIfWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> voidreverseForEach(ArrayList<T> list, Procedure<? super T> procedure) Reverses over the List in reverse order executing the Procedure for each element.static <T> voidreverseForEachWithIndex(ArrayList<T> list, ObjectIntProcedure<? super T> procedure) Reverses over the List in reverse order executing the Procedure with index for each element.static <T> ArrayList<T>static <T,R extends Collection<T>>
Rstatic <T,P> Twin<MutableList<T>> selectAndRejectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> MutableList<T>selectInstancesOf(ArrayList<?> list, Class<T> clazz) static <T,IV> ArrayList<T> selectWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T,P, R extends Collection<T>>
RselectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) static <T extends Comparable<? super T>>
ArrayList<T>Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.static <T> ArrayList<T>sortThis(ArrayList<T> list, Comparator<? super T> comparator) Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.static <T> ArrayList<T>static <T,R extends Collection<T>>
Rstatic <T> MutableList<T>static <T> voidstatic <X,Y> MutableList<Pair<X, Y>> static <X,Y, R extends Collection<Pair<X, Y>>>
Rstatic <T> MutableList<Pair<T,Integer>> zipWithIndex(ArrayList<T> list) static <T,R extends Collection<Pair<T, Integer>>>
RzipWithIndex(ArrayList<T> list, R targetCollection)
-
Method Details
-
select
- See Also:
-
selectWith
public static <T,IV> ArrayList<T> selectWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
select
public static <T,R extends Collection<T>> R select(ArrayList<T> list, Predicate<? super T> predicate, R targetCollection) -
selectWith
public static <T,P, R selectWithR extends Collection<T>> (ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) -
selectInstancesOf
-
count
- See Also:
-
countWith
public static <T,P> int countWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
collectIf
-
collectIf
public static <T,A, R collectIfR extends Collection<A>> (ArrayList<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function, R targetCollection) -
reject
- See Also:
-
rejectWith
public static <T,IV> ArrayList<T> rejectWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
reject
public static <T,R extends Collection<T>> R reject(ArrayList<T> list, Predicate<? super T> predicate, R targetCollection) -
rejectWith
public static <T,P, R rejectWithR extends Collection<T>> (ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P injectedValue, R targetCollection) -
collect
public static <T,A> ArrayList<A> collect(ArrayList<T> list, Function<? super T, ? extends A> function) - See Also:
-
collectBoolean
public static <T> MutableBooleanList collectBoolean(ArrayList<T> list, BooleanFunction<? super T> booleanFunction) -
collectBoolean
public static <T,R extends MutableBooleanCollection> R collectBoolean(ArrayList<T> list, BooleanFunction<? super T> booleanFunction, R target) -
collectByte
public static <T> MutableByteList collectByte(ArrayList<T> list, ByteFunction<? super T> byteFunction) -
collectByte
public static <T,R extends MutableByteCollection> R collectByte(ArrayList<T> list, ByteFunction<? super T> byteFunction, R target) -
collectChar
public static <T> MutableCharList collectChar(ArrayList<T> list, CharFunction<? super T> charFunction) -
collectChar
public static <T,R extends MutableCharCollection> R collectChar(ArrayList<T> list, CharFunction<? super T> charFunction, R target) -
collectDouble
public static <T> MutableDoubleList collectDouble(ArrayList<T> list, DoubleFunction<? super T> doubleFunction) -
collectDouble
public static <T,R extends MutableDoubleCollection> R collectDouble(ArrayList<T> list, DoubleFunction<? super T> doubleFunction, R target) -
collectFloat
public static <T> MutableFloatList collectFloat(ArrayList<T> list, FloatFunction<? super T> floatFunction) -
collectFloat
public static <T,R extends MutableFloatCollection> R collectFloat(ArrayList<T> list, FloatFunction<? super T> floatFunction, R target) -
collectInt
-
collectInt
public static <T,R extends MutableIntCollection> R collectInt(ArrayList<T> list, IntFunction<? super T> intFunction, R target) -
collectLong
public static <T> MutableLongList collectLong(ArrayList<T> list, LongFunction<? super T> longFunction) -
collectLong
public static <T,R extends MutableLongCollection> R collectLong(ArrayList<T> list, LongFunction<? super T> longFunction, R target) -
collectShort
public static <T> MutableShortList collectShort(ArrayList<T> list, ShortFunction<? super T> shortFunction) -
collectShort
public static <T,R extends MutableShortCollection> R collectShort(ArrayList<T> list, ShortFunction<? super T> shortFunction, R target) -
collect
public static <T,A, R collectR extends Collection<A>> (ArrayList<T> list, Function<? super T, ? extends A> function, R targetCollection) -
flatCollect
public static <T,A> ArrayList<A> flatCollect(ArrayList<T> list, Function<? super T, ? extends Iterable<A>> function) - See Also:
-
flatCollect
public static <T,A, R flatCollectR extends Collection<A>> (ArrayList<T> list, Function<? super T, ? extends Iterable<A>> function, R targetCollection) -
forEach
- See Also:
-
reverseForEach
Reverses over the List in reverse order executing the Procedure for each element. -
reverseForEachWithIndex
public static <T> void reverseForEachWithIndex(ArrayList<T> list, ObjectIntProcedure<? super T> procedure) Reverses over the List in reverse order executing the Procedure with index for each element. -
forEach
Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the list is iterated in the reverse order.e.g. ArrayList<People> people = new ArrayList<People>(FastList.newListWith(ted, mary, bob, sally)); ArrayListIterate.forEach(people, 0, 1, new Procedure<Person>() { public void value(Person person) { LOGGER.info(person.getName()); } });This code would output ted and mary's names.
-
forEachWithIndex
public static <T> void forEachWithIndex(ArrayList<T> list, int from, int to, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the list is iterated in the reverse order. The index passed into the ObjectIntProcedure is the actual index of the range.e.g. ArrayList<People> people = new ArrayList<People>(FastList.newListWith(ted, mary, bob, sally)); ArrayListIterate.forEachWithIndex(people, 0, 1, new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info(person.getName() + " at index: " + index); } });This code would output ted and mary's names.
-
forEachInBoth
public static <T1,T2> void forEachInBoth(ArrayList<T1> list1, ArrayList<T2> list2, Procedure2<? super T1, ? super T2> procedure) -
forEachWithIndex
public static <T> void forEachWithIndex(ArrayList<T> list, ObjectIntProcedure<? super T> objectIntProcedure) -
detect
- See Also:
-
detectWith
public static <T,P> T detectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detectOptional
-
detectWithOptional
public static <T,P> Optional<T> detectWithOptional(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detectIfNone
-
detectWithIfNone
public static <T,IV> T detectWithIfNone(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue, T ifNone) -
injectInto
-
injectInto
public static <T> int injectInto(int injectValue, ArrayList<T> list, IntObjectToIntFunction<? super T> function) -
injectInto
public static <T> long injectInto(long injectValue, ArrayList<T> list, LongObjectToLongFunction<? super T> function) -
injectInto
public static <T> double injectInto(double injectValue, ArrayList<T> list, DoubleObjectToDoubleFunction<? super T> function) -
injectInto
public static <T> float injectInto(float injectValue, ArrayList<T> list, FloatObjectToFloatFunction<? super T> function) -
anySatisfy
- See Also:
-
anySatisfyWith
public static <T,P> boolean anySatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
allSatisfy
- See Also:
-
allSatisfyWith
public static <T,IV> boolean allSatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
noneSatisfy
- See Also:
-
noneSatisfyWith
public static <T,IV> boolean noneSatisfyWith(ArrayList<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
selectAndRejectWith
public static <T,P> Twin<MutableList<T>> selectAndRejectWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
partition
public static <T> PartitionMutableList<T> partition(ArrayList<T> list, Predicate<? super T> predicate) - See Also:
-
partitionWith
public static <T,P> PartitionMutableList<T> partitionWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detectIndex
- See Also:
-
detectIndexWith
public static <T,P> int detectIndexWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detectLastIndex
-
injectIntoWith
-
forEachWith
public static <T,P> void forEachWith(ArrayList<T> list, Procedure2<? super T, ? super P> procedure, P parameter) -
collectWith
-
collectWith
public static <T,P, R collectWithA, R extends Collection<A>> (ArrayList<T> list, Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) -
removeIf
- See Also:
-
removeIfWith
public static <T,P> boolean removeIfWith(ArrayList<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
distinct
-
distinct
Deprecated.in 7.0. -
distinct
public static <T> ArrayList<T> distinct(ArrayList<T> list, HashingStrategy<? super T> hashingStrategy) - Since:
- 7.0.
-
distinctBy
public static <T,V> ArrayList<T> distinctBy(ArrayList<T> list, Function<? super T, ? extends V> function) - Since:
- 9.0.
-
sortThis
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. -
sortThis
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. -
toArray
-
take
- See Also:
-
take
- See Also:
-
drop
- See Also:
-
drop
- See Also:
-
groupBy
public static <T,V> FastListMultimap<V,T> groupBy(ArrayList<T> list, Function<? super T, ? extends V> function) - See Also:
-
groupBy
public static <T,V, R groupByR extends MutableMultimap<V, T>> (ArrayList<T> list, Function<? super T, ? extends V> function, R target) -
groupByEach
public static <T,V> FastListMultimap<V,T> groupByEach(ArrayList<T> list, Function<? super T, ? extends Iterable<V>> function) - See Also:
-
groupByEach
public static <T,V, R groupByEachR extends MutableMultimap<V, T>> (ArrayList<T> list, Function<? super T, ? extends Iterable<V>> function, R target) -
groupByUniqueKey
public static <T,V> MutableMap<V,T> groupByUniqueKey(ArrayList<T> list, Function<? super T, ? extends V> function) -
groupByUniqueKey
public static <T,V, R groupByUniqueKeyR extends MutableMapIterable<V, T>> (ArrayList<T> list, Function<? super T, ? extends V> function, R target) -
zip
- See Also:
-
zip
public static <X,Y, R zipR extends Collection<Pair<X, Y>>> (ArrayList<X> xs, Iterable<Y> ys, R targetCollection) -
zipWithIndex
- See Also:
-
zipWithIndex
public static <T,R extends Collection<Pair<T, R zipWithIndexInteger>>> (ArrayList<T> list, R targetCollection) -
takeWhile
-
dropWhile
-
partitionWhile
public static <T> PartitionMutableList<T> partitionWhile(ArrayList<T> list, Predicate<? super T> predicate) -
aggregateInPlaceBy
public static <T,K, MutableMap<K,V> V> aggregateInPlaceBy(ArrayList<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) -
aggregateBy
public static <T,K, MutableMap<K,V> V> aggregateBy(ArrayList<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator)
-