@@ -147,19 +147,15 @@ public AtomContainer(IAtomContainer container)
147147
148148 for (int f = 0 ; f < container .getAtomCount (); f ++) {
149149 atoms [f ] = container .getAtom (f );
150- container .getAtom (f ).addListener (this );
151150 }
152151 for (int f = 0 ; f < this .bondCount ; f ++) {
153152 bonds [f ] = container .getBond (f );
154- container .getBond (f ).addListener (this );
155153 }
156154 for (int f = 0 ; f < this .lonePairCount ; f ++) {
157155 lonePairs [f ] = container .getLonePair (f );
158- container .getLonePair (f ).addListener (this );
159156 }
160157 for (int f = 0 ; f < this .singleElectronCount ; f ++) {
161158 singleElectrons [f ] = container .getSingleElectron (f );
162- container .getSingleElectron (f ).addListener (this );
163159 }
164160 }
165161
@@ -208,14 +204,7 @@ public Iterator<IStereoElement> iterator() {
208204 *@see #getAtom
209205 */
210206 public void setAtoms (IAtom [] atoms ) {
211- // unregister this as listener with the old atoms
212- for (IAtom atom : this .atoms )
213- if (atom != null ) atom .removeListener (this );
214-
215207 this .atoms = atoms ;
216- for (IAtom atom : atoms ) {
217- atom .addListener (this );
218- }
219208 this .atomCount = atoms .length ;
220209 }
221210
@@ -229,9 +218,6 @@ public void setAtoms(IAtom[] atoms) {
229218 public void setBonds (IBond [] bonds )
230219 {
231220 this .bonds = bonds ;
232- for (IBond bond : bonds ) {
233- bond .addListener (this );
234- }
235221 this .bondCount = bonds .length ;
236222 }
237223
@@ -263,7 +249,6 @@ public void setBonds(IBond[] bonds)
263249 */
264250 public void setAtom (int number , IAtom atom )
265251 {
266- atom .addListener (this );
267252 atoms [number ] = atom ;
268253 }
269254
@@ -1025,7 +1010,6 @@ public void addAtom(IAtom atom)
10251010 {
10261011 growAtomArray ();
10271012 }
1028- atom .addListener (this );
10291013 atoms [atomCount ] = atom ;
10301014 atomCount ++;
10311015 }
@@ -1115,7 +1099,6 @@ public void remove(IAtomContainer atomContainer)
11151099 */
11161100 public void removeAtom (int position )
11171101 {
1118- atoms [position ].removeListener (this );
11191102 for (int i = position ; i < atomCount - 1 ; i ++)
11201103 {
11211104 atoms [i ] = atoms [i + 1 ];
@@ -1195,7 +1178,6 @@ public void removeBond(IBond bond)
11951178 public ILonePair removeLonePair (int position )
11961179 {
11971180 ILonePair lp = lonePairs [position ];
1198- lp .removeListener (this );
11991181 for (int i = position ; i < lonePairCount - 1 ; i ++)
12001182 {
12011183 lonePairs [i ] = lonePairs [i + 1 ];
@@ -1224,7 +1206,6 @@ public void removeLonePair(ILonePair lonePair)
12241206 public ISingleElectron removeSingleElectron (int position )
12251207 {
12261208 ISingleElectron se = singleElectrons [position ];
1227- se .removeListener (this );
12281209 for (int i = position ; i < singleElectronCount - 1 ; i ++)
12291210 {
12301211 singleElectrons [i ] = singleElectrons [i + 1 ];
@@ -1315,9 +1296,6 @@ public void removeAtomAndConnectedElectronContainers(IAtom atom)
13151296 */
13161297 public void removeAllElements () {
13171298 removeAllElectronContainers ();
1318- for (int f = 0 ; f < getAtomCount (); f ++) {
1319- getAtom (f ).removeListener (this );
1320- }
13211299 atoms = new IAtom [growArraySize ];
13221300 atomCount = 0 ;
13231301 }
@@ -1329,12 +1307,6 @@ public void removeAllElements() {
13291307 public void removeAllElectronContainers ()
13301308 {
13311309 removeAllBonds ();
1332- for (int f = 0 ; f < getLonePairCount (); f ++) {
1333- getLonePair (f ).removeListener (this );
1334- }
1335- for (int f = 0 ; f < getSingleElectronCount (); f ++) {
1336- getSingleElectron (f ).removeListener (this );
1337- }
13381310 lonePairs = new ILonePair [growArraySize ];
13391311 singleElectrons = new ISingleElectron [growArraySize ];
13401312 lonePairCount = 0 ;
@@ -1345,9 +1317,6 @@ public void removeAllElectronContainers()
13451317 * Removes all Bonds from this container.
13461318 */
13471319 public void removeAllBonds () {
1348- for (int f = 0 ; f < getBondCount (); f ++) {
1349- getBond (f ).removeListener (this );
1350- }
13511320 bonds = new IBond [growArraySize ];
13521321 bondCount = 0 ;
13531322 }
@@ -1409,7 +1378,6 @@ public void addBond(int atom1, int atom2, IBond.Order order)
14091378 public void addLonePair (int atomID )
14101379 {
14111380 ILonePair lonePair = getBuilder ().newInstance (ILonePair .class ,atoms [atomID ]);
1412- lonePair .addListener (this );
14131381 addLonePair (lonePair );
14141382 /* no notifyChanged() here because addElectronContainer() does
14151383 it already */
@@ -1423,7 +1391,6 @@ public void addLonePair(int atomID)
14231391 public void addSingleElectron (int atomID )
14241392 {
14251393 ISingleElectron singleElectron = getBuilder ().newInstance (ISingleElectron .class ,atoms [atomID ]);
1426- singleElectron .addListener (this );
14271394 addSingleElectron (singleElectron );
14281395 /* no notifyChanged() here because addSingleElectron() does
14291396 it already */
0 commit comments