当前位置:网站首页>对象集合去重的方法
对象集合去重的方法
2022-07-31 00:00:00 【EntyIU】
有的时候我们有这样的需求,在一个集合中有几个对象的数据是重复的,我们只想取不重复的那几个,可以通过以下方法去做
//这里讲述的是通过tDeptId这个字段去重
private static <T> Predicate<T> distinctByVariable(Function<? super T, ?> keyExtractor){
HashMap<Object, Boolean> map = new HashMap<>();
return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
public HttpResult updateUserInfo(@RequestBody UpdateUserParam updateUserParam) {
List<UpdateDeptCheckParam> collect3 = collect.stream().filter(distinctByVariable(u -> u.getDeptId())).collect(Collectors.toList());
}
边栏推荐
- proemthues 服务发现配置
- H5跳转微信公众号解决方案
- 46.<list链表的举列>
- 360核心安全大脑3.0正式发布,构建政企用户的“能力中枢平台”
- 常用的正则表达式
- 在微服务中使用事件溯源的六大原因 - Herath
- background对float的子元素无效
- Debezium error series 20: task failed to create new topic. Ensure that the task is authorized to create topics
- Chevrolet Trailblazer, the first choice for safety and warmth for your family travel
- xss靶机训练【实现弹窗即成功】
猜你喜欢

递增三元组

【LeetCode】42. 接雨水 - Go 语言题解

Encapsulate and obtain system user information, roles and permission control

xss绕过:prompt(1)

Shell programming conditional statement test command Integer value, string comparison Logical test File test

ctfshow 文件包含

In MySQL, the stored procedure cannot realize the problem of migrating and copying the data in the table
![[0x800706D9] solution appears in Microsoft Store](/img/f2/7485cd55fd260220378acd485d8dc9.png)
[0x800706D9] solution appears in Microsoft Store

如何在WordPress网站上添加导航菜单

vscode上利用screen命令跑代码
随机推荐
【LeetCode】55. 跳跃游戏 - Go 语言题解
HashSet源码解析
Installation considerations for pytorch
【飞控开发基础教程10】疯壳·开源编队无人机-PID 基础原理
Calico 网络通信原理揭秘
Android security optimization - APP reinforcement
How to install joiplay emulator rtp
数据清洗-使用es的ingest
46.
MPI简谈
Data cleaning - ingest using es
joiplay模拟器不支持此游戏类型怎么解决
uni-ui installation
Mysql体系化之JOIN运算实例分析
Axure Carousel
After writing business code for many years, I found these 11 doorways, which only experts know
Soft Exam Study Plan
joiplay模拟器如何使用
How to ensure the consistency of database and cache data?
jira是什么