"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.FixedQueue=void 0;const node_assert_1=__importDefault(require("node:assert")),kSize=2048,kMask=2047;class FixedCircularBuffer{constructor(){this.bottom=0,this.top=0,this.list=new Array(2048),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(t){this.list[this.top]=t,this.top=this.top+1&2047}shift(){const t=this.list[this.bottom];return void 0===t?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&2047,t)}remove(t){const i=this.list.indexOf(t);node_assert_1.default.notStrictEqual(i,-1);let s=i;for(;;){const t=s+1&2047;if(this.list[s]=this.list[t],void 0===this.list[s])break;if(t===i){this.list[s]=void 0;break}s=t}this.top=this.top-1&2047}}class FixedQueue{constructor(){this._size=0,this.head=this.tail=new FixedCircularBuffer}isEmpty(){return this.head.isEmpty()}push(t){this.head.isFull()&&(this.head=this.head.next=new FixedCircularBuffer),this.head.push(t),this._size++}shift(){const t=this.tail,i=t.shift();return null!==i&&this._size--,t.isEmpty()&&null!==t.next&&(this.tail=t.next,t.next=null),i}remove(t){let i=null,s=this.tail;for(;;){if(s.list.includes(t)){s.remove(t),this._size--;break}if(null===s.next)break;i=s,s=s.next}s.isEmpty()&&(null===i?null!==s.next&&(this.tail=s.next):null===s.next?this.head=i:i.next=s.next)}get size(){return this._size}}exports.FixedQueue=FixedQueue;