UNPKG

@devgrid/common

Version:
40 lines 935 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ListBuffer = void 0; class ListBuffer { constructor() { this.head = null; this.tail = null; this.size = 0; } push(value) { const node = { value, next: null }; if (!this.tail) { this.head = this.tail = node; } else { this.tail.next = node; this.tail = node; } this.size++; } shift() { if (!this.head) return undefined; const value = this.head.value; this.head = this.head.next; if (!this.head) this.tail = null; this.size--; return value; } get length() { return this.size; } clear() { this.head = this.tail = null; this.size = 0; } } exports.ListBuffer = ListBuffer; //# sourceMappingURL=list-buffer.js.map