diff options
| author | Max <maxh2709@gmail.com> | 2022-06-17 10:39:38 +0200 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-17 16:40:09 +0800 |
| commit | 530c2b71410de0bd89d9dc992b09cac8c7078751 (patch) | |
| tree | 7005128cb0ec7d7c224443a0109b521d94490588 /api/src/main/java | |
| parent | 81fe954ffee1b4976c6fb1e385348f8af535b113 (diff) | |
| download | RoughlyEnoughItems-530c2b71410de0bd89d9dc992b09cac8c7078751.tar.gz RoughlyEnoughItems-530c2b71410de0bd89d9dc992b09cac8c7078751.tar.bz2 RoughlyEnoughItems-530c2b71410de0bd89d9dc992b09cac8c7078751.zip | |
Implement JEICatalystLookup and JEIRecipeCategoriesLookup, fixes #927 (#929) [ci skip]
Diffstat (limited to 'api/src/main/java')
| -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 a478ee693..7a6c3a285 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<>(); |
