Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/EpsilonComparator.java @ 4732:7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
author | Sascha Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 28 Dec 2012 15:01:12 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4731:7d9fcd322c45 | 4732:7fdddc6ba296 |
---|---|
1 package de.intevation.flys.importer.parsers.tim; | |
2 | |
3 import java.util.Comparator; | |
4 | |
5 public class EpsilonComparator implements Comparator<Double> | |
6 { | |
7 public static final double EPSILON = 1e-4; | |
8 | |
9 public static final EpsilonComparator CMP = new EpsilonComparator(EPSILON); | |
10 | |
11 private double epsilon; | |
12 | |
13 public EpsilonComparator(double epsilon) { | |
14 this.epsilon = epsilon; | |
15 } | |
16 | |
17 @Override | |
18 public int compare(Double a, Double b) { | |
19 double diff = a - b; | |
20 if (diff < -epsilon) return -1; | |
21 if (diff > epsilon) return +1; | |
22 return 0; | |
23 } | |
24 } | |
25 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |