Hi all,
here is my problem. I have a list of data, sorted by dateStart :
index dateStart dateEnd value
[0] 2009-11-01 04:20 2009-11-01 05:40 5
[1] 2009-11-01 06:30 2009-11-01 08:42 10
[2] 2009-11-01 07:43 2009-11-01 16:12 0
[3] 2009-11-01 10:43 2009-11-01 14:34 -12
[4] 2009-11-01 12:34 2009-11-01 12:42 3
The final output that I want would be a subset from that list, where dateStart and dateEnd from 2 different items would never clash.
In the current example, I would start at [0] and keep it.
For [1], since its dateStart > [0].dateEnd, I would also keep it.
For [2], since its dateStart <= [1].dateEnd, I would discard it.
For [3], since its dateStart > [2].dateEnd, I would keep it.
For [4], since its dateStart <= [3].dateEnd, I would discard it.
and so on.
I would like to use LINQ (lamda preferred) for that, if possible.
Otherwise, I guess a standard for loop would do the trick.
Another interesting way of getting my final output would be to keep all the data, but add a flag to each item (bValid), that would indicate if the data is to be taken or not.
Thanks! p.s. sorry for Formatting, I tried my best (first post here)