Dynamic chain for ranges?
Steven Schveighoffer
schveiguy at gmail.com
Mon Jun 13 14:03:13 UTC 2022
On 6/13/22 9:44 AM, Ola Fosheim Grøstad wrote:
> On Monday, 13 June 2022 at 13:22:52 UTC, Steven Schveighoffer wrote:
>> I would think sort(joiner([arr1, arr2, arr3])) should work, but it's
>> not a random access range.
>
> Yes, I got the error «must satisfy the following constraint:
> isRandomAccessRange!Range`».
>
> It would be relatively easy to make it work as a random access range if
> arr1, arr2, etc were fixed size slices.
>
> Or I guess, use insertion-sort followed by merge-sort.
Merge sort only works if it's easy to manipulate the structure, like a
linked-list, or to build a new structure, like if you don't care about
allocating a new array every iteration.
-Steve
More information about the Digitalmars-d-learn
mailing list