org.openscience.cdk.tools
Class ElementComparator

java.lang.Object
  extended by org.openscience.cdk.tools.ElementComparator
All Implemented Interfaces:
Comparator

@TestClass(value="org.openscience.cdk.tools.ElementComparatorTest")
public class ElementComparator
extends Object
implements Comparator

Compares elements based on the order commonly used in molecular formula. Order: C, H, other elements in alphabetic order.

Keywords:
element, sorting
Belongs to CDK module:
standard
Source code:
HEAD

Constructor Summary
ElementComparator()
           
 
Method Summary
 int compare(Object o1, Object 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ElementComparator

public ElementComparator()
Method Detail

compare

@TestMethod(value="testCompare_Object_Object")
public int compare(Object o1,
                                   Object 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