From 774bceacf9a2ceb92aa5ac66a7bf81fcf03d28c0 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 28 Jun 2022 18:30:18 +0800 Subject: Fix compile issues, release REI 9.1 --- .../me/shedaniel/rei/api/common/util/CollectionUtils.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'api/src') 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 Set mapToSet(Collection list, Function function) { Set l = new HashSet<>(list.size() + 1); for (T t : list) { @@ -146,7 +146,7 @@ public class CollectionUtils { } return l; } - + public static Set mapToSet(Iterable list, Function function) { Set l = new HashSet<>(); for (T t : list) { @@ -349,6 +349,17 @@ public class CollectionUtils { return sum; } + public static List distinctToList(Iterable list) { + List newList = new ArrayList<>(); + Set set = new HashSet<>(); + for (T t : list) { + if (set.add(t)) { + newList.add(t); + } + } + return newList; + } + public static Iterable> partition(List list, int size) { return () -> new UnmodifiableIterator>() { int i = 0; -- cgit