Package org.openscience.cdk.tools
Class ElementComparator
- java.lang.Object
-
- org.openscience.cdk.tools.ElementComparator
-
- All Implemented Interfaces:
Comparator<String>
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:
- main
- Belongs to CDK module:
- standard
- Keywords:
- element, sorting
-
-
Constructor Summary
Constructors Constructor Description ElementComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
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 interfaceComparator<String>
-
-