Ranges & containers : is it possible to get a SortedRange from a RedBlackTree ?
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 7 12:36:40 PDT 2014
On Monday, 7 July 2014 at 19:20:24 UTC, Fr wrote:
> It's in the example above :
>
> SortedRange!(MyObject[]) opSlice() {
> sequence[].array.assumeSorted; }
>
> I thought that that using ".array" would lead to instantiating
> something.
Yes, this *will* instantiate an array and copy all of the items
from the RedBlackTree into it. There's not really a way around it
(unless you upgrade to 2.066 so assumeSorted will accept the
result of sequence[] without having the intermediate array).
More information about the Digitalmars-d-learn
mailing list