Closer to compiling. at the moment, it throws a NullPointerException right after...
[IRC.git] / Robust / src / Benchmarks / oooJava / DelaunayRefinement / ElementEdge.java
1 public class ElementEdge {
2   private final Tuple p1;
3   private final Tuple p2;
4   private final int hashvalue;
5
6   public ElementEdge() {
7     p1 = null;
8     p2 = null;
9     hashvalue = 1;
10   }
11
12   public ElementEdge(Tuple a, Tuple b) {
13     if (a.lessThan(b)) {
14       p1 = a;
15       p2 = b;
16     } else {
17       p1 = b;
18       p2 = a;
19     }
20     int tmphashval = 17;
21     tmphashval = 37 * tmphashval + p1.hashCode();
22     tmphashval = 37 * tmphashval + p2.hashCode();
23     hashvalue = tmphashval;
24   }
25
26   public ElementEdge(ElementEdge rhs) {
27     p1 = rhs.p1;
28     p2 = rhs.p2;
29     hashvalue = rhs.hashvalue;
30   }
31
32   public boolean equals(Object obj) {
33     if (!(obj instanceof ElementEdge))
34       return false;
35     ElementEdge edge = (ElementEdge) obj;
36     return p1.equals(edge.p1) && p2.equals(edge.p2);
37   }
38
39   public int hashCode() {
40     return hashvalue;
41   }
42
43   public boolean notEqual(ElementEdge rhs) {
44     return !equals(rhs);
45   }
46
47   public boolean lessThan(ElementEdge rhs) {
48     return p1.lessThan(rhs.p1) || p1.equals(rhs.p1) && p2.lessThan(rhs.p2);
49   }
50
51   public boolean greaterThan(ElementEdge rhs) {
52     return p1.greaterThan(rhs.p1) || p1.equals(rhs.p1) && p2.greaterThan(rhs.p2);
53   }
54
55   public Tuple getPoint(int i) {
56     if (i == 0)
57       return p1;
58     if (i == 1) {
59       return p2;
60     } else {
61       System.exit(-1);
62       return null;
63     }
64   }
65
66   public String toString() {
67     return "<"+p1.toString()+(", ")+p2.toString()+">";
68   }
69 }