I have a list<> of an "region" class with two variables, "startLocation" and "endLocation". I'd like to combine those two into a new sorted 2 dimensional array where its just Location and an integer representing whether its start or an end.
For example, if the list has three region objects with
[Region 1] : startLocation = 5, endLocation = 7
[Region 2] : startLocation = 3, endLocation = 5
[Region 3] : startLocation = 8, endLocation = 9
I'd like to get a sorted two dimensional array (or list or similar) looking like:
[3] [1]
[5] [1]
[5] [-1]
[7] [-1]
[8] [1]
[9] [-1]
(preferably i'd like the overlaps to add their second values together, so the two separate 5's in the array would be combined into [5 0]...but that's not too important)
I'm currently using a regular forloop going through each one by one and adding them to a list one at a time. This implementation is quite slow because I'm working with large datasets, and I'm guessing there's a more elegant / faster way to accomplish this through LINQ.
Any suggestions would be much appreciated.