/** * {@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(); }
/** * {@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(); }