@Override public int hashCode() { return deref().hashCode(); }
private void addToEndpoints(BaseBondRef bondref) { if (bondref.getAtomCount() == 2) { BaseAtomRef beg = getAtomRef(bondref.getBegin()); BaseAtomRef end = getAtomRef(bondref.getEnd()); beg.bonds.add(bondref); end.bonds.add(bondref); } else { for (int i = 0; i < bondref.getAtomCount(); i++) { getAtomRef(bondref.getAtom(i)).bonds.add(bondref); } } }
if (!bonds[i].contains(atom)) { bonds[newNumBonds] = bonds[i]; bonds[newNumBonds].setIndex(newNumBonds); newNumBonds++; } else { bonds[i].removeListener(this); delFromEndpoints(bonds[i]);
if (!bonds[i].contains(atom)) { bonds[newNumBonds] = bonds[i]; bonds[newNumBonds].setIndex(newNumBonds); newNumBonds++; } else { bonds[i].removeListener(this); delFromEndpoints(bonds[i]);
/** * {@inheritDoc} */ @Override public void setBonds(IBond[] newbonds) { // replace existing bonds to clear their adjacency if (numBonds > 0) { clearAdjacency(); } ensureBondCapacity(newbonds.length); for (int i = 0; i < newbonds.length; i++) { BaseBondRef bondRef = newBondRef(newbonds[i]); bondRef.setIndex(i); addToEndpoints(bondRef); if (bonds[i] != null) bonds[i].removeListener(this); bonds[i] = bondRef; bondRef.addListener(this); } // null-fill if (newbonds.length < numBonds) { for (int i = newbonds.length; i < numBonds; i++) bonds[i].removeListener(this); Arrays.fill(this.bonds, newbonds.length, numBonds, null); } numBonds = newbonds.length; notifyChanged(); }
/** * {@inheritDoc} */ @Override public void setBonds(IBond[] newbonds) { // replace existing bonds to clear their adjacency if (numBonds > 0) { clearAdjacency(); } ensureBondCapacity(newbonds.length); for (int i = 0; i < newbonds.length; i++) { BaseBondRef bondRef = newBondRef(newbonds[i]); bondRef.setIndex(i); addToEndpoints(bondRef); if (bonds[i] != null) bonds[i].removeListener(this); bonds[i] = bondRef; bondRef.addListener(this); } // null-fill if (newbonds.length < numBonds) { for (int i = newbonds.length; i < numBonds; i++) bonds[i].removeListener(this); Arrays.fill(this.bonds, newbonds.length, numBonds, null); } numBonds = newbonds.length; notifyChanged(); }
/** * {@inheritDoc} */ @Override public IBond removeBond(int idx) { BondRef bond = null; if (idx >= 0 && idx < numBonds) { bond = bonds[idx]; numBonds--; for (int i = idx; i < numBonds; i++) { bonds[i] = bonds[i + 1]; bonds[i].setIndex(i); } delFromEndpoints(bond); bonds[numBonds] = null; bond.removeListener(this); notifyChanged(); } return bond; }
/** * {@inheritDoc} */ @Override public IBond removeBond(int idx) { BondRef bond = null; if (idx >= 0 && idx < numBonds) { bond = bonds[idx]; numBonds--; for (int i = idx; i < numBonds; i++) { bonds[i] = bonds[i + 1]; bonds[i].setIndex(i); } delFromEndpoints(bond); bonds[numBonds] = null; bond.removeListener(this); notifyChanged(); } return bond; }
/** * {@inheritDoc} */ @Override public void addBond(IBond bond) { ensureBondCapacity(numBonds + 1); final BaseBondRef bref = newBondRef(bond); bref.setIndex(numBonds); addToEndpoints(bref); bonds[numBonds++] = bref; bref.addListener(this); notifyChanged(); }
/** * {@inheritDoc} */ @Override public void addBond(IBond bond) { ensureBondCapacity(numBonds + 1); final BaseBondRef bref = newBondRef(bond); bref.setIndex(numBonds); addToEndpoints(bref); bonds[numBonds++] = bref; bref.addListener(this); notifyChanged(); }
private BondRef getBondRefUnsafe(IBond bond) { if (bond.getContainer() == this && bonds[bond.getIndex()] == bond) return (BondRef) bond; bond = unbox(bond); for (int i = 0; i < numBonds; i++) if (bonds[i].deref() == bond) return bonds[i]; return null; }
private BondRef getBondRefUnsafe(IBond bond) { if (bond.getContainer() == this && bonds[bond.getIndex()] == bond) return (BondRef) bond; bond = unbox(bond); for (int i = 0; i < numBonds; i++) if (bonds[i].deref() == bond) return bonds[i]; return null; }
@Override public int hashCode() { return deref().hashCode(); }
private void addToEndpoints(BaseBondRef bondref) { if (bondref.getAtomCount() == 2) { BaseAtomRef beg = getAtomRef(bondref.getBegin()); BaseAtomRef end = getAtomRef(bondref.getEnd()); beg.bonds.add(bondref); end.bonds.add(bondref); } else { for (int i = 0; i < bondref.getAtomCount(); i++) { getAtomRef(bondref.getAtom(i)).bonds.add(bondref); } } }
private BaseBondRef newBondRef(IBond bond) { BaseAtomRef beg = bond.getBegin() == null ? null : getAtomRef(bond.getBegin()); BaseAtomRef end = bond.getEnd() == null ? null : getAtomRef(bond.getEnd()); if (bond.getClass() == Bond.class) return new BaseBondRef(this, bond, beg, end); bond = unbox(bond); if (bond instanceof IQueryBond) return new QueryBondRef(this, (IQueryBond) bond, beg, end); return new BaseBondRef(this, bond, beg, end); }
private BaseBondRef newBondRef(IBond bond) { BaseAtomRef beg = bond.getBegin() == null ? null : getAtomRef(bond.getBegin()); BaseAtomRef end = bond.getEnd() == null ? null : getAtomRef(bond.getEnd()); if (bond.getClass() == Bond.class) return new BaseBondRef(this, bond, beg, end); bond = unbox(bond); if (bond instanceof IQueryBond) return new QueryBondRef(this, (IQueryBond) bond, beg, end); return new BaseBondRef(this, bond, beg, end); }