Remove duplicates from list of object

后端 未结 5 1959
悲&欢浪女
悲&欢浪女 2021-01-20 11:52

I have MyObject with field: id, a, b, c, e, f and I have List with 500 000 items, now how can I remove all duplicate items with of the same value of the parameter a, c, f? <

5条回答
  •  情歌与酒
    2021-01-20 12:23

    One efficient method would be first to to a quicksort (or similar n Log n sort), based on a hash of (a, c, f) and then you can iterate through the resultant list, picking one every time the value of (a, c, f) changes.

    That would give a n log n speed solution, which is probably the best you can do.

提交回复
热议问题