首页 > 其他 > 详细

利用 HashSet 去过滤元素是否重复

时间:2016-11-05 17:41:55      阅读:124      评论:0      收藏:0      [点我收藏+]
 1      HashSet<Integer> hashSet = new HashSet<Integer>();
 2         for (int i = resultDoctorDetails.size() - 1; i >= 0; --i) {
 3             ResultDoctorDetail temp = resultDoctorDetails.get(i);
 4             if (!hashSet.contains(temp.getUserId())) {
 5                 hashSet.add(temp.getUserId());
 6             } else {
 7                 resultDoctorDetails.remove(i);
 8             }
 9         }

 

利用 HashSet 去过滤元素是否重复

原文:http://www.cnblogs.com/xjbBill/p/5884200.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!