sorting std.container
WhatMeWorry via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 11 22:05:20 PDT 2016
On Monday, 11 July 2016 at 19:07:51 UTC, ketmar wrote:
> list slices are not random-access ranges, thus they can't be
> sorted in-place (this is what std.algorithm.sort does). so the
> only way is to convert list to array, sort it, and make a list
> from sorted array. probably not something you want. ;-)
>
> this is common for any "traditional" linked list
> implementation: random access is very costly, thus even if it
> is implemented, it's better to not use it. SList and DList are
> "traditional" lists without any fancy algorithms inside (like
> finger trees or skip lists).
>
> you may want to use arrays instead (it is often more efficient
> anyway, especially if you don't need to insert elements in the
> middle of the array), or associative arrays.
If I may deviate from the discussion a bit,are there any real
world scenarios where the SList and DList (that is, "traditional"
linked lists) is superior to fixed, dynamic or associative arrays?
Or are lists more of a data type exercise?
More information about the Digitalmars-d-learn
mailing list