Commit b448a7ff authored by Caelan Reese Wong's avatar Caelan Reese Wong
Browse files

updated the delete function to fix array index issue

parent 2f68541c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -162,6 +162,10 @@ public class MDB {
            Molecule result = dbMolecule.areMoleculesEqual(molecule);
            if (result != null) {
                this.db.get(numAtoms).remove(dbMolecule);
                if( this.db.get(numAtoms).size()==0 )
                {
                    this.db.remove(numAtoms); //prevents array index error when key becomes empty
                }
                return true; // successfully delete the molecule
            }
        }
+4 −0
Original line number Diff line number Diff line
@@ -193,6 +193,10 @@ public class MoleculeDatabase {
            Molecule result = dbMolecule.areMoleculesEqual(molecule);
            if (result != null) {
                this.db.get(numAtoms).remove(dbMolecule);
                if( this.db.get(numAtoms).size()==0 )
                {
                    this.db.remove(numAtoms); //prevents array index error when key becomes empty
                }
                return true; // successfully delete the molecule
            }
        }