com.unit16.z.function.Comparison Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unit16-z Show documentation
Show all versions of unit16-z Show documentation
A collection of utilities for representing and manipulating time series and such.
package com.unit16.z.function;
import java.util.Comparator;
import com.google.common.base.Equivalence;
/**
* An {@link Equivalence} relationship based on a {@link Comparator}.
*
* @param
*/
public final class Comparison extends Equivalence
{
private final Comparator super T> c;
public Comparison(Comparator super T> c1) { c = c1; }
@Override
protected boolean doEquivalent(T a, T b) {
return c.compare(a, b) == 0;
}
@Override
protected int doHash(T t) {
return t.hashCode();
}
}