File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -4,32 +4,26 @@ function init(list) {
4
4
list . _idleNext = list ;
5
5
list . _idlePrev = list ;
6
6
}
7
- exports . init = init ;
8
7
9
8
// create a new linked list
10
9
function create ( ) {
11
10
const list = { _idleNext : null , _idlePrev : null } ;
12
11
init ( list ) ;
13
12
return list ;
14
13
}
15
- exports . create = create ;
16
14
17
15
// show the most idle item
18
16
function peek ( list ) {
19
17
if ( list . _idlePrev === list ) return null ;
20
18
return list . _idlePrev ;
21
19
}
22
- exports . peek = peek ;
23
-
24
20
25
21
// remove the most idle item from the list
26
22
function shift ( list ) {
27
23
const first = list . _idlePrev ;
28
24
remove ( first ) ;
29
25
return first ;
30
26
}
31
- exports . shift = shift ;
32
-
33
27
34
28
// remove a item from its list
35
29
function remove ( item ) {
@@ -44,8 +38,6 @@ function remove(item) {
44
38
item . _idleNext = null ;
45
39
item . _idlePrev = null ;
46
40
}
47
- exports . remove = remove ;
48
-
49
41
50
42
// remove a item from its list and place at the end.
51
43
function append ( list , item ) {
@@ -62,10 +54,17 @@ function append(list, item) {
62
54
list . _idleNext . _idlePrev = item ;
63
55
list . _idleNext = item ;
64
56
}
65
- exports . append = append ;
66
-
67
57
68
58
function isEmpty ( list ) {
69
59
return list . _idleNext === list ;
70
60
}
71
- exports . isEmpty = isEmpty ;
61
+
62
+ module . exports = {
63
+ init,
64
+ create,
65
+ peek,
66
+ shift,
67
+ remove,
68
+ append,
69
+ isEmpty
70
+ } ;
You can’t perform that action at this time.
0 commit comments