Creating a Sub-view of a non - RA (hasSlicing) range.

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jun 30 07:25:05 PDT 2012


On 6/30/12 9:15 AM, Dmitry Olshansky wrote:
> On 30-Jun-12 15:35, Tobias Pankrath wrote:
>>> Say I have a forward range (for example, an SList[]). I would like to
>>> create a new range containing only the first 5 elements of that old
>>> range. How can I do that?
>>>
>>
>> std.algorithm.take.
>>
>> But I would generally avoid SList.
>
> Indeed. I'd be hard pressed to devise realistic use case where it
> performs better.

Singly-linked lists are frequently used with lock-free algorithms. 
Generally it's simplistic to compare slists with arrays as to "which 
performs better" because they have different primitives.

Andrei


More information about the Digitalmars-d mailing list