Dear Toby, On Tue, Oct 9, 2012 at 4:44 PM, Toby Wright <toby.wri...@inhibox.com> wrote: > > Working in C++, I am calling ForwardsSDMolSupplier's method "atEnd()", > expecting that it returns false if there are more molecules and true > if there are no more molecules. As such the line: while > (!molSupplier->atEnd()) ought to be the obvious looping test with > molSupplier->next() providing the molecules, one per loop. Sadly it > seems that atEnd doesn't work. For example if I have a file with 2 > molecules in it, the loop executes 3 times. On the first 2 "next()" > provides me with the correct molecule. On the third "next()" returns > NULL. Then when the loop test is checked for a fourth time atEnd() > returns true. > > I can work around this very easily so there is no urgency from me, > just thought I should make the bug known. Below is code in full that > demonstrates the problem.
Thanks for raising it. This is a known characteristic of the ForwardSDMolSupplier. This supplier does not do a look-ahead at the end of the molecule, so if there's a blank line after the last molecule, the supplier has no way of knowing the file is actually at the end until you try to read the next molecule. Fixing this requires adding a cache to the supplier so that it can do look-ahead. This is doable (and would help address the outstanding feature request to have a getLastItemText method on ForwardSDMolSuppliers. -greg ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss