SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
MultiDimComparator.java
1/*
2 * Class: MultiDimComparator
3 * Description:
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10
11 * SSJ is free software: you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License (GPL) as published by the
13 * Free Software Foundation, either version 3 of the License, or
14 * any later version.
15
16 * SSJ is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20
21 * A copy of the GNU General Public License is available at
22 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
23 */
24package umontreal.ssj.util.multidimsort;
25
26import java.util.Comparator;
27import java.lang.IllegalArgumentException;
28
42public class MultiDimComparator<T extends MultiDimComparable<? super T>> implements Comparator<T> {
43 private int compareDim;
44
51 public MultiDimComparator(int j) {
52 compareDim = j;
53 }
54
61 public int compare(T o1, T o2) {
62 if (compareDim >= o1.getStateDimension() || compareDim >= o2.getStateDimension())
63 throw new IllegalArgumentException("Comparing in a " + "dimension larger than object dimension");
64 return o1.compareTo(o2, compareDim);
65 }
66
67}
MultiDimComparator(int j)
Constructs a comparator that uses coordinate j for the comparison of MultiDimComparable<T> objects.
int compare(T o1, T o2)
Calls o1.compareTo(o2, j) from class MultiDimComparable<T>.
This interface is an extension (or variant) of the Comparable interface in Java.