Class RandomAccessListIterate
java.lang.Object
org.eclipse.collections.impl.utility.internal.RandomAccessListIterate
The ListIterate class provides a few of the methods from the Smalltalk Collection Protocol for use with ArrayLists.
This includes do:, select:, reject:, collect:, inject:into:, detect:, detect:ifNone:, anySatisfy: and allSatisfy:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
K, V> MutableMap<K, V> aggregateBy
(List<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
(List<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) static <T> boolean
allSatisfy
(List<T> list, Predicate<? super T> predicate) static <T,
P> boolean allSatisfyWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> boolean
anySatisfy
(List<T> list, Predicate<? super T> predicate) static <T,
P> boolean anySatisfyWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> void
appendString
(List<T> list, Appendable appendable, String start, String separator, String end) static <T,
A> MutableList<A> static <T,
A, R extends Collection<A>>
Rstatic <T> MutableBooleanList
collectBoolean
(List<T> list, BooleanFunction<? super T> booleanFunction) static <T,
R extends MutableBooleanCollection>
RcollectBoolean
(List<T> list, BooleanFunction<? super T> booleanFunction, R target) static <T> MutableByteList
collectByte
(List<T> list, ByteFunction<? super T> byteFunction) static <T,
R extends MutableByteCollection>
RcollectByte
(List<T> list, ByteFunction<? super T> byteFunction, R target) static <T> MutableCharList
collectChar
(List<T> list, CharFunction<? super T> charFunction) static <T,
R extends MutableCharCollection>
RcollectChar
(List<T> list, CharFunction<? super T> charFunction, R target) static <T> MutableDoubleList
collectDouble
(List<T> list, DoubleFunction<? super T> doubleFunction) static <T,
R extends MutableDoubleCollection>
RcollectDouble
(List<T> list, DoubleFunction<? super T> doubleFunction, R target) static <T> MutableFloatList
collectFloat
(List<T> list, FloatFunction<? super T> floatFunction) static <T,
R extends MutableFloatCollection>
RcollectFloat
(List<T> list, FloatFunction<? super T> floatFunction, R target) static <T,
A> MutableList<A> static <T,
A, R extends Collection<A>>
RcollectIf
(List<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function, R targetCollection) static <T> MutableIntList
collectInt
(List<T> list, IntFunction<? super T> intFunction) static <T,
R extends MutableIntCollection>
RcollectInt
(List<T> list, IntFunction<? super T> intFunction, R target) static <T> MutableLongList
collectLong
(List<T> list, LongFunction<? super T> longFunction) static <T,
R extends MutableLongCollection>
RcollectLong
(List<T> list, LongFunction<? super T> longFunction, R target) static <T> MutableShortList
collectShort
(List<T> list, ShortFunction<? super T> shortFunction) static <T,
R extends MutableShortCollection>
RcollectShort
(List<T> list, ShortFunction<? super T> shortFunction, R target) static <T,
P, A, R extends Collection<A>>
RcollectWith
(List<T> list, Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) static <T,
A> MutableList<A> collectWithIndex
(List<T> list, ObjectIntToObjectFunction<? super T, ? extends A> function) static <T,
A, R extends Collection<A>>
RcollectWithIndex
(List<T> list, ObjectIntToObjectFunction<? super T, ? extends A> function, R targetCollection) static <T,
P> boolean corresponds
(List<T> list, OrderedIterable<P> other, Predicate2<? super T, ? super P> predicate) static <T> int
static <T,
IV> int countWith
(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T> T
static <T> int
detectIndex
(List<T> list, Predicate<? super T> predicate) Searches for the first occurrence where the predicate evaluates to true.static <T,
IV> int detectIndexWith
(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) Searches for the first occurrence where the predicate evaluates to true.static <T> int
detectLastIndex
(List<T> list, Predicate<? super T> predicate) static <T> Optional<T>
detectOptional
(List<T> list, Predicate<? super T> predicate) static <T,
P> T detectWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T,
P> Optional<T> detectWithOptional
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> MutableList<T>
static <T> MutableList<T>
distinct
(List<T> list, HashingStrategy<? super T> hashingStrategy) static <T,
R extends List<T>>
RDeprecated.in 7.0.static <T> MutableList<T>
static <T,
R extends Collection<T>>
Rstatic <T> MutableList<T>
static <T,
A> MutableList<A> flatCollect
(List<T> list, Function<? super T, ? extends Iterable<A>> function) static <T,
A, R extends Collection<A>>
RflatCollect
(List<T> list, Function<? super T, ? extends Iterable<A>> function, R targetCollection) static <T> void
Iterates over the section of the list covered by the specified indexes.static <T> void
static <T1,
T2> void forEachInBoth
(List<T1> list1, List<T2> list2, Procedure2<? super T1, ? super T2> procedure) For each element in both of the Lists, operation is evaluated with both elements as parameters.static <T,
P> void forEachWith
(List<T> list, Procedure2<? super T, ? super P> procedure, P parameter) static <T> void
forEachWithIndex
(List<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
(List<T> list, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over a collection passing each element and the current relative int index to the specified instance of ObjectIntProcedure.static <T> T
Returns the last element of a list.static <T,
V> FastListMultimap<V, T> static <T,
V, R extends MutableMultimap<V, T>>
Rstatic <T,
V> FastListMultimap<V, T> groupByEach
(List<T> list, Function<? super T, ? extends Iterable<V>> function) static <T,
V, R extends MutableMultimap<V, T>>
RgroupByEach
(List<T> list, Function<? super T, ? extends Iterable<V>> function, R target) static <K,
T> MutableMap<K, T> groupByUniqueKey
(List<T> list, Function<? super T, ? extends K> function) static <K,
T, R extends MutableMapIterable<K, T>>
RgroupByUniqueKey
(List<T> list, Function<? super T, ? extends K> function, R target) static <T> double
injectInto
(double injectValue, List<T> list, DoubleObjectToDoubleFunction<? super T> function) static <T> float
injectInto
(float injectValue, List<T> list, FloatObjectToFloatFunction<? super T> function) static <T> int
injectInto
(int injectValue, List<T> list, IntObjectToIntFunction<? super T> function) static <T> long
injectInto
(long injectValue, List<T> list, LongObjectToLongFunction<? super T> function) static <T,
IV> IV injectInto
(IV injectValue, List<T> list, Function2<? super IV, ? super T, ? extends IV> function) static <T,
IV, P> IV injectIntoWith
(IV injectedValue, List<T> list, Function3<? super IV, ? super T, ? super P, ? extends IV> function, P parameter) static <T> T
static <T> T
max
(List<T> list, Comparator<? super T> comparator) static <T,
V extends Comparable<? super V>>
Tstatic <T> T
static <T> T
min
(List<T> list, Comparator<? super T> comparator) static <T,
V extends Comparable<? super V>>
Tstatic <T> boolean
noneSatisfy
(List<T> list, Predicate<? super T> predicate) static <T,
P> boolean noneSatisfyWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> PartitionMutableList<T>
static <T> PartitionMutableList<T>
partitionWhile
(List<T> list, Predicate<? super T> predicate) static <T,
P> PartitionMutableList<T> partitionWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T> MutableList<T>
static <T,
R extends Collection<T>>
Rstatic <T,
IV> MutableList<T> rejectWith
(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T,
P, R extends Collection<T>>
RrejectWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) static <T> boolean
static <T> boolean
static <T,
P> boolean removeIfWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) static <T,
P> boolean removeIfWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, Procedure<? super T> procedure) static <T> MutableList<T>
static <T,
R extends Collection<T>>
Rstatic <T,
IV> Twin<MutableList<T>> selectAndRejectWith
(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T> MutableList<T>
selectInstancesOf
(List<?> list, Class<T> clazz) static <T,
IV> MutableList<T> selectWith
(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) static <T,
P, R extends Collection<T>>
RselectWith
(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) static <T> boolean
shortCircuit
(List<T> list, Predicate<? super T> predicate, boolean expected, boolean onShortCircuit, boolean atEnd) static <T,
P> boolean shortCircuitWith
(List<T> list, Predicate2<? super T, ? super P> predicate2, P parameter, boolean expected, boolean onShortCircuit, boolean atEnd) static <V,
T> MutableMap<V, BigDecimal> sumByBigDecimal
(List<T> list, Function<? super T, ? extends V> groupBy, Function<? super T, BigDecimal> function) static <V,
T> MutableMap<V, BigInteger> sumByBigInteger
(List<T> list, Function<? super T, ? extends V> groupBy, Function<? super T, BigInteger> function) static <V,
T> ObjectDoubleMap<V> sumByDouble
(List<T> list, Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) static <V,
T> ObjectDoubleMap<V> sumByFloat
(List<T> list, Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) static <V,
T> ObjectLongMap<V> sumByInt
(List<T> list, Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) static <V,
T> ObjectLongMap<V> sumByLong
(List<T> list, Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) static <T> BigDecimal
sumOfBigDecimal
(List<T> list, Function<? super T, BigDecimal> function) static <T> BigInteger
sumOfBigInteger
(List<T> list, Function<? super T, BigInteger> function) static <T> double
sumOfDouble
(List<T> list, DoubleFunction<? super T> function) static <T> double
sumOfFloat
(List<T> list, FloatFunction<? super T> function) static <T> long
sumOfInt
(List<T> list, IntFunction<? super T> function) static <T> long
sumOfLong
(List<T> list, LongFunction<? super T> function) static <T> MutableList<T>
static <T,
R extends Collection<T>>
Rstatic <T> MutableList<T>
static <T> void
static <X,
Y> MutableList<Pair<X, Y>> static <X,
Y, R extends Collection<Pair<X, Y>>>
Rstatic <T> MutableList<Pair<T,
Integer>> zipWithIndex
(List<T> list) static <T,
R extends Collection<Pair<T, Integer>>>
RzipWithIndex
(List<T> list, R target)
-
Method Details
-
toArray
-
select
- See Also:
-
selectWith
public static <T,IV> MutableList<T> selectWith(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
select
public static <T,R extends Collection<T>> R select(List<T> list, Predicate<? super T> predicate, R targetCollection) -
selectWith
public static <T,P, R selectWithR extends Collection<T>> (List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) -
selectInstancesOf
-
count
- See Also:
-
countWith
public static <T,IV> int countWith(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
collectIf
public static <T,A> MutableList<A> collectIf(List<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function) -
collectIf
public static <T,A, R collectIfR extends Collection<A>> (List<T> list, Predicate<? super T> predicate, Function<? super T, ? extends A> function, R targetCollection) -
reject
- See Also:
-
rejectWith
public static <T,IV> MutableList<T> rejectWith(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
reject
public static <T,R extends Collection<T>> R reject(List<T> list, Predicate<? super T> predicate, R targetCollection) -
rejectWith
public static <T,P, R rejectWithR extends Collection<T>> (List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) -
collect
- See Also:
-
collect
public static <T,A, R collectR extends Collection<A>> (List<T> list, Function<? super T, ? extends A> function, R targetCollection) -
collectWithIndex
public static <T,A> MutableList<A> collectWithIndex(List<T> list, ObjectIntToObjectFunction<? super T, ? extends A> function) - Since:
- 9.1
-
collectWithIndex
public static <T,A, R collectWithIndexR extends Collection<A>> (List<T> list, ObjectIntToObjectFunction<? super T, ? extends A> function, R targetCollection) - Since:
- 9.1
-
collectBoolean
public static <T> MutableBooleanList collectBoolean(List<T> list, BooleanFunction<? super T> booleanFunction) -
collectBoolean
public static <T,R extends MutableBooleanCollection> R collectBoolean(List<T> list, BooleanFunction<? super T> booleanFunction, R target) -
collectByte
-
collectByte
public static <T,R extends MutableByteCollection> R collectByte(List<T> list, ByteFunction<? super T> byteFunction, R target) -
collectChar
-
collectChar
public static <T,R extends MutableCharCollection> R collectChar(List<T> list, CharFunction<? super T> charFunction, R target) -
collectDouble
public static <T> MutableDoubleList collectDouble(List<T> list, DoubleFunction<? super T> doubleFunction) -
collectDouble
public static <T,R extends MutableDoubleCollection> R collectDouble(List<T> list, DoubleFunction<? super T> doubleFunction, R target) -
collectFloat
public static <T> MutableFloatList collectFloat(List<T> list, FloatFunction<? super T> floatFunction) -
collectFloat
public static <T,R extends MutableFloatCollection> R collectFloat(List<T> list, FloatFunction<? super T> floatFunction, R target) -
collectInt
-
collectInt
public static <T,R extends MutableIntCollection> R collectInt(List<T> list, IntFunction<? super T> intFunction, R target) -
collectLong
-
collectLong
public static <T,R extends MutableLongCollection> R collectLong(List<T> list, LongFunction<? super T> longFunction, R target) -
collectShort
public static <T> MutableShortList collectShort(List<T> list, ShortFunction<? super T> shortFunction) -
collectShort
public static <T,R extends MutableShortCollection> R collectShort(List<T> list, ShortFunction<? super T> shortFunction, R target) -
flatCollect
public static <T,A> MutableList<A> flatCollect(List<T> list, Function<? super T, ? extends Iterable<A>> function) - See Also:
-
flatCollect
public static <T,A, R flatCollectR extends Collection<A>> (List<T> list, Function<? super T, ? extends Iterable<A>> function, R targetCollection) -
getLast
Returns the last element of a list. -
forEach
- See Also:
-
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. MutableList<People> people = FastList.newListWith(ted, mary, bob, sally); ListIterate.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(List<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. MutableList<People> people = FastList.newListWith(ted, mary, bob, sally); ListIterate.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(List<T1> list1, List<T2> list2, Procedure2<? super T1, ? super T2> procedure) For each element in both of the Lists, operation is evaluated with both elements as parameters. -
forEachWithIndex
public static <T> void forEachWithIndex(List<T> list, ObjectIntProcedure<? super T> objectIntProcedure) Iterates over a collection passing each element and the current relative int index to the specified instance of ObjectIntProcedure. -
injectInto
-
injectInto
public static <T> int injectInto(int injectValue, List<T> list, IntObjectToIntFunction<? super T> function) -
injectInto
public static <T> long injectInto(long injectValue, List<T> list, LongObjectToLongFunction<? super T> function) -
injectInto
public static <T> double injectInto(double injectValue, List<T> list, DoubleObjectToDoubleFunction<? super T> function) -
injectInto
public static <T> float injectInto(float injectValue, List<T> list, FloatObjectToFloatFunction<? super T> function) -
sumOfInt
-
sumOfLong
-
sumOfFloat
-
sumOfDouble
-
sumOfBigDecimal
-
sumOfBigInteger
-
sumByBigDecimal
public static <V,T> MutableMap<V,BigDecimal> sumByBigDecimal(List<T> list, Function<? super T, ? extends V> groupBy, Function<? super T, BigDecimal> function) -
sumByBigInteger
public static <V,T> MutableMap<V,BigInteger> sumByBigInteger(List<T> list, Function<? super T, ? extends V> groupBy, Function<? super T, BigInteger> function) -
shortCircuit
-
shortCircuitWith
public static <T,P> boolean shortCircuitWith(List<T> list, Predicate2<? super T, ? super P> predicate2, P parameter, boolean expected, boolean onShortCircuit, boolean atEnd) -
corresponds
public static <T,P> boolean corresponds(List<T> list, OrderedIterable<P> other, Predicate2<? super T, ? super P> predicate) -
anySatisfy
-
anySatisfyWith
public static <T,P> boolean anySatisfyWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
allSatisfy
-
allSatisfyWith
public static <T,P> boolean allSatisfyWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
noneSatisfy
-
noneSatisfyWith
public static <T,P> boolean noneSatisfyWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detect
-
detectWith
public static <T,P> T detectWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
detectOptional
-
detectWithOptional
public static <T,P> Optional<T> detectWithOptional(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
selectAndRejectWith
public static <T,IV> Twin<MutableList<T>> selectAndRejectWith(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) -
partition
-
partitionWith
public static <T,P> PartitionMutableList<T> partitionWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
removeIf
-
removeIfWith
public static <T,P> boolean removeIfWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter) -
removeIf
-
removeIfWith
public static <T,P> boolean removeIfWith(List<T> list, Predicate2<? super T, ? super P> predicate, P parameter, Procedure<? super T> procedure) -
detectIndex
Searches for the first occurrence where the predicate evaluates to true.- See Also:
-
detectIndexWith
public static <T,IV> int detectIndexWith(List<T> list, Predicate2<? super T, ? super IV> predicate, IV injectedValue) Searches for the first occurrence where the predicate evaluates to true. -
detectLastIndex
-
injectIntoWith
-
forEachWith
public static <T,P> void forEachWith(List<T> list, Procedure2<? super T, ? super P> procedure, P parameter) -
collectWith
public static <T,P, R collectWithA, R extends Collection<A>> (List<T> list, Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) -
distinct
Deprecated.in 7.0. -
distinct
- Since:
- 7.0.
-
distinct
- Since:
- 7.0.
-
take
- See Also:
-
take
- See Also:
-
drop
- See Also:
-
drop
- See Also:
-
appendString
public static <T> void appendString(List<T> list, Appendable appendable, String start, String separator, String end) -
groupBy
public static <T,V> FastListMultimap<V,T> groupBy(List<T> list, Function<? super T, ? extends V> function) - See Also:
-
groupBy
public static <T,V, R groupByR extends MutableMultimap<V, T>> (List<T> list, Function<? super T, ? extends V> function, R target) -
groupByEach
public static <T,V> FastListMultimap<V,T> groupByEach(List<T> list, Function<? super T, ? extends Iterable<V>> function) -
groupByEach
public static <T,V, R groupByEachR extends MutableMultimap<V, T>> (List<T> list, Function<? super T, ? extends Iterable<V>> function, R target) -
groupByUniqueKey
public static <K,T> MutableMap<K,T> groupByUniqueKey(List<T> list, Function<? super T, ? extends K> function) -
groupByUniqueKey
public static <K,T, R groupByUniqueKeyR extends MutableMapIterable<K, T>> (List<T> list, Function<? super T, ? extends K> function, R target) -
minBy
public static <T,V extends Comparable<? super V>> T minBy(List<T> list, Function<? super T, ? extends V> function) -
maxBy
public static <T,V extends Comparable<? super V>> T maxBy(List<T> list, Function<? super T, ? extends V> function) -
min
-
max
-
min
-
max
-
zip
-
zip
public static <X,Y, R zipR extends Collection<Pair<X, Y>>> (List<X> list, Iterable<Y> iterable, R target) -
zipWithIndex
-
zipWithIndex
-
aggregateInPlaceBy
public static <T,K, MutableMap<K,V> V> aggregateInPlaceBy(List<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(List<T> list, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) -
takeWhile
-
dropWhile
-
partitionWhile
public static <T> PartitionMutableList<T> partitionWhile(List<T> list, Predicate<? super T> predicate) -
sumByInt
public static <V,T> ObjectLongMap<V> sumByInt(List<T> list, Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) -
sumByLong
public static <V,T> ObjectLongMap<V> sumByLong(List<T> list, Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) -
sumByFloat
public static <V,T> ObjectDoubleMap<V> sumByFloat(List<T> list, Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) -
sumByDouble
public static <V,T> ObjectDoubleMap<V> sumByDouble(List<T> list, Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function)
-