Class ElementComparator

  • All Implemented Interfaces:

    public class ElementComparator
    extends Object
    implements Comparator<String>
    Compares elements based on the order commonly used in molecular formula. Order: C, H, other elements in alphabetic order.
    Source code:
    Belongs to CDK module:
    element, sorting
    • Constructor Detail

      • ElementComparator

        public ElementComparator()
    • Method Detail

      • compare

        public int compare​(String o1,
                           String o2)
        Returns a negative if o1 comes before o2 in a molecular formula, returns zero if they are identical, and positive if o1 comes after o2 in the formula.
        Specified by:
        compare in interface Comparator<String>