Aktueller Stand
This commit is contained in:
18
backend/node_modules/mnemonist/fixed-deque.js
generated
vendored
18
backend/node_modules/mnemonist/fixed-deque.js
generated
vendored
@@ -48,7 +48,10 @@ FixedDeque.prototype.push = function(item) {
|
||||
if (this.size === this.capacity)
|
||||
throw new Error('mnemonist/fixed-deque.push: deque capacity (' + this.capacity + ') exceeded!');
|
||||
|
||||
var index = (this.start + this.size) % this.capacity;
|
||||
var index = this.start + this.size;
|
||||
|
||||
if (index >= this.capacity)
|
||||
index -= this.capacity;
|
||||
|
||||
this.items[index] = item;
|
||||
|
||||
@@ -85,10 +88,13 @@ FixedDeque.prototype.pop = function() {
|
||||
if (this.size === 0)
|
||||
return;
|
||||
|
||||
const index = (this.start + this.size - 1) % this.capacity;
|
||||
|
||||
this.size--;
|
||||
|
||||
var index = this.start + this.size;
|
||||
|
||||
if (index >= this.capacity)
|
||||
index -= this.capacity;
|
||||
|
||||
return this.items[index];
|
||||
};
|
||||
|
||||
@@ -135,7 +141,7 @@ FixedDeque.prototype.peekLast = function() {
|
||||
|
||||
var index = this.start + this.size - 1;
|
||||
|
||||
if (index > this.capacity)
|
||||
if (index >= this.capacity)
|
||||
index -= this.capacity;
|
||||
|
||||
return this.items[index];
|
||||
@@ -148,12 +154,12 @@ FixedDeque.prototype.peekLast = function() {
|
||||
* @return {any}
|
||||
*/
|
||||
FixedDeque.prototype.get = function(index) {
|
||||
if (this.size === 0)
|
||||
if (this.size === 0 || index >= this.capacity)
|
||||
return;
|
||||
|
||||
index = this.start + index;
|
||||
|
||||
if (index > this.capacity)
|
||||
if (index >= this.capacity)
|
||||
index -= this.capacity;
|
||||
|
||||
return this.items[index];
|
||||
|
||||
Reference in New Issue
Block a user