菜单
登录注册
欢 迎
登录
自动登录
忘记密码?
新朋友
注册
注册
老朋友
登录
笔记内容为空!
TA的笔记树 >>
java集合处理工具类
Java工具类
``` import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Function; /** * @author vanki * @date 2019-05-07 16:11 */ public class CollectionUtil { /** * 集合数据分批处理 * * @param
* @param list 集合数据源 * @param onceMaxSize 每批处理最大数据量 * @param handler 业务处理 * * @return */ public static
List
listLimitSizeHandle(final List
list, int onceMaxSize, final Function
, R> handler) { if (list.isEmpty() || handler == null) { return Collections.EMPTY_LIST; } final int size = list.size(); onceMaxSize = onceMaxSize <= 0 ? size : onceMaxSize; List
results = new ArrayList<>((size / onceMaxSize) * 2); int fromIndex = 0; int toIndex = onceMaxSize; List
subList; do { if (toIndex > size) { toIndex = size; } if (fromIndex >= toIndex) { break; } subList = list.subList(fromIndex, toIndex); if (subList.isEmpty()) { break; } results.add(handler.apply(subList)); if (subList.size() < onceMaxSize) { break; } fromIndex = toIndex; toIndex += onceMaxSize; } while (true); return results; } } ```
vanki
祈愿万家灯火熨烫过脉络,刀山与火海多深刻,都陪你渡过。
浏览:
4597
创建:
2019-05-07 16:19:16
更新:
2019-05-07 16:58:06
TA的最新笔记
spring-boot配置redis多数据源
linux源修改(阿里)
python安装postgresql依赖
arthas使用
java基于spring的NamedParameterJdbcTemplate封装的获取sql工具类
Impala添加负载
S3常用使用
redis常用操作
hdfs相关命令
crontab使用
TA的最热笔记
java异步http请求工具类(org.asynchttpclient)
iTerm2主题配置与常用技巧
java基于spring.redisTemplate实现分布式锁工具类
Kotlin + SpringBoot + JPA(Hibernate) + Repository自定义方法
IDEA汉化
Sequel Pro连接mysql8打开数据库报错
centos-Hadoop2.7.3完全分布式搭建(HA)
SpringBoot上传文件报错(The temporary upload location [..] is not valid)
mac常用软件
kotlin对象属性值拷贝工具类