MapUtil增加partition方法

This commit is contained in:
Looly 2024-02-07 11:24:44 +08:00
parent 56e7b1d5c6
commit 44580782f1
2 changed files with 32 additions and 32 deletions

View File

@ -2,10 +2,11 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.26(2024-02-03)
# 5.8.26(2024-02-07)
### 🐣新特性
* 【db 】 RedisDS增加user支持issue#I8XEQ4@Gitee
* 【core 】 MapUtil增加partition方法pr#1170@Gitee
### 🐞Bug修复
* 【crypto】 修复BouncyCastleProvider导致graalvm应用报错UnsupportedFeatureErrorpr#3464@Github

View File

@ -3,10 +3,7 @@ package cn.hutool.core.map;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.lang.Editor;
import cn.hutool.core.lang.Filter;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.lang.*;
import cn.hutool.core.stream.CollectorUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.JdkUtil;
@ -1523,14 +1520,16 @@ public class MapUtil {
/**
* 将一个Map按照固定大小拆分成多个子Map
*
* @param <K> 键类型
* @param <V> 值类型
* @param map Map
* @param size 子Map的大小
* @return 子Map列表
* @since 5.8.26
*/
public static <K, V> List<Map<K, V>> partition(Map<K, V> map, int size) {
if (map == null) {
throw new NullPointerException("Map must not be null");
} else if (size <= 0) {
Assert.notNull(map);
if (size <= 0) {
throw new IllegalArgumentException("Size must be greater than 0");
}
List<Map<K, V>> list = new ArrayList<>();