public FormulaGenerator(Range massRange, ElementRule selectedElements[]) {
// Sort the elements by mass in ascending order. That greatly speeds up
// the search.
this.elementRules = selectedElements;
Arrays.sort(this.elementRules, new ElementRuleSorterByMass());
// Adjust the maximum numbers according to the mass we are
// searching
for (ElementRule rule : selectedElements) {
int maxCountAccordingToMass = (int) (massRange.getMax() / rule