{"draft":null,"from":132,"to":133,"files":[{"path":"src/engine/state-source.ts","added":34,"removed":0,"diff":"--- a/src/engine/state-source.ts\n+++ b/src/engine/state-source.ts\n@@ -139,6 +139,40 @@\n \t}\n }\n \n+/** Immutable indexed subtraction retains neither operand's enumerated values. */\n+export class StableDifferenceSet<T> extends StableSet<T> {\n+\treadonly left: StableSet<T>;\n+\treadonly right: StableSet<T>;\n+\tconstructor(left: StableSet<T>, right: StableSet<T>) {\n+\t\tsuper();\n+\t\tthis.left = left;\n+\t\tthis.right = right;\n+\t}\n+\tget retainedBytes(): number {\n+\t\treturn 32 + this.left.retainedBytes + this.right.retainedBytes;\n+\t}\n+\thas(value: T): boolean {\n+\t\treturn this.left.has(value) && !this.right.has(value);\n+\t}\n+\t*values(): SetIterator<T> {\n+\t\tfor (const value of this.left) if (!this.right.has(value)) yield value;\n+\t}\n+}\n+\n+/** Preserve indexed history; only the caller's operation-sized overlay is copied. */\n+export function unionOverlay<T>(base: ReadonlySet<T>, overlay: Iterable<T>): ReadonlySet<T> {\n+\treturn base instanceof StableSet\n+\t\t? new StableUnionSet(base, new StableOverlaySet(overlay))\n+\t\t: new Set([...base, ...overlay]);\n+}\n+\n+/** Both indexed operands must be immutable for the lifetime of the result. */\n+export function differenceSet<T>(left: ReadonlySet<T>, right: ReadonlySet<T>): ReadonlySet<T> {\n+\treturn left instanceof StableSet && right instanceof StableSet\n+\t\t? new StableDifferenceSet(left, right)\n+\t\t: new Set([...left].filter((value) => !right.has(value)));\n+}\n+\n /** An immutable snapshot for the operation's small overlay, not its history. */\n export class StableOverlaySet<T> extends StableSet<T> {\n \treadonly #values: Set<T>;"}],"unmatched":[]}