Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -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];