diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-17 16:45:00 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-17 16:45:00 +0800 |
| commit | 37ff3e5ecf9052c1690ff2475f27bc60a7ee36f3 (patch) | |
| tree | b3513d7463ba93bfa5ba580871ce5c09baea167b /api | |
| parent | 15b115f1675db77e7886330c920e0d9879553272 (diff) | |
| parent | 530c2b71410de0bd89d9dc992b09cac8c7078751 (diff) | |
| download | RoughlyEnoughItems-37ff3e5ecf9052c1690ff2475f27bc60a7ee36f3.tar.gz RoughlyEnoughItems-37ff3e5ecf9052c1690ff2475f27bc60a7ee36f3.tar.bz2 RoughlyEnoughItems-37ff3e5ecf9052c1690ff2475f27bc60a7ee36f3.zip | |
Merge remote-tracking branch 'origin/8.x-1.18.2' into feature/rei_8.3
Diffstat (limited to 'api')
| -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<>(); |
