Skip to content

Instantly share code, notes, and snippets.

@johnmay
Created November 23, 2012 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmay/4136504 to your computer and use it in GitHub Desktop.
Save johnmay/4136504 to your computer and use it in GitHub Desktop.
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