当前位置:网站首页>Intercept the specified range data set from list < map >
Intercept the specified range data set from list < map >
2022-07-23 13:10:00 【Withered maple leaf】
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 {
/** * Intercept the elements in the specified collection * @param list Set to be processed * @param interceptFactor Interception factor * @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;
}
}
Use :
// Take before 10 name
List<Map<String, Object>> resultList1 = CollectUtils.truncateCollectByFactor(resultList, 10);
边栏推荐
猜你喜欢
随机推荐
Prefix and leetcode2100. Suitable for bank robbery days
Make local apt source offline installation
HCIA----07 ACL-Net
Redis如何实现持久化?详细讲解RDB的三种触发机制及其优缺点,带你快速掌握RDB
方法区、永久代、元空间的关系
2020-09-22
Confused, work without motivation? Career development hopeless? It's enough to read this article
Rhcsa - - parcourir le contenu du fichier, couper, uniq, trier, utiliser les commandes.tr
C randomly generate a score to judge its grade (excellent, good, medium, poor, failed)
zabbix监控详细安装到部署
雷达导论PART VII.1 雷达与分辨率
Summary of basic SQL operations
User and group management, file permissions
Install LNMP service deployment using yum
yum安装LNMP服务部署
高压MOS管KNX42150 1500V/3A 应用于变频器电源-逆变器等
Telnet configuration instance learning record
常见的cmd命令快速打开程序
基于redis+lua进行限流
In the Internet era, how to refine user operations?









