/***
     * 去除List<PartsInfoDTO>列表中的重复对象 ~!!
     * @param list
     * @return
     */
    public static List<PartsInfoDTO> removeDuplicate(List<PartsInfoDTO> list) {
//        Set<PartsInfoDTO> set = new HashSet<PartsInfoDTO>();
        List<PartsInfoDTO> newList = new ArrayList<PartsInfoDTO>();
        
        Map map = new HashMap();
        for (Iterator<PartsInfoDTO> iter = list.iterator(); iter.hasNext();) {
            PartsInfoDTO element = (PartsInfoDTO) iter.next();
            map.put(element.getId(), element); //如果id重复会覆盖.
        }
        
        Iterator it = map.keySet().iterator();   
        while (it.hasNext()) {   
           Integer key = (Integer) it.next();   
           newList.add((PartsInfoDTO) map.get(key));   
        }   

       return newList;
   }

 

相关文章:

  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案