|
I have two SftpItemCollection objects. I need to compare them (based on file name, size and modified date) and extract the items that exists on both. Ex:
SftpItemCollection 1 SftpItemCollection 2 I need SftpItem 1 from SftpItemCollection 1 as the final result. This is essentially the Enumerable.Intersect functionality in .net. link:Enumerable.Intersect What options do I have? Thanks. |
|
To use the Linq Intersect functionality you have to implement your own
If you cannot use Linq, implement your own
Thanks, Lukas. With respect to the second solution, I am worried about the performance, since it is a linear (and not a binary) look up. I am not sure about Linq Intersect method in terms of performance. These are definitely good options. On a side note, it would be nice if Rebex implemented/supported binary look up/search natively in the SftpItemCollection class.
(03 Oct '11, 18:08)
AdvStpDev
|
|
You don't have to be worried about the performance. Please note, the If the performance has to be taken into consideration I suggest you one optimization of the second solution. The optimal approach of the Intersect problem on unsorted collection runs in O(n) = Linear time complexity. But in real life it matter whether the 'n' is 3 or 3000. The second algorithm iterates over the
To make a picture about the Linq Please note the Linq Thanks again Lukas. I like the non-linq approach. I didn’t realize the “SftpItemCollection behaves like an associative array” when I initially eplied. This is really helpful. I appreciate it!
(05 Oct '11, 00:19)
AdvStpDev
|