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 {
44 constructor ( maxLength ) {
55 this . _maxLength = maxLength ;
66 this . _length = 0 ;
7- this . _root = 0 ;
87 this . _first = null ;
98 this . _last = null ;
109 }
@@ -32,24 +31,18 @@ class RoundLinkedQueue {
3231 } ;
3332
3433 if ( this . length < this . maxLength ) {
35- if ( ! this . _root ) {
36- this . _root = node ;
34+ if ( ! this . _first ) {
3735 this . _first = node ;
38- this . _last = node ;
39- } else {
40- const previousLast = this . _last ;
41- previousLast . next = node ;
42-
4336 this . _last = node ;
4437 }
4538
4639 this . _length += 1 ;
4740 } 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 ;
5242 }
43+
44+ this . _last . next = node ;
45+ this . _last = node ;
5346 }
5447}
5548
You can’t perform that action at this time.
0 commit comments