aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2019-11-15 20:09:15 +0800
committershedaniel <daniel@shedaniel.me>2019-11-15 20:09:15 +0800
commitb7246fa0016888fd52c45f9c77df46f9d791e326 (patch)
treeca455d73ea2213ef6e5a62855834119715a13fe2 /src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
parent5c34cd8dae4879e04fd825f423e0ddbf8480668e (diff)
downloadRoughlyEnoughItems-b7246fa0016888fd52c45f9c77df46f9d791e326.tar.gz
RoughlyEnoughItems-b7246fa0016888fd52c45f9c77df46f9d791e326.tar.bz2
RoughlyEnoughItems-b7246fa0016888fd52c45f9c77df46f9d791e326.zip
Using more of the API instead of the Impl
Diffstat (limited to 'src/main/java/me/shedaniel/rei/utils/CollectionUtils.java')
-rw-r--r--src/main/java/me/shedaniel/rei/utils/CollectionUtils.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java b/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
index d2b7eb92a..20e20d162 100644
--- a/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
+++ b/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java
@@ -47,14 +47,13 @@ public class CollectionUtils {
}
public static final <T> List<T> filter(List<T> list, Predicate<T> predicate) {
- List<T> l = null;
+ List<T> l = new LinkedList<>();
for (T t : list) {
if (predicate.test(t)) {
- if (l == null) l = new LinkedList<>();
l.add(t);
}
}
- return l == null ? Collections.emptyList() : l;
+ return l;
}
public static final <T, R> List<R> map(List<T> list, Function<T, R> function) {
@@ -158,7 +157,7 @@ public class CollectionUtils {
public static final <T> int sumInt(List<Integer> list) {
int sum = 0;
- for (Integer t : list) {
+ for (int t : list) {
sum += t;
}
return sum;
@@ -174,7 +173,7 @@ public class CollectionUtils {
public static final <T> double sumDouble(List<Double> list) {
double sum = 0;
- for (Double t : list) {
+ for (double t : list) {
sum += t;
}
return sum;