Class ArrayListIterate
- java.lang.Object
-
- org.eclipse.collections.impl.utility.ArrayListIterate
-
public final class ArrayListIterate extends java.lang.Object
This utility class provides optimized iteration pattern implementations that work with java.util.ArrayList.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Field
ELEMENT_DATA_FIELD
private static int
MIN_DIRECT_ARRAY_ACCESS_SIZE
private static java.lang.reflect.Field
SIZE_FIELD
-
Constructor Summary
Constructors Modifier Constructor Description private
ArrayListIterate()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T,K,V>
MutableMap<K,V>aggregateBy(java.util.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(java.util.ArrayList<T> list, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)
static <T> boolean
allSatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,IV>
booleanallSatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
static <T> boolean
anySatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
booleananySatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
private static boolean
canAccessInternalArray(java.util.ArrayList<?> list)
static <T,A>
java.util.ArrayList<A>collect(java.util.ArrayList<T> list, Function<? super T,? extends A> function)
static <T,A,R extends java.util.Collection<A>>
Rcollect(java.util.ArrayList<T> list, Function<? super T,? extends A> function, R targetCollection)
static <T> MutableBooleanList
collectBoolean(java.util.ArrayList<T> list, BooleanFunction<? super T> booleanFunction)
static <T,R extends MutableBooleanCollection>
RcollectBoolean(java.util.ArrayList<T> list, BooleanFunction<? super T> booleanFunction, R target)
private static <T,R extends MutableBooleanCollection>
RcollectBooleanFromInternalArray(java.util.ArrayList<T> source, BooleanFunction<? super T> booleanFunction, int elementsToCollect, R target)
static <T> MutableByteList
collectByte(java.util.ArrayList<T> list, ByteFunction<? super T> byteFunction)
static <T,R extends MutableByteCollection>
RcollectByte(java.util.ArrayList<T> list, ByteFunction<? super T> byteFunction, R target)
private static <T,R extends MutableByteCollection>
RcollectByteFromInternalArray(java.util.ArrayList<T> source, ByteFunction<? super T> byteFunction, int elementsToCollect, R target)
static <T> MutableCharList
collectChar(java.util.ArrayList<T> list, CharFunction<? super T> charFunction)
static <T,R extends MutableCharCollection>
RcollectChar(java.util.ArrayList<T> list, CharFunction<? super T> charFunction, R target)
private static <T,R extends MutableCharCollection>
RcollectCharFromInternalArray(java.util.ArrayList<T> source, CharFunction<? super T> charFunction, int elementsToCollect, R target)
static <T> MutableDoubleList
collectDouble(java.util.ArrayList<T> list, DoubleFunction<? super T> doubleFunction)
static <T,R extends MutableDoubleCollection>
RcollectDouble(java.util.ArrayList<T> list, DoubleFunction<? super T> doubleFunction, R target)
private static <T,R extends MutableDoubleCollection>
RcollectDoubleFromInternalArray(java.util.ArrayList<T> source, DoubleFunction<? super T> doubleFunction, int elementsToCollect, R target)
static <T> MutableFloatList
collectFloat(java.util.ArrayList<T> list, FloatFunction<? super T> floatFunction)
static <T,R extends MutableFloatCollection>
RcollectFloat(java.util.ArrayList<T> list, FloatFunction<? super T> floatFunction, R target)
private static <T,R extends MutableFloatCollection>
RcollectFloatFromInternalArray(java.util.ArrayList<T> source, FloatFunction<? super T> floatFunction, int elementsToCollect, R target)
static <T,A>
java.util.ArrayList<A>collectIf(java.util.ArrayList<T> list, Predicate<? super T> predicate, Function<? super T,? extends A> function)
static <T,A,R extends java.util.Collection<A>>
RcollectIf(java.util.ArrayList<T> list, Predicate<? super T> predicate, Function<? super T,? extends A> function, R targetCollection)
static <T> MutableIntList
collectInt(java.util.ArrayList<T> list, IntFunction<? super T> intFunction)
static <T,R extends MutableIntCollection>
RcollectInt(java.util.ArrayList<T> list, IntFunction<? super T> intFunction, R target)
private static <T,R extends MutableIntCollection>
RcollectIntFromInternalArray(java.util.ArrayList<T> source, IntFunction<? super T> intFunction, int elementsToCollect, R target)
static <T> MutableLongList
collectLong(java.util.ArrayList<T> list, LongFunction<? super T> longFunction)
static <T,R extends MutableLongCollection>
RcollectLong(java.util.ArrayList<T> list, LongFunction<? super T> longFunction, R target)
private static <T,R extends MutableLongCollection>
RcollectLongFromInternalArray(java.util.ArrayList<T> source, LongFunction<? super T> longFunction, int elementsToCollect, R target)
static <T> MutableShortList
collectShort(java.util.ArrayList<T> list, ShortFunction<? super T> shortFunction)
static <T,R extends MutableShortCollection>
RcollectShort(java.util.ArrayList<T> list, ShortFunction<? super T> shortFunction, R target)
private static <T,R extends MutableShortCollection>
RcollectShortFromInternalArray(java.util.ArrayList<T> source, ShortFunction<? super T> shortFunction, int elementsToCollect, R target)
static <T,P,A>
java.util.ArrayList<A>collectWith(java.util.ArrayList<T> list, Function2<? super T,? super P,? extends A> function, P parameter)
static <T,P,A,R extends java.util.Collection<A>>
RcollectWith(java.util.ArrayList<T> list, Function2<? super T,? super P,? extends A> function, P parameter, R targetCollection)
static <T> int
count(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
intcountWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> T
detect(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T> T
detectIfNone(java.util.ArrayList<T> list, Predicate<? super T> predicate, T ifNone)
static <T> int
detectIndex(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
intdetectIndexWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> int
detectLastIndex(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T> java.util.Optional<T>
detectOptional(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
TdetectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T,IV>
TdetectWithIfNone(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue, T ifNone)
static <T,P>
java.util.Optional<T>detectWithOptional(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> java.util.ArrayList<T>
distinct(java.util.ArrayList<T> list)
static <T> java.util.ArrayList<T>
distinct(java.util.ArrayList<T> list, HashingStrategy<? super T> hashingStrategy)
static <T,R extends java.util.List<T>>
Rdistinct(java.util.ArrayList<T> list, R targetList)
Deprecated.in 7.0.static <T,V>
java.util.ArrayList<T>distinctBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
static <T> java.util.ArrayList<T>
drop(java.util.ArrayList<T> list, int count)
static <T,R extends java.util.Collection<T>>
Rdrop(java.util.ArrayList<T> list, int count, R targetList)
static <T> MutableList<T>
dropWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,A>
java.util.ArrayList<A>flatCollect(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<A>> function)
static <T,A,R extends java.util.Collection<A>>
RflatCollect(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<A>> function, R targetCollection)
static <T> void
forEach(java.util.ArrayList<T> list, int from, int to, Procedure<? super T> procedure)
Iterates over the section of the list covered by the specified indexes.static <T> void
forEach(java.util.ArrayList<T> list, Procedure<? super T> procedure)
static <T1,T2>
voidforEachInBoth(java.util.ArrayList<T1> list1, java.util.ArrayList<T2> list2, Procedure2<? super T1,? super T2> procedure)
static <T,P>
voidforEachWith(java.util.ArrayList<T> list, Procedure2<? super T,? super P> procedure, P parameter)
static <T> void
forEachWithIndex(java.util.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> void
forEachWithIndex(java.util.ArrayList<T> list, ObjectIntProcedure<? super T> objectIntProcedure)
private static <T> T[]
getInternalArray(java.util.ArrayList<T> list)
static <T,V>
FastListMultimap<V,T>groupBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
static <T,V,R extends MutableMultimap<V,T>>
RgroupBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function, R target)
static <T,V>
FastListMultimap<V,T>groupByEach(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<V>> function)
static <T,V,R extends MutableMultimap<V,T>>
RgroupByEach(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<V>> function, R target)
static <T,V>
MutableMap<V,T>groupByUniqueKey(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
static <T,V,R extends MutableMapIterable<V,T>>
RgroupByUniqueKey(java.util.ArrayList<T> list, Function<? super T,? extends V> function, R target)
static <T> double
injectInto(double injectValue, java.util.ArrayList<T> list, DoubleObjectToDoubleFunction<? super T> function)
static <T> float
injectInto(float injectValue, java.util.ArrayList<T> list, FloatObjectToFloatFunction<? super T> function)
static <T> int
injectInto(int injectValue, java.util.ArrayList<T> list, IntObjectToIntFunction<? super T> function)
static <T> long
injectInto(long injectValue, java.util.ArrayList<T> list, LongObjectToLongFunction<? super T> function)
static <T,IV>
IVinjectInto(IV injectValue, java.util.ArrayList<T> list, Function2<? super IV,? super T,? extends IV> function)
static <T,IV,P>
IVinjectIntoWith(IV injectedValue, java.util.ArrayList<T> list, Function3<? super IV,? super T,? super P,? extends IV> function, P parameter)
private static boolean
isOptimizableArrayList(java.util.ArrayList<?> list, int newSize)
static <T> boolean
noneSatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,IV>
booleannoneSatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
static <T> PartitionMutableList<T>
partition(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T> PartitionMutableList<T>
partitionWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
PartitionMutableList<T>partitionWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> java.util.ArrayList<T>
reject(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,R extends java.util.Collection<T>>
Rreject(java.util.ArrayList<T> list, Predicate<? super T> predicate, R targetCollection)
static <T,IV>
java.util.ArrayList<T>rejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
static <T,P,R extends java.util.Collection<T>>
RrejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P injectedValue, R targetCollection)
static <T> boolean
removeIf(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,P>
booleanremoveIfWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> void
reverseForEach(java.util.ArrayList<T> list, Procedure<? super T> procedure)
Reverses over the List in reverse order executing the Procedure for each element.static <T> void
reverseForEachWithIndex(java.util.ArrayList<T> list, ObjectIntProcedure<? super T> procedure)
Reverses over the List in reverse order executing the Procedure with index for each element.static <T> java.util.ArrayList<T>
select(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T,R extends java.util.Collection<T>>
Rselect(java.util.ArrayList<T> list, Predicate<? super T> predicate, R targetCollection)
static <T,P>
Twin<MutableList<T>>selectAndRejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
static <T> MutableList<T>
selectInstancesOf(java.util.ArrayList<?> list, java.lang.Class<T> clazz)
static <T,IV>
java.util.ArrayList<T>selectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
static <T,P,R extends java.util.Collection<T>>
RselectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)
static <T extends java.lang.Comparable<? super T>>
java.util.ArrayList<T>sortThis(java.util.ArrayList<T> list)
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.static <T> java.util.ArrayList<T>
sortThis(java.util.ArrayList<T> list, java.util.Comparator<? super T> comparator)
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.static <T> java.util.ArrayList<T>
take(java.util.ArrayList<T> list, int count)
static <T,R extends java.util.Collection<T>>
Rtake(java.util.ArrayList<T> list, int count, R targetList)
static <T> MutableList<T>
takeWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
static <T> void
toArray(java.util.ArrayList<T> list, T[] target, int startIndex, int sourceSize)
private static <T> void
wipeAndResetTheEnd(int newCurrentFilledIndex, int newSize, T[] newElements, java.util.ArrayList<T> list)
static <X,Y>
MutableList<Pair<X,Y>>zip(java.util.ArrayList<X> xs, java.lang.Iterable<Y> ys)
static <X,Y,R extends java.util.Collection<Pair<X,Y>>>
Rzip(java.util.ArrayList<X> xs, java.lang.Iterable<Y> ys, R targetCollection)
static <T> MutableList<Pair<T,java.lang.Integer>>
zipWithIndex(java.util.ArrayList<T> list)
static <T,R extends java.util.Collection<Pair<T,java.lang.Integer>>>
RzipWithIndex(java.util.ArrayList<T> list, R targetCollection)
-
-
-
Field Detail
-
ELEMENT_DATA_FIELD
private static final java.lang.reflect.Field ELEMENT_DATA_FIELD
-
SIZE_FIELD
private static final java.lang.reflect.Field SIZE_FIELD
-
MIN_DIRECT_ARRAY_ACCESS_SIZE
private static final int MIN_DIRECT_ARRAY_ACCESS_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
select
public static <T> java.util.ArrayList<T> select(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.select(Iterable, Predicate)
-
selectWith
public static <T,IV> java.util.ArrayList<T> selectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
-
select
public static <T,R extends java.util.Collection<T>> R select(java.util.ArrayList<T> list, Predicate<? super T> predicate, R targetCollection)
-
selectWith
public static <T,P,R extends java.util.Collection<T>> R selectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)
-
selectInstancesOf
public static <T> MutableList<T> selectInstancesOf(java.util.ArrayList<?> list, java.lang.Class<T> clazz)
-
count
public static <T> int count(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.count(Iterable, Predicate)
-
countWith
public static <T,P> int countWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
collectIf
public static <T,A> java.util.ArrayList<A> collectIf(java.util.ArrayList<T> list, Predicate<? super T> predicate, Function<? super T,? extends A> function)
-
collectIf
public static <T,A,R extends java.util.Collection<A>> R collectIf(java.util.ArrayList<T> list, Predicate<? super T> predicate, Function<? super T,? extends A> function, R targetCollection)
-
reject
public static <T> java.util.ArrayList<T> reject(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.reject(Iterable, Predicate)
-
rejectWith
public static <T,IV> java.util.ArrayList<T> rejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
-
reject
public static <T,R extends java.util.Collection<T>> R reject(java.util.ArrayList<T> list, Predicate<? super T> predicate, R targetCollection)
-
rejectWith
public static <T,P,R extends java.util.Collection<T>> R rejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P injectedValue, R targetCollection)
-
collect
public static <T,A> java.util.ArrayList<A> collect(java.util.ArrayList<T> list, Function<? super T,? extends A> function)
- See Also:
Iterate.collect(Iterable, Function)
-
collectBoolean
public static <T> MutableBooleanList collectBoolean(java.util.ArrayList<T> list, BooleanFunction<? super T> booleanFunction)
-
collectBoolean
public static <T,R extends MutableBooleanCollection> R collectBoolean(java.util.ArrayList<T> list, BooleanFunction<? super T> booleanFunction, R target)
-
collectBooleanFromInternalArray
private static <T,R extends MutableBooleanCollection> R collectBooleanFromInternalArray(java.util.ArrayList<T> source, BooleanFunction<? super T> booleanFunction, int elementsToCollect, R target)
-
collectByte
public static <T> MutableByteList collectByte(java.util.ArrayList<T> list, ByteFunction<? super T> byteFunction)
-
collectByte
public static <T,R extends MutableByteCollection> R collectByte(java.util.ArrayList<T> list, ByteFunction<? super T> byteFunction, R target)
-
collectByteFromInternalArray
private static <T,R extends MutableByteCollection> R collectByteFromInternalArray(java.util.ArrayList<T> source, ByteFunction<? super T> byteFunction, int elementsToCollect, R target)
-
collectChar
public static <T> MutableCharList collectChar(java.util.ArrayList<T> list, CharFunction<? super T> charFunction)
-
collectChar
public static <T,R extends MutableCharCollection> R collectChar(java.util.ArrayList<T> list, CharFunction<? super T> charFunction, R target)
-
collectCharFromInternalArray
private static <T,R extends MutableCharCollection> R collectCharFromInternalArray(java.util.ArrayList<T> source, CharFunction<? super T> charFunction, int elementsToCollect, R target)
-
collectDouble
public static <T> MutableDoubleList collectDouble(java.util.ArrayList<T> list, DoubleFunction<? super T> doubleFunction)
-
collectDouble
public static <T,R extends MutableDoubleCollection> R collectDouble(java.util.ArrayList<T> list, DoubleFunction<? super T> doubleFunction, R target)
-
collectDoubleFromInternalArray
private static <T,R extends MutableDoubleCollection> R collectDoubleFromInternalArray(java.util.ArrayList<T> source, DoubleFunction<? super T> doubleFunction, int elementsToCollect, R target)
-
collectFloat
public static <T> MutableFloatList collectFloat(java.util.ArrayList<T> list, FloatFunction<? super T> floatFunction)
-
collectFloat
public static <T,R extends MutableFloatCollection> R collectFloat(java.util.ArrayList<T> list, FloatFunction<? super T> floatFunction, R target)
-
collectFloatFromInternalArray
private static <T,R extends MutableFloatCollection> R collectFloatFromInternalArray(java.util.ArrayList<T> source, FloatFunction<? super T> floatFunction, int elementsToCollect, R target)
-
collectInt
public static <T> MutableIntList collectInt(java.util.ArrayList<T> list, IntFunction<? super T> intFunction)
-
collectInt
public static <T,R extends MutableIntCollection> R collectInt(java.util.ArrayList<T> list, IntFunction<? super T> intFunction, R target)
-
collectIntFromInternalArray
private static <T,R extends MutableIntCollection> R collectIntFromInternalArray(java.util.ArrayList<T> source, IntFunction<? super T> intFunction, int elementsToCollect, R target)
-
collectLong
public static <T> MutableLongList collectLong(java.util.ArrayList<T> list, LongFunction<? super T> longFunction)
-
collectLong
public static <T,R extends MutableLongCollection> R collectLong(java.util.ArrayList<T> list, LongFunction<? super T> longFunction, R target)
-
collectLongFromInternalArray
private static <T,R extends MutableLongCollection> R collectLongFromInternalArray(java.util.ArrayList<T> source, LongFunction<? super T> longFunction, int elementsToCollect, R target)
-
collectShort
public static <T> MutableShortList collectShort(java.util.ArrayList<T> list, ShortFunction<? super T> shortFunction)
-
collectShort
public static <T,R extends MutableShortCollection> R collectShort(java.util.ArrayList<T> list, ShortFunction<? super T> shortFunction, R target)
-
collectShortFromInternalArray
private static <T,R extends MutableShortCollection> R collectShortFromInternalArray(java.util.ArrayList<T> source, ShortFunction<? super T> shortFunction, int elementsToCollect, R target)
-
collect
public static <T,A,R extends java.util.Collection<A>> R collect(java.util.ArrayList<T> list, Function<? super T,? extends A> function, R targetCollection)
-
flatCollect
public static <T,A> java.util.ArrayList<A> flatCollect(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<A>> function)
- See Also:
Iterate.flatCollect(Iterable, Function)
-
flatCollect
public static <T,A,R extends java.util.Collection<A>> R flatCollect(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<A>> function, R targetCollection)
-
forEach
public static <T> void forEach(java.util.ArrayList<T> list, Procedure<? super T> procedure)
- See Also:
Iterate.forEach(Iterable, Procedure)
-
reverseForEach
public static <T> void reverseForEach(java.util.ArrayList<T> list, Procedure<? super T> procedure)
Reverses over the List in reverse order executing the Procedure for each element.
-
reverseForEachWithIndex
public static <T> void reverseForEachWithIndex(java.util.ArrayList<T> list, ObjectIntProcedure<? super T> procedure)
Reverses over the List in reverse order executing the Procedure with index for each element.
-
forEach
public static <T> void forEach(java.util.ArrayList<T> list, int from, int to, Procedure<? super T> procedure)
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(java.util.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(java.util.ArrayList<T1> list1, java.util.ArrayList<T2> list2, Procedure2<? super T1,? super T2> procedure)
-
forEachWithIndex
public static <T> void forEachWithIndex(java.util.ArrayList<T> list, ObjectIntProcedure<? super T> objectIntProcedure)
-
detect
public static <T> T detect(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.detect(Iterable, Predicate)
-
detectWith
public static <T,P> T detectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
detectOptional
public static <T> java.util.Optional<T> detectOptional(java.util.ArrayList<T> list, Predicate<? super T> predicate)
-
detectWithOptional
public static <T,P> java.util.Optional<T> detectWithOptional(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
detectIfNone
public static <T> T detectIfNone(java.util.ArrayList<T> list, Predicate<? super T> predicate, T ifNone)
-
detectWithIfNone
public static <T,IV> T detectWithIfNone(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue, T ifNone)
-
injectInto
public static <T,IV> IV injectInto(IV injectValue, java.util.ArrayList<T> list, Function2<? super IV,? super T,? extends IV> function)
-
injectInto
public static <T> int injectInto(int injectValue, java.util.ArrayList<T> list, IntObjectToIntFunction<? super T> function)
-
injectInto
public static <T> long injectInto(long injectValue, java.util.ArrayList<T> list, LongObjectToLongFunction<? super T> function)
-
injectInto
public static <T> double injectInto(double injectValue, java.util.ArrayList<T> list, DoubleObjectToDoubleFunction<? super T> function)
-
injectInto
public static <T> float injectInto(float injectValue, java.util.ArrayList<T> list, FloatObjectToFloatFunction<? super T> function)
-
anySatisfy
public static <T> boolean anySatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.anySatisfy(Iterable, Predicate)
-
anySatisfyWith
public static <T,P> boolean anySatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
allSatisfy
public static <T> boolean allSatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.allSatisfy(Iterable, Predicate)
-
allSatisfyWith
public static <T,IV> boolean allSatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
-
noneSatisfy
public static <T> boolean noneSatisfy(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.noneSatisfy(Iterable, Predicate)
-
noneSatisfyWith
public static <T,IV> boolean noneSatisfyWith(java.util.ArrayList<T> list, Predicate2<? super T,? super IV> predicate, IV injectedValue)
-
selectAndRejectWith
public static <T,P> Twin<MutableList<T>> selectAndRejectWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
partition
public static <T> PartitionMutableList<T> partition(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.partition(Iterable, Predicate)
-
partitionWith
public static <T,P> PartitionMutableList<T> partitionWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
detectIndex
public static <T> int detectIndex(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.detectIndex(Iterable, Predicate)
-
detectIndexWith
public static <T,P> int detectIndexWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
detectLastIndex
public static <T> int detectLastIndex(java.util.ArrayList<T> list, Predicate<? super T> predicate)
-
injectIntoWith
public static <T,IV,P> IV injectIntoWith(IV injectedValue, java.util.ArrayList<T> list, Function3<? super IV,? super T,? super P,? extends IV> function, P parameter)
-
forEachWith
public static <T,P> void forEachWith(java.util.ArrayList<T> list, Procedure2<? super T,? super P> procedure, P parameter)
-
collectWith
public static <T,P,A> java.util.ArrayList<A> collectWith(java.util.ArrayList<T> list, Function2<? super T,? super P,? extends A> function, P parameter)
-
collectWith
public static <T,P,A,R extends java.util.Collection<A>> R collectWith(java.util.ArrayList<T> list, Function2<? super T,? super P,? extends A> function, P parameter, R targetCollection)
-
removeIf
public static <T> boolean removeIf(java.util.ArrayList<T> list, Predicate<? super T> predicate)
- See Also:
Iterate.removeIf(Iterable, Predicate)
-
removeIfWith
public static <T,P> boolean removeIfWith(java.util.ArrayList<T> list, Predicate2<? super T,? super P> predicate, P parameter)
-
distinct
public static <T> java.util.ArrayList<T> distinct(java.util.ArrayList<T> list)
-
distinct
@Deprecated public static <T,R extends java.util.List<T>> R distinct(java.util.ArrayList<T> list, R targetList)
Deprecated.in 7.0.
-
distinct
public static <T> java.util.ArrayList<T> distinct(java.util.ArrayList<T> list, HashingStrategy<? super T> hashingStrategy)
- Since:
- 7.0.
-
distinctBy
public static <T,V> java.util.ArrayList<T> distinctBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
- Since:
- 9.0.
-
wipeAndResetTheEnd
private static <T> void wipeAndResetTheEnd(int newCurrentFilledIndex, int newSize, T[] newElements, java.util.ArrayList<T> list)
-
sortThis
public static <T extends java.lang.Comparable<? super T>> java.util.ArrayList<T> sortThis(java.util.ArrayList<T> list)
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.
-
sortThis
public static <T> java.util.ArrayList<T> sortThis(java.util.ArrayList<T> list, java.util.Comparator<? super T> comparator)
Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList.
-
toArray
public static <T> void toArray(java.util.ArrayList<T> list, T[] target, int startIndex, int sourceSize)
-
take
public static <T> java.util.ArrayList<T> take(java.util.ArrayList<T> list, int count)
- See Also:
Iterate.take(Iterable, int)
-
take
public static <T,R extends java.util.Collection<T>> R take(java.util.ArrayList<T> list, int count, R targetList)
- See Also:
Iterate.take(Iterable, int)
-
drop
public static <T> java.util.ArrayList<T> drop(java.util.ArrayList<T> list, int count)
- See Also:
Iterate.drop(Iterable, int)
-
drop
public static <T,R extends java.util.Collection<T>> R drop(java.util.ArrayList<T> list, int count, R targetList)
- See Also:
Iterate.drop(Iterable, int)
-
groupBy
public static <T,V> FastListMultimap<V,T> groupBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
- See Also:
Iterate.groupBy(Iterable, Function)
-
groupBy
public static <T,V,R extends MutableMultimap<V,T>> R groupBy(java.util.ArrayList<T> list, Function<? super T,? extends V> function, R target)
-
groupByEach
public static <T,V> FastListMultimap<V,T> groupByEach(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<V>> function)
- See Also:
Iterate.groupByEach(Iterable, Function)
-
groupByEach
public static <T,V,R extends MutableMultimap<V,T>> R groupByEach(java.util.ArrayList<T> list, Function<? super T,? extends java.lang.Iterable<V>> function, R target)
-
groupByUniqueKey
public static <T,V> MutableMap<V,T> groupByUniqueKey(java.util.ArrayList<T> list, Function<? super T,? extends V> function)
-
groupByUniqueKey
public static <T,V,R extends MutableMapIterable<V,T>> R groupByUniqueKey(java.util.ArrayList<T> list, Function<? super T,? extends V> function, R target)
-
zip
public static <X,Y> MutableList<Pair<X,Y>> zip(java.util.ArrayList<X> xs, java.lang.Iterable<Y> ys)
- See Also:
Iterate.zip(Iterable, Iterable)
-
zip
public static <X,Y,R extends java.util.Collection<Pair<X,Y>>> R zip(java.util.ArrayList<X> xs, java.lang.Iterable<Y> ys, R targetCollection)
-
zipWithIndex
public static <T> MutableList<Pair<T,java.lang.Integer>> zipWithIndex(java.util.ArrayList<T> list)
- See Also:
Iterate.zipWithIndex(Iterable)
-
zipWithIndex
public static <T,R extends java.util.Collection<Pair<T,java.lang.Integer>>> R zipWithIndex(java.util.ArrayList<T> list, R targetCollection)
-
takeWhile
public static <T> MutableList<T> takeWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
-
dropWhile
public static <T> MutableList<T> dropWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
-
partitionWhile
public static <T> PartitionMutableList<T> partitionWhile(java.util.ArrayList<T> list, Predicate<? super T> predicate)
-
canAccessInternalArray
private static boolean canAccessInternalArray(java.util.ArrayList<?> list)
-
isOptimizableArrayList
private static boolean isOptimizableArrayList(java.util.ArrayList<?> list, int newSize)
-
getInternalArray
private static <T> T[] getInternalArray(java.util.ArrayList<T> list)
-
aggregateInPlaceBy
public static <T,K,V> MutableMap<K,V> aggregateInPlaceBy(java.util.ArrayList<T> list, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)
-
aggregateBy
public static <T,K,V> MutableMap<K,V> aggregateBy(java.util.ArrayList<T> list, Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)
-
-