On 11/10/11 1:39 PM, Chris Morley wrote: > On 10/11/2011 17:40, Igor Filippov [Contr] wrote: >> >>> The confusion caused by too much choice and the deficiencies in all of >>> the above mean that MolCore API (the proposed re-writing of the central >>> part of the toolkit) deserves better. I am pushing for no atom indexes >>> at all, and only one way for a user to reference an atom - a sort of >>> atom pointer which remains valid whatever you do to the molecule. It is >>> also an iterator that can be can be incremented in various interesting >>> ways. >> >> I don't want to be a naysayer but I think it's a horrible idea. >> I've had numerous problems with the current implementation of atom/bond >> iterators, if they are going to remain the only way to loop through >> atoms/bonds it will be very difficult if not impossible to manipulate >> OBMol to the degree that I need.
What's the harm in allowing array access? I don't see how it complicates the API. It's just a matter of good documentation and nice example programs to illustrate proper use. Arrays are one of the oldest and still one of the best data structures in computer science for two simple reasons: they're extremely fast, and they're easy to use. They're fast because the architecture of modern CPUs supports offset operations at the nanosecond time scale, and they're easy to use because it's a simple data structure. Algorithms that manipulate a molecular graph often have to access atoms with O(N^2) and sometimes higher-order loops. These loops often don't access the atoms sequentially, so an iterator is useless. By eliminating direct indexing, you're just forcing programmers to waste valuable CPU cycles building their own arrays and using an iterator to fill those arrays. That's a huge waste of CPU cycles and will dramatically slow OpenBabel's performance, especially considering that somewhere under the covers the atoms and bonds are probably in an array already. The only thing wrong with the original atom IDX was that it started with 1 instead of zero. That's fixed now, and hopefully the old 1-based index will be deprecated at some point. Craig ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel