Home » U++ Library support » U++ Core » FIX FindBest in Algo.h
FIX FindBest in Algo.h [message #43456] |
Wed, 06 August 2014 16:56  |
masu
Messages: 378 Registered: February 2006
|
Senior Member |
|
|
Hi,
I took a look into Algo.h especially the Min and Max functions.
Both functions call FindBest (starting at line 64) which I think should be fixed, because it does not respect its pos and count parameters appropriately.
Here is the fix:
template <class C, class Pred>
int FindBest(const C& c, int pos, int count, const Pred& pred)
{
===> if(c.GetCount() == 0)
return -1;
typename C::ValueType m = c[pos];
int mi = pos;
===> for(int i = pos+1; i < count; i++)
if(pred(c[i], m)) {
m = c[i];
mi = i;
}
return mi;
}
Regards
Matthias
931b81e7ea53320dccc37375b34b38c3
|
|
|
|
Goto Forum:
Current Time: Sun May 11 14:32:45 CEST 2025
Total time taken to generate the page: 0.02831 seconds
|