create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / optimization / general / multidim / FunctionCacheComparator.java
1 package net.sf.openrocket.optimization.general.multidim;
2
3 import java.util.Comparator;
4
5 import net.sf.openrocket.optimization.general.FunctionCache;
6 import net.sf.openrocket.optimization.general.Point;
7
8 /**
9  * A comparator that orders Points in a function value order, smallest first.
10  * 
11  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
12  */
13 public class FunctionCacheComparator implements Comparator<Point> {
14         
15         private final FunctionCache cache;
16         
17         public FunctionCacheComparator(FunctionCache cache) {
18                 this.cache = cache;
19         }
20         
21         @Override
22         public int compare(Point o1, Point o2) {
23                 double v1 = cache.getValue(o1);
24                 double v2 = cache.getValue(o2);
25                 
26                 return Double.compare(v1, v2);
27         }
28         
29 }