On Friday, 11 November 2016 at 13:33:20 UTC, Vladimir Panteleev
wrote:
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()));
It does work, the problem is that [1, 2, 3].sort() is of type
SortedRange(int[], "a < b") while r is of type
SortedRange(Result, "a < b"). This is a problem if you want to
return r in a function which has return type SortedRange(int[],
"a < b").