Performance optimization for minElement and maxElement
Sergey
kornburn at yandex.ru
Mon Sep 12 11:53:34 UTC 2022
On Monday, 12 September 2022 at 11:46:23 UTC, Ali Çehreli wrote:
> On 9/12/22 04:07, H. S. Teoh wrote:
> > On Sun, Sep 11, 2022 at 07:40:35PM -0700, Ali Çehreli via
> Digitalmars-d wrote:
> >> Since the minimum and maximum values of fundamental types
> are known, can
> >> minElement and maxElement shortcut and return that value
> immediately?
> >
> > No, because that value may not appear in the given range.
> >
> >
> > T
>
> I am not that silly. :) What I meant is "as soon as they see
> e.g. 0". Say, at the third element of a million-element range...
>
> Ali
In case zero will be the last element - the search should make an
extra comparisons “if currentElement = T.minimum” which double
operations..
Isn’t it?
More information about the Digitalmars-d
mailing list