当前位置:网站首页>从List<Map>中截取指定的范围数据集合
从List<Map>中截取指定的范围数据集合
2022-07-23 05:48:00 【枯枫叶】
package com.sport.sportsfinetrackadminserver.common.utils;
import com.google.common.collect.Lists;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
/** * @author zdj * @version 1.0 * @date 2022/06/21 10:02 */
public class CollectUtils {
/** * 截取指定集合中的元素 * @param list 需要处理的集合 * @param interceptFactor 截取因子 * @return */
public static List<Map<String, Object>> truncateCollectByFactor(List<Map<String, Object>> list, int interceptFactor) {
List<Map<String, Object>> resultList = Lists.newArrayList();
if(CollectionUtils.isEmpty(list)){
return resultList;
}
if(interceptFactor >= list.size() || interceptFactor <= 0){
return list;
}
if(interceptFactor < list.size()){
return list.subList(0, interceptFactor);
}
return resultList;
}
}
使用:
// 取前10名
List<Map<String, Object>> resultList1 = CollectUtils.truncateCollectByFactor(resultList, 10);
边栏推荐
- Manually configure DHCP service
- NFS service deployment notes
- FTP experiment and overview
- FTP 配置实例学习记录
- harbor部署
- Gameframework: package resources, publish packages with the app, package and generate folder instructions, upload resources to the server, download resources, gamefreamworklist DAT and gameframeworkve
- Pod topology constraints
- C#输出斐波那契数列
- User and group management, file permissions
- 融e学答案脚本制作(2020最新)
猜你喜欢

雷达导论PART VII.1 雷达与分辨率

TI单芯片毫米波雷达代码走读(二十五)—— 角度维(3D)处理流程

Unity3d: script execution sequence on scene loading gameobejct

Unity used trilib plug-in under URP pipeline to load model material incorrectly

Gameframework: resource hot code analysis, check version information, download version files, verify version files, get the number of updated files, download files, taskpool

Secret key remote login server to realize secret free login

平方根立方根

RIP 配置实例学习记录

Plug ins used by Jenkins

Single arm routing configuration instance learning record
随机推荐
2020-09-22
Es common operations
HCIA----06 OSPF
Jupyter notebook添加已存在的虚拟环境
Build FRPC client in NAS [super brainless]
Hcip --- OSPF details
OSPF 单区域配置实例学习记录
Hcip --- condition matching and OSPF Protocol
ACL——net
STP 配置实例学习记录
Gameframework: resource hot code analysis, check version information, download version files, verify version files, get the number of updated files, download files, taskpool
Eth-Trunk 配置实例学习记录
FTP 配置实例学习记录
Hcia---03 ENSP usage, DHCP, router
0 dynamic programming leetcodde313. super ugly number
2020-10-16
Telnet 配置实例学习记录
Unity3d: script execution sequence on scene loading gameobejct
RIP 配置实例学习记录
踩坑electron渲染进程renderer,解决require is not defined的问题