![]() |
OpenMS
|
Orders the elements of a formula independently of where the Element objects are in memory. More...
#include <OpenMS/CHEMISTRY/EmpiricalFormula.h>
Public Member Functions | |
| bool | operator() (const Element *a, const Element *b) const |
Orders the elements of a formula independently of where the Element objects are in memory.
By atomic number, then by the length and the text of the symbol: an element ("C") comes before its isotopes, which ElementDB names by their mass number ("(12)C", "(13)C"), and the isotopes come in the order of their mass numbers. Iterating over a formula (e.g. to sum up its weight) therefore visits the elements in the same order in every run; the addresses of the Element objects differ between runs (e.g. with the randomized heap of Windows), and a different order of the additions changes the last bits of the weights. ElementDB keeps atomic number and symbol when it updates an element. Only distinct elements with the same atomic number and symbol are ordered by address.
References Element::getAtomicNumber(), and Element::getSymbol().