Last change
on this file since 335 was 335, checked in by gebner, 17 years ago |
CombineWayAction: Reorder ways if that makes it possible to combine them.
|
File size:
703 bytes
|
Line | |
---|
1 | package org.openstreetmap.josm.data.osm;
|
---|
2 | import java.util.ArrayList;
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * A pair of twe nodes.
|
---|
6 | */
|
---|
7 | public final class NodePair {
|
---|
8 | public Node a, b;
|
---|
9 |
|
---|
10 | public NodePair(Node a, Node b) {
|
---|
11 | this.a = a;
|
---|
12 | this.b = b;
|
---|
13 | }
|
---|
14 |
|
---|
15 | @Override public int hashCode() {
|
---|
16 | return a.hashCode() ^ b.hashCode();
|
---|
17 | }
|
---|
18 |
|
---|
19 | @Override public boolean equals(Object o) {
|
---|
20 | if (o == null || !(o instanceof NodePair)) {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 | return a == ((NodePair) o).a && b == ((NodePair) o).b;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public ArrayList<Node> toArrayList() {
|
---|
27 | ArrayList<Node> l = new ArrayList<Node>(2);
|
---|
28 | l.add(a);
|
---|
29 | l.add(b);
|
---|
30 | return l;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public void sort() {
|
---|
34 | if (b.hashCode() < a.hashCode()) {
|
---|
35 | Node tmp = a;
|
---|
36 | a = b;
|
---|
37 | b = tmp;
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.