Last change
on this file since 8508 was
8434,
checked in by spimming, 12 years ago
|
#1894
- renamed old Vertex<T> to OsmVertex<T>
- added new Vertex class
|
File size:
1.2 KB
|
Line | |
---|
1 | namespace HeuristicLab.Problems.RoutePlanning.Graph {
|
---|
2 | public class OsmVertex<T> {
|
---|
3 | private static long idCounter = 0;
|
---|
4 |
|
---|
5 | private long id;
|
---|
6 | public long Id {
|
---|
7 | get { return id; }
|
---|
8 | }
|
---|
9 |
|
---|
10 | private T node;
|
---|
11 | public T Node {
|
---|
12 | get { return node; }
|
---|
13 | }
|
---|
14 |
|
---|
15 | public OsmVertex(T node) {
|
---|
16 | this.node = node;
|
---|
17 | this.id = idCounter++;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public static bool operator ==(OsmVertex<T> v1, OsmVertex<T> v2) {
|
---|
21 | if ((object)v1 == null) {
|
---|
22 | if ((object)v2 == null) {
|
---|
23 | return true;
|
---|
24 | }
|
---|
25 | return false;
|
---|
26 | }
|
---|
27 | if ((object)v1 == null && (object)v2 != null) {
|
---|
28 | return false;
|
---|
29 | }
|
---|
30 | return v1.Equals(v2);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public static bool operator !=(OsmVertex<T> v1, OsmVertex<T> v2) {
|
---|
34 | return !(v1 == v2);
|
---|
35 | }
|
---|
36 |
|
---|
37 | public override bool Equals(object obj) {
|
---|
38 | if (obj is OsmVertex<T>) {
|
---|
39 | OsmVertex<T> graph = (obj as OsmVertex<T>);
|
---|
40 | return this.Equals(graph);
|
---|
41 | }
|
---|
42 | return false;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public override int GetHashCode() {
|
---|
46 | return typeof(T).GetHashCode() ^ this.Node.GetHashCode();
|
---|
47 | }
|
---|
48 |
|
---|
49 | public override string ToString() {
|
---|
50 | return string.Format("{0}", this.Node);
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | }
|
---|
55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.