diff options
| author | shedaniel <daniel@shedaniel.me> | 2022-06-28 18:30:18 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2022-06-28 18:30:18 +0800 |
| commit | 774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0 (patch) | |
| tree | a63ef2990912692180071015ce5df88ddfecac4d /api/src/main/java/me/shedaniel | |
| parent | c053118665dbffa9ddc6d147530edf0badf6fc60 (diff) | |
| download | RoughlyEnoughItems-774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0.tar.gz RoughlyEnoughItems-774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0.tar.bz2 RoughlyEnoughItems-774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0.zip | |
Fix compile issues, release REI 9.1
Diffstat (limited to 'api/src/main/java/me/shedaniel')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java | 15 |
1 files changed, 13 insertions, 2 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 21e5401d0..44bb9da1f 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,7 +138,7 @@ 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) { @@ -146,7 +146,7 @@ public class CollectionUtils { } 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) { @@ -349,6 +349,17 @@ public class CollectionUtils { return sum; } + public static <T> List<T> distinctToList(Iterable<T> list) { + List<T> newList = new ArrayList<>(); + Set<T> set = new HashSet<>(); + for (T t : list) { + if (set.add(t)) { + newList.add(t); + } + } + return newList; + } + public static <T> Iterable<List<T>> partition(List<T> list, int size) { return () -> new UnmodifiableIterator<List<T>>() { int i = 0; |
