Hi,
I just wanted to point you to a (possible) problem when looping over TCandList and removing candidates of this list within the loop.
It seems at some places in macro/run/..., a routine similar to the following one is used:
int n_removed=0, i=0;
for (l=0; l<list.GetLength(); ++l)
{
i = l-n_removed;
if( ... Some criterion ...)
{
list.Remove( list[i] );
n_removed++;
}
}
This actually does not work properly, since it doesn't take into account, that the quantity 'list.GetLength()' is changed by the removal process.
It can be fixed by replacing
for (l=0; l<list.GetLength(); ++l)
by
int nl = list.GetLength();
for (l=0; l<nl; ++l)
At least for me, this worked correctly afterwards. The safest thing of course is to do something like
TCandList newlist;
for (l=0; l<list.GetLength(); ++l)
{
if( ... the OPPOSITE criterion ...) )
newlist.Put( list[i] );
}
list=newlist;
In case you used the first kind of construction in one of your analysis studies, you should check your results.
Best regards,
Klaus
[Updated on: Fri, 19 April 2013 12:36] by Moderator
Report message to a moderator