1
1
///<reference path="Driver.ts"/>
2
2
3
3
namespace Base {
4
- export interface IList {
4
+ export interface IList < T > {
5
5
isHead : boolean ;
6
- next : IList ;
7
- prev : IList ;
8
- insertAfter ( entry : IList ) : IList ;
9
- insertBefore ( entry : IList ) : IList ;
6
+ next : IList < T > ;
7
+ prev : IList < T > ;
8
+ data : T ;
9
+ insertAfter ( entry : IList < T > ) : IList < T > ;
10
+ insertBefore ( entry : IList < T > ) : IList < T > ;
10
11
item ( ) ;
11
12
empty ( ) : boolean ;
12
13
}
13
14
14
- export class List implements IList {
15
- next : IList ;
16
- prev : IList ;
17
-
18
- constructor ( public isHead : boolean , public data ) { }
15
+ export class List < T > implements IList < T > {
16
+ next : IList < T > ;
17
+ prev : IList < T > ;
18
+
19
+ constructor ( public isHead : boolean , public data : T ) { }
19
20
20
21
item ( ) {
21
22
return this . data ;
@@ -25,15 +26,15 @@ namespace Base {
25
26
return this . next == this ;
26
27
}
27
28
28
- insertAfter ( entry : IList ) : IList {
29
+ insertAfter ( entry : IList < T > ) : IList < T > {
29
30
entry . next = this . next ;
30
31
entry . prev = this ;
31
32
this . next = entry ;
32
33
entry . next . prev = entry ;
33
34
return ( entry ) ;
34
35
}
35
36
36
- insertBefore ( entry : IList ) : IList {
37
+ insertBefore ( entry : IList < T > ) : IList < T > {
37
38
this . prev . next = entry ;
38
39
entry . next = this ;
39
40
entry . prev = this . prev ;
@@ -42,21 +43,21 @@ namespace Base {
42
43
}
43
44
}
44
45
45
- export function listMakeEntry ( data ) : IList {
46
- var entry : List = new List ( false , data ) ;
46
+ export function listMakeEntry < T > ( data : T ) : IList < T > {
47
+ var entry : List < T > = new List < T > ( false , data ) ;
47
48
entry . prev = entry ;
48
49
entry . next = entry ;
49
50
return entry ;
50
51
}
51
52
52
- export function listMakeHead ( ) : IList {
53
- var entry : List = new List ( true , null ) ;
53
+ export function listMakeHead < T > ( ) : IList < T > {
54
+ var entry : List < T > = new List ( true , null ) ;
54
55
entry . prev = entry ;
55
56
entry . next = entry ;
56
57
return entry ;
57
58
}
58
59
59
- export function listRemove ( entry : IList ) : IList {
60
+ export function listRemove < T > ( entry : IList < T > ) : IList < T > {
60
61
if ( entry == null ) {
61
62
return null ;
62
63
}
0 commit comments