#184 IChemModel.empty() or isEmpty()

None
closed
nobody
None
1
2013-10-22
2012-10-23
No

hello,
I would like to have a function such as IChemModel.empty() or isEmpty().
At the moment I'm using the following, with doubts if I got it right:

    IChemModel cm = jcpPanel.get2DHub().getChemModel();
    if ((cm.getMoleculeSet() == null || cm.getMoleculeSet().getMoleculeCount() < 2)
            && (cm.getReactionSet() == null || cm.getReactionSet().getReactionCount() == 0)) {
        if (cm.getMoleculeSet().getMoleculeCount() == 1) {
            IMolecule mol = cm.getMoleculeSet().getMolecule(0);
            if (mol.getAtomCount() == 0)
                jcpPanel.setModified(false);
        } else {
            jcpPanel.setModified(false);
        }
    }

So you see, it can happen there is a molecule with 0 atoms in the model. This is considered acceptable as empty in JCP. Does that conform to CDK policy?

Discussion

  • John May

    John May - 2012-10-23

    You know I was thinking exactly this the other day!

    .isEmpty()
    

    would definitely make for some cleaner code. Unfortunately atom container uses fixed size arrays internally (i.e. not Collections API) so although it's trivial to do it's not as clean as it would be if we used collections.

    ++ from me anyways :-)

    Edit: typos

     
    Last edit: John May 2012-10-23
  • John May

    John May - 2013-10-22
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks