aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-11-20 18:24:52 +0800
committershedaniel <daniel@shedaniel.me>2021-11-20 18:31:03 +0800
commit67f20e0233abc67f7743554deb486049e8a88e1c (patch)
treea4c428081b93e7c056f766296a2a19a9dcc8e5ee /api/src/main/java/me
parent69e26e78b69f7eeb745b604b2347ac30fe32666f (diff)
downloadRoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.tar.gz
RoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.tar.bz2
RoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.zip
Fix duplicate items with CC Tweaked
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
index 0d20cf7f9..946d9336f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java
@@ -265,6 +265,19 @@ public class CollectionUtils {
return l == null ? Collections.emptyList() : l;
}
+ public static <T, R> List<R> mapAndFilter(Iterable<T> list, Predicate<R> predicate, Function<T, R> function) {
+ List<R> l = null;
+ for (T t : list) {
+ R r = function.apply(t);
+ if (predicate.test(r)) {
+ if (l == null)
+ l = Lists.newArrayList();
+ l.add(r);
+ }
+ }
+ return l == null ? Collections.emptyList() : l;
+ }
+
public static <T> int sumInt(Iterable<T> list, Function<T, Integer> function) {
int sum = 0;
for (T t : list) {