Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AtomContainer Shallow Copy Behaviour
IAtomContainer a = new AtomContainer();
a.addAtom(new Atom("C"));
a.addAtom(new Atom("C"));
a.addBond(new Bond(a.getAtom(0), a.getAtom(1), SINGLE));
// copy constructor
IAtomContainer b = new AtomContainer(a);
b.removeAtom(0); // atom at index 0 is removed from b, a is not affected
b.getBond(0).setOrder(DOUBLE); // bond order is change in both a and b
b.getBond(0).addAtom(new Atom("H")); // as the bond is the same instance this is now
ITetrahedralChiralAtomParityEtc element = ...; // access stereo elements
element.setStereo(CLOCKWISE); // a,b both have stereo changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment