design question

dsimcha dsimcha at yahoo.com
Fri Apr 3 11:25:29 PDT 2009


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> I think the stability request could be better encoded as a wrapper of
> the range making the request. For example:
> auto p = partition!("(a & 1) == 0")(keepStable(arr));
> So in order to tell partition you want stability, you just wrap the
> range with a call to keepStable. (The runtime cost is negligible).
> Similarly, say you want a stable sort. You'd say:
> sort(keepStable(arr));
> instead of:
> sort!(SwapStrategy.stable)(arr);

Can you elaborate a little?  In particular, would the KeepStable wrapper actually _do_ anything in itself to
make modifications to the underlying range stable, or would it just wrap the range in a new type so that
you could stick a static if statement in the sort algorithm to decide what to?



More information about the Digitalmars-d mailing list