All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unit16.z.function.Comparison Maven / Gradle / Ivy

Go to download

A collection of utilities for representing and manipulating time series and such.

There is a newer version: 0.1.6
Show newest version
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 c;
	public Comparison(Comparator 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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy