Timeline for C# - fastest way of comparing a collection against itself to find duplicates
Current License: CC BY-SA 3.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 26, 2016 at 16:24 | vote | accept | Bob Tway | ||
May 26, 2016 at 15:25 | answer | added | Matthew Watson | timeline score: 2 | |
May 26, 2016 at 15:00 | answer | added | Pradeep Kumar | timeline score: 0 | |
May 26, 2016 at 14:55 | answer | added | dotNET | timeline score: 1 | |
May 26, 2016 at 14:54 | answer | added | Steve | timeline score: 1 | |
May 26, 2016 at 14:53 | history | edited | Bob Tway | CC BY-SA 3.0 |
added 1 character in body
|
May 26, 2016 at 14:46 | answer | added | Ivan Yurchenko | timeline score: 13 | |
May 26, 2016 at 14:44 | comment | added | Bob Tway | @dotNET It also gets marked as a duplicate. One, and one only, record with a given TestValue should come out without the marker. | |
May 26, 2016 at 14:43 | comment | added | Bob Tway | @Luaan thanks for looking - have provided more information for you, as requested. | |
May 26, 2016 at 14:43 | history | edited | Bob Tway | CC BY-SA 3.0 |
added 572 characters in body
|
May 26, 2016 at 14:42 | comment | added | Murray Foxcroft | Generally I find this needs a few approaches and then a bit of bench marking to find the best. How does a SortedList stack up - then it's just a case of comparing the second item to the first ans so on and doing a single pass through the list. | |
May 26, 2016 at 14:41 | comment | added | dotNET |
What happens if there's a 3rd Matt in the list?
|
|
May 26, 2016 at 14:39 | comment | added | Luaan |
What is the meaning of the duplicates? Does that mean that you want to preserve order and that order is important for further processing of the collection? What happens with the collection after you mark the duplicates? How are you going to work with those duplicates? Have you considered having a separate HashSet just for the duplicate checking, e.g. when you add a new item, you check if it's already in the HashSet , and if it is, you mark it as duplicate immediately?
|
|
May 26, 2016 at 14:36 | history | edited | Bob Tway | CC BY-SA 3.0 |
edited body
|
May 26, 2016 at 14:36 | comment | added | Bob Tway | @Nasreddine hastily scribbled pseudocode :) And yes, I need to keep duplicates and mark them. | |
May 26, 2016 at 14:35 | comment | added | Draken | I was thinking the same @Anatolyevich, however it doesn't allow the collection to contain the duplicate and mark the duplicates. I'm assuming that is what the OP wanted. | |
May 26, 2016 at 14:34 | comment | added | Anatolyevich | I'm not sure if it's the case, but if you just need distinct TestObject entities, then use HashSet. It will serve you the best as it's made to contain only unique instances of specific type. | |
May 26, 2016 at 14:30 | history | asked | Bob Tway | CC BY-SA 3.0 |