import type { BitField, Uint32 } from "./bitfield/api.js"; import type { Path } from "./path/api.js"; export interface Config { /** * Number of bits of the hash to use for child index calculation at each level * of the tree such that the root node takes the first `bitWidth` bits of the * hash to calculate an index and as we move lower in the tree, we move along * the hash by `depth x bitWidth` bits. This also determines branching factor * of the tree beacuse each node will contain index for `2 ** bitWidth` * children. * * When omitted `bitWidth` of `5` is used which results in trees with branching * factor of 32, allowing us to use various space and computation optimizations * while still fitting large amounts of entries in relatively shallow tree ( * around `33,554,432` entries in a tree that is just 6 levels deep) */ bitWidth: Uint32; /** * Configuration used by the HAMT to calculate tree path from the key. It used * for building an index and traversal. It can be configured so that e.g 32 * branching factor is used in which case it will be highly optimized. */ Path: Path; /** * Configuration used by the HAMT to represent child index (datamap & nodemap), * which is configurable allowing us to highly optimizing 32 barnch factor by * representing them as a single 32 bit integer as opposed to `Uint8Array`. */ BitField: BitField; } export interface HAMT { readonly root: BitmapIndexedNode; readonly config: C; } export interface PersistentHashMap extends HAMT { readonly size: number; entries(): IterableIterator<[K, T]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.iterator](): IterableIterator<[K, T]>; clone(): PersistentHashMap; empty(): PersistentHashMap; has(key: K): boolean; get(key: K): T | undefined; set(key: R, value: T): PersistentHashMap; delete(key: K): PersistentHashMap; createBuilder(): HashMapBuilder; } export interface HashMapBuilder extends HAMT { readonly size: number; set(key: R, value: T): HashMapBuilder; delete(key: K): HashMapBuilder; build(): PersistentHashMap; } export interface Node { edit: Edit | null; children: Children; config: C; lookup(shift: Uint32, path: ReturnType, key: K, notFound: X): T | X; associate(edit: Edit | null, depth: Uint32, path: ReturnType, key: K | R, value: T, leafAdded: { value: boolean; }): Node; dissociate(edit: Edit | null, depth: Uint32, path: ReturnType, key: K, removedLeaf: { value: boolean; }): Node; entries(): IterableIterator<[K, T]>; keys(): IterableIterator; values(): IterableIterator; fork(edit?: Edit | null): Node; nodeArity: number; dataArity: number; } export interface BitmapIndexedNode extends Node { datamap: ReturnType; nodemap: ReturnType; associate(edit: Edit | null, depth: Uint32, path: ReturnType, key: K | R, value: T, leafAdded: { value: boolean; }): BitmapIndexedNode; dissociate(edit: Edit | null, depth: Uint32, path: ReturnType, key: K, removedLeaf: { value: boolean; }): BitmapIndexedNode; fork(edit?: Edit | null): BitmapIndexedNode; } export interface HashCollisionNode extends Node { config: C; count: number; children: CollisionEntries; nodeArity: 0; fork(edit?: Edit | null): HashCollisionNode; } export declare type CollisionEntries = [K, T] | [K, T, K, T] | [K, T, K, T, K, T, ...Array]; export interface Children extends Array> { } export declare type usize = number; export interface Edit { } export type { BitField, Uint32, Path }; //# sourceMappingURL=api.d.ts.map