Adding minmaxElement to Phobos?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Sep 5 16:31:14 UTC 2019
On 9/5/19 12:12 AM, Per Nordlöw wrote:
> At
>
> https://stackoverflow.com/a/19954882/683710
>
> I just learned the reason for C++11 having
>
> https://en.cppreference.com/w/cpp/algorithm/minmax_element
>
> Calculating the min and max simultaneously reduces the number of
> comparisons with 1/4.
>
> Should we add a minmaxElement alongside minElement and maxElement?
Looks like enough of an principled algorithm to make a valid addition. I
think it was an interview question at Facebook at a point :o). (Hmmm...
I looked quickly over the C++ sample implementation in the link above
and it seems something is amiss.)
More information about the Digitalmars-d
mailing list