Tag Info

New answers tagged


Iterating through a List is (slightly) slower than a plain array due to a few factors: Bounds checks: This is likely to be the biggest factor; every single indexer access to the List is going to do a bounds check. Bounds checking on a raw array can often be trivially optimized out of a loop by the JIT. Method call costs: The indexer on a List is a method ...


Thanks to @Kilian Foth I have a solution: [...] if you just want to collect all interval boundaries into a single list, uniquely sort it and then construct new intervals from every two values in the list. [...] Array of overlapping intervals: [ {0,7}, {8,12}, {13,17}, {0,3}, {4,9}, {10,17} ] Single list, uniquely sorted: ...

Top 50 recent answers are included