/** * Checks to see whether the specified conformer is currently stored. * * This method first checks whether the title of the supplied molecule * matches the stored title. If not, it returns false. If the title matches * it then checks all the coordinates to see whether they match. If all * coordinates match it returns true else false. * * @param o The IAtomContainer to check for * @return true if it is present, false otherwise */ @Override public boolean contains(Object o) { return indexOf(o) != -1; }
/** * Checks to see whether the specified conformer is currently stored. * * This method first checks whether the title of the supplied molecule * matches the stored title. If not, it returns false. If the title matches * it then checks all the coordinates to see whether they match. If all * coordinates match it returns true else false. * * @param o The IAtomContainer to check for * @return true if it is present, false otherwise */ @Override public boolean contains(Object o) { return indexOf(o) != -1; }
/** * Remove the specified conformer. * * @param o The conformer to remove (should be castable to IAtomContainer) * @return true if the specified conformer was present and removed, false if not found */ @Override public boolean remove(Object o) { IAtomContainer atomContainer = (IAtomContainer) o; // we should never have a null conformer if (atomContainer == null) return false; int index = indexOf(atomContainer); if (index >= 0) { remove(index); return true; } return false; }
/** * Remove the specified conformer. * * @param o The conformer to remove (should be castable to IAtomContainer) * @return true if the specified conformer was present and removed, false if not found */ @Override public boolean remove(Object o) { IAtomContainer atomContainer = (IAtomContainer) o; // we should never have a null conformer if (atomContainer == null) return false; int index = indexOf(atomContainer); if (index >= 0) { remove(index); return true; } return false; }
@Test public void testIndexOf_IAtomContainer() { ConformerContainer container = new ConformerContainer(confs); IAtomContainer ac = container.get(2); int index = container.indexOf(ac); Assert.assertEquals(2, index); }
@Test public void testIndexOf_Object() { ConformerContainer container = new ConformerContainer(confs); Assert.assertNotNull(container); int counter = 0; for (IAtomContainer conf : confs) { Assert.assertEquals(counter, container.indexOf(conf)); counter++; } }
@Test public void testSet_int_Object() { ConformerContainer container = new ConformerContainer(confs); int location = 5; container.set(location, container.get(location + 1)); Assert.assertEquals(location, container.indexOf(container.get(location + 1))); }
@Test public void testSet_int_IAtomContainer() { ConformerContainer container = new ConformerContainer(confs); int location = 5; container.set(location, container.get(location + 1)); Assert.assertEquals(location, container.indexOf(container.get(location + 1))); }