var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // sieve.mts var sieve_exports = {}; __export(sieve_exports, { Entry: () => Entry, Sieve: () => Sieve }); module.exports = __toCommonJS(sieve_exports); var import_link_list = require("@js-sdsl/link-list"); var Entry = class { constructor(key, value, visited = false) { this.key = key; this.value = value; this.visited = visited; } }; var Sieve = class { size; items; ll; hand; constructor(size) { this.size = size; this.items = /* @__PURE__ */ new Map(); this.ll = new import_link_list.LinkList(); } set(key, value) { if (this.items.has(key)) { const e2 = this.items.get(key); if (e2) { e2.value = value; e2.visited = true; } return; } if (this.ll.length >= this.size) { this.evict(); } const e = new Entry(key, value); this.items.set(key, e); this.ll.pushFront(e); } get(key) { if (this.items.has(key)) { const e = this.items.get(key); if (e) { e.visited = true; return [e.value, true]; } } return [null, false]; } contains(key) { return this.items.has(key); } peek(key) { if (this.items.has(key)) { const e = this.items.get(key); if (e) { return [e.value, true]; } } return [null, false]; } len() { return this.ll.length; } clear() { this.items.clear(); this.ll.clear(); } evict() { if (!this.hand || !this.hand.isAccessible()) { this.hand = this.ll.rBegin(); } let i; while ((i = this.hand.pointer) && i.visited) { i.visited = false; this.hand.next(); if (!this.hand.isAccessible()) { this.hand = this.ll.rBegin(); } } this.items.delete(this.hand.pointer.key); this.ll.eraseElementByIterator(this.hand); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Entry, Sieve });