I have the following scenario. I have two collections, one has some items missing. What collection type would be the quickest to find the missing items and insert them?
+5
A:
HashSet is your friend: http://msdn.microsoft.com/en-us/library/bb359438.aspx
Scordo
2010-08-20 14:23:22
Without knowing more, I don't believe you can say this. The performance of different colleciton types depends, amongst other things, on the number of items in them. Your HashSet will not outperform my List for a small number of items :)
Rob Levine
2010-08-20 14:24:58
For a small number of items the performance is not an issue. I dont think he's asking for a 10 item collection ;)
Scordo
2010-08-20 14:27:30
I have no information on the size of the collection; the OP didn't specify. The performance may not be an issue if you perform the operation once, but we don't know how often it is to be performed; it could be many times back-to-back. In fact, we know very little from the question, hence me being a but nit-picky about specific answers.
Rob Levine
2010-08-20 14:31:24
It's ok, the input is not as much as to start discussions on who is right :-D
Scordo
2010-08-20 14:33:29
+2
A:
You may want to take a look into HashSet which has a method called UnionWith.
Alfred Myers
2010-08-20 14:24:23