On Friday, 11 November 2016 at 13:30:17 UTC, RazvanN wrote:
I am trying to concatenate 2 ranges of the same type
(SortedRange in my case). I have tried merge, join and chain,
but the problem is that the result is not an object of the type
of the initial ranges. For example:
1. If I use chain
On Friday, 11 November 2016 at 13:39:32 UTC, RazvanN wrote:
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
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
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()));
I am trying to concatenate 2 ranges of the same type (SortedRange
in my case). I have tried merge, join and chain, but the problem
is that the result is not an object of the type of the initial
ranges. For example:
1. If I use chain(r1, r2), the result will be an object of type
Result which