U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » FIX FindBest in Algo.h
FIX FindBest in Algo.h [message #43456] Wed, 06 August 2014 16:56 Go to previous message
masu is currently offline  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
 
Read Message
Read Message
Previous Topic: Is XML compression possible by U++ library call?
Next Topic: HttpRequest : problem with multiple redirections ?
Goto Forum:
  


Current Time: Tue Jun 23 03:49:35 GMT+2 2026

Total time taken to generate the page: 0.00471 seconds