Last active
August 29, 2015 14:07
-
-
Save johnmay/c95a443392816ea9b15a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Map<AtomPair,IBond> bondMap = new HashMap<>(); | |
| for (IBond bond : container.bonds()) | |
| bondMap.put(new AtomPair(bond.getAtom(0), bond.getAtom(1)), | |
| bond); | |
| class AtomPair { | |
| IAtom a, b; | |
| AtomPair(IAtom a, IAtom b) { | |
| this.a = a, this.b = b; | |
| } | |
| public int hashCode() { | |
| return a.hashCode() ^ b.hashCode(); | |
| } | |
| public boolean equals(Object obj) { | |
| // null check etc | |
| AtomPair that = (AtomPair) obj; | |
| return this.a.equals(that.a) && this.b.equal(that.b) || this.a.equals(that.b) && this.b.equal(that.a); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment