behaviour of find method.
Chris Dams
chrisd at sci.kun.nl
Mon Dec 23 18:39:00 CET 2002
Hello everybody,
I found out that the behaviour of the find method is not quite as
advertised in the tutorial. The tutorial says:
@example
bool ex::find(const ex & pattern, lst & found);
@end example
works a bit like @code{has()} but it doesn't stop upon finding the first
match. Instead, it appends all found matches to the specified list.
Appending means adding at the end. However, the code of the ex::find()
method includes the lines
if (match(pattern)) {
found.append(*this);
found.sort();
found.unique();
return true;
}
This sorts the found-list so that a match will most of the time not end up
at the end, not to mention what happens to any ordering of elements the
found list had before calling the find() method. I would guess that this
is because this implementation comes with potentially huge memory savings
at the cost of speed because of uniquing after every object found. If this
is the case, I can understand the implementation, but still the tutorial
should describe the true behaviour.
Groetjes,
Chris
More information about the GiNaC-list
mailing list