UNPKG

array-ring

Version:

Advanced Array and Ring structure for Large data: A High-Performance Solution, mostly created to implement array methods, bringing 2 data structures, An efficient resizable array with similar methods to javascript array which are optmized methods like shi

27 lines (26 loc) 745 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RingArray = void 0; const _Array_1 = require("./_Array"); class RingArray extends _Array_1._Array { _push(item) { this.buffer[this.end] = item; this.end = (this.end + 1) % this.size; if (this.count === this.size) { this.start = this.end; } else this.count++; } _unshift(item) { this.start = (this.start - 1 + this.size) % this.size; this.buffer[this.start] = item; if (this.count === this.size) { this.end = (this.end - 1 + this.size) % this.size; } else { this.count++; } } } exports.RingArray = RingArray;