File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 4
4
5
5
6
6
export class Node < T > {
7
- public left : Node < T > | null
8
- public right : Node < T > | null
7
+ public left : Node < T > | undefined
8
+ public right : Node < T > | undefined
9
9
10
10
constructor ( public value : T ) {
11
- this . right = null
12
- this . left = null
11
+ this . right = undefined
12
+ this . left = undefined
13
13
}
14
14
15
15
static of < T > ( val : T ) {
@@ -19,11 +19,11 @@ export class Node<T> {
19
19
20
20
export class LinkedList < T > {
21
21
public length : number
22
- private __head : Node < T > | null
22
+ private __head : Node < T > | undefined
23
23
24
24
constructor ( ) {
25
25
this . length = 0
26
- this . __head = null
26
+ this . __head = undefined
27
27
}
28
28
29
29
element ( ) {
@@ -58,12 +58,12 @@ export class LinkedList<T> {
58
58
}
59
59
else if ( n . left ) {
60
60
this . __head = n . left
61
- n . left . right = null
61
+ n . left . right = undefined
62
62
}
63
63
else if ( n . right ) {
64
- n . right . left = null
64
+ n . right . left = undefined
65
65
} else {
66
- this . __head = null
66
+ this . __head = undefined
67
67
}
68
68
this . length --
69
69
}
You can’t perform that action at this time.
0 commit comments