I have a list <> of class "region" with two variables: "startLocation" and "endLocation". I would like to combine these two into a new sorted 2-dimensional array, where its fair location and integer representing its beginning or end.
For example, if there are three objects in the list with
[Region 1]: startLocation = 5, endLocation = 7
[Region 2]: startLocation = 3, endLocation = 5
[Region 3]: startLocation = 8, endLocation = 9
I would like to get a sorted two-dimensional array (either a list or similar) similar to:
[3] [1]
[5] [1]
[5] [-1]
[7] [-1]
[8] [1]
[9] [-1]
(it is desirable that the coincidences add their two values โโtogether, so two separate 5 in the array will be combined in [5 0] ... but this is not too important)
I am currently using the usual forloop, going through each one at a time and adding them to the list one at a time. This implementation is rather slow because I work with large data sets, and I assume that there is a more elegant / fast way to do this through LINQ.
Any suggestions would be highly appreciated.
c # linq
Dark amgine
source share