Algorithm
Development Kit 1.0

algs.model.kdtree
Class DimensionalComparator

java.lang.Object
  extended by algs.model.kdtree.DimensionalComparator
All Implemented Interfaces:
java.util.Comparator<IMultiPoint>

public class DimensionalComparator
extends java.lang.Object
implements java.util.Comparator<IMultiPoint>

Able to compare IMultiPoint objects using a fixed dimensional index to select the value against which to compare.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Field Summary
 int d
          The dimension against which the points are being compared.
 
Constructor Summary
DimensionalComparator(int d)
          Construct with the given dimensional index (d >= 1).
 
Method Summary
 int compare(IMultiPoint o1, IMultiPoint o2)
          Compare the two points against a given dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

d

public final int d
The dimension against which the points are being compared.

Constructor Detail

DimensionalComparator

public DimensionalComparator(int d)
Construct with the given dimensional index (d >= 1).

Parameters:
d - specific dimension (d >= 1).
Method Detail

compare

public int compare(IMultiPoint o1,
                   IMultiPoint o2)
Compare the two points against a given dimension.

Note that for performance reasons, there is no check to ensure that the two points have the same dimensionality. Indeed, if this method is invoked with an IMultiPoint whose dimensionality is less than d, then the result is undetermined (it may throw a runtime exception it may not).

Specified by:
compare in interface java.util.Comparator<IMultiPoint>
Parameters:
o1 - first IMultiPoint to be compared against
o2 - second IMultiPoint to be compared against.

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.