com.asher_stern.crf.utilities.AbsoluteValueComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CRF Show documentation
Show all versions of CRF Show documentation
Implementation of linear-chain Conditional Random Fields (CRF) in pure Java
The newest version!
package com.asher_stern.crf.utilities;
import java.util.Comparator;
/**
* A comparator of Double, which compares the absolute value of the given Doubles.
*
* @author Asher Stern
* Date: Nov 20, 2014
*
*/
public class AbsoluteValueComparator implements Comparator
{
@Override
public int compare(Double o1, Double o2)
{
if (o1==o2) return 0;
if (o1==null) return -1;
if (o2==null) return 1;
return Double.compare(Math.abs(o1), Math.abs(o2));
}
}