findNext vs. findFirst

User f5e6ccf034

26-05-2008 04:29:51

In MolPrinter I don't understand why a findFirst method is needed and what it does: why would you make a distinction between the first vs. the other matches? Does that mean that


Code:



   int[] hits;


   while ((hits = s.findNext()) != null)


         doStuff(hits)





somehow will not work?

ChemAxon a3d59b832c

26-05-2008 14:06:17

Yes, it would work, findNext() does the search initialization if needed.





The difference is that findFirst() always re-initializes the search. (So if you want to re-start the enumeration of the hits, you need to use findFirst() instead of findNext().)





Best regards,


Szabolcs

User f5e6ccf034

26-05-2008 15:09:12

OK. A restartable iterator is neat indeed. That should be added to the findFirst javadocs.

ChemAxon a3d59b832c

29-05-2008 09:07:47

OK, I made it explicit in the javadocs for the next releases.





Thanks!


Szabolcs