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