当前位置:网站首页>从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);
边栏推荐
- C#随机生成一个分数,判断其成绩等级(优、良、中、差、不及格)
- 静态路由原理与配置
- jenkins部署
- Tar, SFTP, fin, history commands, variables, aliases
- Unity3d: vector calculation, AOE graph intersection
- vlan配置实例学习记录
- harbor部署
- 录入数学公式至mark down文档的方法
- Frame relay network configuration example learning record
- Three layer switching configuration example learning record
猜你喜欢

HCIA----06 OSPF

Matplotlib-实现常见概率分布

雷达导论PART VII.3 SAR图像的形成和处理

FTP configuration instance learning record

动态RIP配置

ACL 配置实例学习记录

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

Ronge answer script production (latest in 2020)

Unity3d:assetbundle simulation loading, synchronous loading, asynchronous loading, dependent package loading, automatic labeling, AB browser, incremental packaging

C #: quick sort. If there is the same number, it will be ignored, and then continue the previous search direction to find the next number that meets the requirements for replacement
随机推荐
Three layer switching configuration example learning record
ACL access control experiment
4D毫米波雷达硬件系统架构
2020-09-22
SAR成像之点目标仿真(二)—— Matlab仿真
Rk3588 compilation problem set
Summary of basic SQL operations
C language can also write Plants vs. Zombies
MIMO雷达专题(〇)—— 总章
ACL访问控制实验
Jupyter notebook添加已存在的虚拟环境
RHCSA--文件内容浏览、cut、uniq、sort、.tr命令使用
FTP deployment
SFTP deployment configuration
静态路由的搭建
RIP 配置实例学习记录
融e学答案脚本制作(2020最新)
[untitled]
TI单芯片毫米波雷达1642代码走读(〇)——总纲
帧中继网配置实例学习记录