On Friday, 11 November 2016 at 13:30:17 UTC, RazvanN wrote:
I know that I can use the .array property, but I think that this iterates through all of my elements. Using assumeSorted(chain(r1, r2).array) will return a SortedRange, but I am not sure what the complexity for this operation is.

.array allocates, so it's going to be O(n), but the allocation will probably be more expensive.

Is there a way to concatenate 2 ranges (SortedRange in my case) in O(1) time?

assumeSorted(chain(a, b)) ?

This works for me:

auto r = assumeSorted(chain([1, 2, 3].sort(), [1, 2, 3].sort()));

Reply via email to