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

org.khelekore.prtree.MinDistComparator Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package org.khelekore.prtree;

import java.util.Comparator;

/** A comparator that uses the MINDIST metrics to sort Nodes
 * @param  the data stored in the nodes
 * @param  the actual node
 */
class MinDistComparator> implements Comparator {
    public final MBRConverter converter;
    public final PointND p;

    public MinDistComparator (MBRConverter converter, PointND p) {
	this.converter = converter;
	this.p = p;
    }

    public int compare (S t1, S t2) {
	MBR mbr1 = t1.getMBR (converter);
	MBR mbr2 = t2.getMBR (converter);
	return Double.compare (MinDist.get (mbr1, p),
			       MinDist.get (mbr2, p));
    }
}