java List removeAll 慢

 

之前 

odmComponentPlatformListCopy.removeAll(componentPlatformListCopy);

 

由于2个list都有100多万 非常慢  几个小时

 

改为

 

odmComponentPlatformListCopy.removeAll(new HashSet<>(componentPlatformListCopy));

 

几秒钟就完成了,list的泛型对象需要实现hashcode和equals方法

posted @ 2023-08-16 18:03  kuroniko  阅读(78)  评论(0编辑  收藏  举报