使用场景,地图加载人员历史轨迹数据,如果里面夹杂重复的时间,会导致地图轨迹加载卡顿,解决办法也很简单,就是根据时间去重,重复时间只保留一份数据。
List<TrackHistory> newList = trackHistoryLists.stream().collect(
CollectionAndThen(Collectors.toCollection() -> new TreeSet<TrackHistory>(Comparator.comparing(TrackHistory::getTrackTime))),ArrayList::new);
根据TrackHistory对象的trackTime属性去重