File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ class RoundLinkedQueue {
4
4
constructor ( maxLength ) {
5
5
this . _maxLength = maxLength ;
6
6
this . _length = 0 ;
7
- this . _root = 0 ;
8
7
this . _first = null ;
9
8
this . _last = null ;
10
9
}
@@ -32,24 +31,18 @@ class RoundLinkedQueue {
32
31
} ;
33
32
34
33
if ( this . length < this . maxLength ) {
35
- if ( ! this . _root ) {
36
- this . _root = node ;
34
+ if ( ! this . _first ) {
37
35
this . _first = node ;
38
- this . _last = node ;
39
- } else {
40
- const previousLast = this . _last ;
41
- previousLast . next = node ;
42
-
43
36
this . _last = node ;
44
37
}
45
38
46
39
this . _length += 1 ;
47
40
} else {
48
- this . _root = this . _root . next ;
49
- this . _last . next = node ;
50
- this . _first = this . _root ;
51
- this . _last = node ;
41
+ this . _first = this . _first . next ;
52
42
}
43
+
44
+ this . _last . next = node ;
45
+ this . _last = node ;
53
46
}
54
47
}
55
48
You can’t perform that action at this time.
0 commit comments