/** * Returns the position of a given lone pair in the lone pair array. * It returns -1 if the lone pair does not exist. * *@param lonePair The lone pair to be sought *@return The Position of the lone pair in the array.. */ @Override public int getLonePairNumber(ILonePair lonePair) { return indexOf(lonePair); }
/** * Returns the position of a given atom in the atoms array. It returns -1 if * the atom does not exist. * *@param atom The atom to be sought *@return The Position of the atom in the atoms array in [0,..]. */ @Override public int getAtomNumber(IAtom atom) { return indexOf(atom); }
/** * Returns the position of a given bond in the electronContainers array. It * returns -1 if the bond does not exist. * *@param bond The bond to be sought *@return The Position of the bond in the electronContainers array in [0,..]. */ @Override public int getBondNumber(IBond bond) { return indexOf(bond); }
/** * Returns the position of a given single electron in the single electron array. * It returns -1 if the single electron does not exist. * *@param singleElectron The single electron to be sought *@return The Position of the single electron in the array. */ @Override public int getSingleElectronNumber(ISingleElectron singleElectron) { return indexOf(singleElectron); }
/** * Removes the lone pair from the AtomContainer. * *@param lonePair The LonePair to be removed. */ @Override public void removeLonePair(ILonePair lonePair) { int pos = indexOf(lonePair); if (pos != -1) removeLonePair(pos); }
/** * Removes the single electron from the AtomContainer. * *@param singleElectron The SingleElectron to be removed. */ @Override public void removeSingleElectron(ISingleElectron singleElectron) { int pos = indexOf(singleElectron); if (pos != -1) removeSingleElectron(pos); }
/** * Returns the position of the bond between two given atoms in the * electronContainers array. It returns -1 if the bond does not exist. * *@param atom1 The first atom *@param atom2 The second atom *@return The Position of the bond between a1 and a2 in the * electronContainers array. */ @Override public int getBondNumber(IAtom atom1, IAtom atom2) { return indexOf(getBond(atom1, atom2)); }
/** * Removes the bond that connects the two given atoms. * * @param atom1 The first atom * @param atom2 The second atom * @return The bond that connects the two atoms */ @Override public IBond removeBond(IAtom atom1, IAtom atom2) { int pos = indexOf(getBond(atom1, atom2)); IBond bond = null; if (pos != -1) { bond = bonds[pos]; removeBond(pos); } return bond; }
if (idx >= atomCount) throw new IndexOutOfBoundsException("No atom at index: " + idx); int aidx = indexOf(atom); if (aidx >= 0) throw new IllegalArgumentException("Atom already in container at index: " + idx);