File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -4,32 +4,26 @@ function init(list){
44list . _idleNext = list ;
55list . _idlePrev = list ;
66}
7- exports . init = init ;
87
98// create a new linked list
109function create ( ) {
1110const list = { _idleNext : null , _idlePrev : null } ;
1211init ( list ) ;
1312return list ;
1413}
15- exports . create = create ;
1614
1715// show the most idle item
1816function peek ( list ) {
1917if ( list . _idlePrev === list ) return null ;
2018return list . _idlePrev ;
2119}
22- exports . peek = peek ;
23-
2420
2521// remove the most idle item from the list
2622function shift ( list ) {
2723const first = list . _idlePrev ;
2824remove ( first ) ;
2925return first ;
3026}
31- exports . shift = shift ;
32-
3327
3428// remove a item from its list
3529function remove ( item ) {
@@ -44,8 +38,6 @@ function remove(item){
4438item . _idleNext = null ;
4539item . _idlePrev = null ;
4640}
47- exports . remove = remove ;
48-
4941
5042// remove a item from its list and place at the end.
5143function append ( list , item ) {
@@ -62,10 +54,17 @@ function append(list, item){
6254list . _idleNext . _idlePrev = item ;
6355list . _idleNext = item ;
6456}
65- exports . append = append ;
66-
6757
6858function isEmpty ( list ) {
6959return list . _idleNext === list ;
7060}
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