diff options
| author | Max <maxh2709@gmail.com> | 2022-06-17 10:39:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-17 16:39:38 +0800 |
| commit | 53e160bbfc5936d599b910b5adf06734c7123257 (patch) | |
| tree | 0aacf910cd5b8cc4a1f9ea88bc52341d4fd82764 /api/src/main | |
| parent | 2175a2b5de7a64026e119807443a9907dffd077b (diff) | |
| download | RoughlyEnoughItems-53e160bbfc5936d599b910b5adf06734c7123257.tar.gz RoughlyEnoughItems-53e160bbfc5936d599b910b5adf06734c7123257.tar.bz2 RoughlyEnoughItems-53e160bbfc5936d599b910b5adf06734c7123257.zip | |
Implement JEICatalystLookup and JEIRecipeCategoriesLookup, fixes #927 (#929) [ci skip]
Diffstat (limited to 'api/src/main')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java | 16 |
1 files changed, 16 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 f00f400c3..21e5401d0 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 @@ -138,6 +138,22 @@ public class CollectionUtils { } return l; } + + public static <T, R> Set<R> mapToSet(Collection<T> list, Function<T, R> function) { + Set<R> l = new HashSet<>(list.size() + 1); + for (T t : list) { + l.add(function.apply(t)); + } + return l; + } + + public static <T, R> Set<R> mapToSet(Iterable<T> list, Function<T, R> function) { + Set<R> l = new HashSet<>(); + for (T t : list) { + l.add(function.apply(t)); + } + return l; + } public static <T, R> List<R> mapIndexed(Iterable<T> list, IndexedFunction<T, R> function) { List<R> l = list instanceof Collection ? new ArrayList<>(((Collection<T>) list).size() + 1) : new ArrayList<>(); |
