diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-11-20 18:24:52 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-11-20 18:31:03 +0800 |
| commit | 67f20e0233abc67f7743554deb486049e8a88e1c (patch) | |
| tree | a4c428081b93e7c056f766296a2a19a9dcc8e5ee /api/src/main/java | |
| parent | 69e26e78b69f7eeb745b604b2347ac30fe32666f (diff) | |
| download | RoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.tar.gz RoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.tar.bz2 RoughlyEnoughItems-67f20e0233abc67f7743554deb486049e8a88e1c.zip | |
Fix duplicate items with CC Tweaked
Diffstat (limited to 'api/src/main/java')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java | 13 |
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) { |
