-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyNode.java
61 lines (48 loc) · 924 Bytes
/
MyNode.java
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
package myLinkedList;
public class MyNode implements Comparable<MyNode> {
MyNode prev, next;
int value;
//costruttori
public MyNode(int v) {
this(null, null, v);
}
public MyNode(MyNode prev, MyNode next, int v) {
this.prev = prev;
this.next = next;
this.value = v;
}
//metodi
public MyNode getPrev() {
return this.prev;
}
public MyNode getNext() {
return this.next;
}
public void setHead() {
this.prev = null;
}
public void setTail() {
this.next = null;
}
public int getValue() {
return this.value;
}
public void setValue(int v) {
this.value = v;
}
@Override
public int compareTo(MyNode arg0) {
if ( this.value < arg0.value)
return -1;
else if ( this.value == arg0.value )
return 0;
else
return -1;
}
public boolean equals(MyNode arg0) {
return this.value == arg0.value ;
}
public void printNode() {
System.out.print(this.value);
}
}