码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-11-05 17:42:55      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:details   result   new   hash   contains   重复   过滤   add   span   

 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 去过滤元素是否重复

标签:details   result   new   hash   contains   重复   过滤   add   span   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!