Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java @ 6372:01073acf6735
Add hashCode and equals implementation to Range.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Jun 2013 09:40:38 +0200 |
parents | af13ceeba52a |
children | 2ad7f3ada1dc |
comparison
equal
deleted
inserted
replaced
6371:19459037b3c7 | 6372:01073acf6735 |
---|---|
67 | 67 |
68 /** True if start>x<end (+ some epsilon) . */ | 68 /** True if start>x<end (+ some epsilon) . */ |
69 public boolean inside(double x) { | 69 public boolean inside(double x) { |
70 return x > start-EPSILON && x < end+EPSILON; | 70 return x > start-EPSILON && x < end+EPSILON; |
71 } | 71 } |
72 | |
73 @Override | |
74 public int hashCode() { | |
75 return new Double(this.start).hashCode() ^ | |
76 new Double(this.end).hashCode(); | |
77 } | |
78 | |
79 @Override | |
80 public boolean equals(Object otherRange) { | |
81 if (otherRange == null) { | |
82 return false; | |
83 } | |
84 else if (otherRange instanceof Range) { | |
85 Range oRange = (Range) otherRange; | |
86 return | |
87 Math.abs(oRange.start - this.start) <= EPSILON | |
88 && Math.abs(oRange.end - this.end) <= EPSILON; | |
89 } | |
90 return false; | |
91 } | |
72 } | 92 } |
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |