diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-10-26 10:49:27 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-10-29 14:02:27 +0800 |
| commit | 9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc (patch) | |
| tree | b4db2569bc4a90d7bb835ff451fe5e11e86e8968 /RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java | |
| parent | b7f8fc61dcaa6d202809651d46cf0946b63beef7 (diff) | |
| download | RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.tar.gz RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.tar.bz2 RoughlyEnoughItems-9ea4a22e9a194fd8fdc2fb03226ab38ee175a6cc.zip | |
Favorites Dragging
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java')
| -rw-r--r-- | RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java index 1060a6bdc..fd4cac467 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/utils/CollectionUtils.java @@ -26,15 +26,15 @@ package me.shedaniel.rei.utils; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.collect.UnmodifiableIterator; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; import me.shedaniel.rei.api.EntryStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.util.Mth; import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; +import java.util.function.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -162,6 +162,14 @@ public class CollectionUtils { return l; } + public static <T> IntList mapToInt(Collection<T> list, ToIntFunction<T> function) { + IntList l = new IntArrayList(list.size() + 1); + for (T t : list) { + l.add(function.applyAsInt(t)); + } + return l; + } + public static <T, R> List<R> mapParallel(Collection<T> list, Function<T, R> function) { return list.parallelStream().map(function).collect(Collectors.toList()); } |
