type CanonicalizerStrategy = 'uninitialized' | 'objectIdentity' | 'numberWithEquality' | 'stringIdentity'; interface CanonicalizerStats { strategy: CanonicalizerStrategy; size: number; bucketCount: number; collisionCount: number; maxChainLength: number; unsupportedKeyFailures: number; } /** * Utility class to map objects to dense integer IDs. * Used for performance optimization to replace object-based maps/sets with array-based structures. * * @template T - The type of items to canonicalize */ export declare class Canonicalizer { private list; private keyExtractor; private equalityComparer?; private readonly usesDefaultKeyExtractor; private strategy; private objectIdSymbol; private numberKeys; private numberHeads; private numberOccupied; private stringHashes; private stringHeads; private stringOccupied; private nextById; private bucketCount; private threshold; private mask; private collisionCount; private maxChainLength; private unsupportedKeyFailures; private scratchFoundStored; /** * @param keyExtractor - Function to extract a unique key from an item. * Defaults to identity (using the item itself as key). */ constructor(keyExtractor?: (item: T) => unknown, equalityComparer?: (a: T, b: T) => boolean); /** * Get the unique integer ID for an item. * If the item (or its key) has been seen before, returns the existing ID. * Otherwise, assigns a new ID. */ getId(item: T): number; private hasDuplicateKeyResolver; private maybeUpdateRepresentative; /** * Get the integer ID of an item if it already exists. * Returns -1 if the item has not been canonicalized. */ getExistingId(item: T): number; /** * Get the item associated with an integer ID. */ get(id: number): T | undefined; /** * Get the total number of unique items seen so far. */ size(): number; getStats(): CanonicalizerStats; /** * Clear all mappings. */ clear(): void; private ensureStrategy; private getObjectIdentityId; private getExistingObjectIdentityId; private getNumberKeyId; private getExistingNumberKeyId; private getStringKeyId; private getExistingStringKeyId; private findStringIdOrAppend; private appendNumberBucket; private appendNumberId; private appendStringBucket; private appendStringId; private initializeNumberTable; private initializeStringTable; private ensureBucketCapacityForInsert; private ensureNextCapacity; private findNumberSlot; private findExistingNumberSlot; private findStringSlot; private findExistingStringSlot; private stringBucketContainsKey; private rehashNumberTable; private rehashStringTable; private initializeNumberTableWithCapacity; private initializeStringTableWithCapacity; private updateMaxChainLength; private isObjectLike; private failUnsupportedKey; /** * Returns the stored item that was found during the last successful * {@link getNumberKeyId} lookup, or `undefined` if no such lookup has * occurred. This is a scratch field carried over from the homeflow * implementation. */ getScratchFoundStored(): T | undefined; } export {}; //# sourceMappingURL=Canonicalizer.d.ts.map