-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.cs
119 lines (89 loc) · 1.63 KB
/
Node.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Created by SharpDevelop.
* User: anton
* Date: 18.11.2010
* Time: 18:36
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace LinkedListLab
{
/// <summary>
/// Узел односвязного списка
/// </summary>
public class Node:ICloneable
{
int info;
public int Info{
set { info = value;}
get { return info;}
}
Node link;
public Node Link {
set { link = value;}
get { return link;}
}
#region constructors
public Node()
{
}
public Node(int d)
{
Info = d;
}
public Node(int d, Node l)
{
Info = d;
Link = l;
}
#endregion
#region operators ++ ==
// FIXME: работает?
/// <summary>
///
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
///
public static Node operator++ (Node n){
return n.Link;
}
/*
public static Node operator== (Node n1, Node n2){
return (n1.Info == n2.Info);
}
public static Node operator!= (Node n1, Node n2){
return !(n1.Info == n2.Info);
}
*/
#endregion
public object Clone()
{
Node p = this.Link;
Node First;
Node last;
First = new Node(this.Info,null);
last = First;
while (p!=null){
last.Link = new Node(p.Info,null);
last = last.Link;
p = p.Link;
}
return First;
}
public override string ToString()
{
return Info+"";
}
/*
public override int GetHashCode(){
return this.Info;
}
public override bool Equals(Object o){
Node n = o as Node;
return (this.Info==n.Info);
}
*/
}
}