/** * A GADDAG (Gordon, 1994) stored as flat typed arrays for speed and compact serialization. * * For every word `w` and every split `1 <= s <= |w|` the automaton accepts * `reverse(w[0..s)) + ◇ + w[s..)` (the separator is omitted when `s === |w|`). * * States are identified by "refs": `ref = (firstArcIndex << 1) | isWordEnd`. * A `firstArcIndex` of 0 means the state has no outgoing arcs; ref 0 means "no such state". * Arcs of a state are contiguous; the last one is marked with {@link LAST_ARC_FLAG} in its label. * An arc label stores the letter index (1..63, 0 = separator) in its low 6 bits. */ export declare class Gaddag { /** Arc labels: letter index | LAST_ARC_FLAG. Index 0 is an unused sentinel. */ readonly arcLabels: Uint8Array; /** Arc targets: encoded state refs. Index 0 is an unused sentinel. */ readonly arcTargets: Int32Array; /** Ref of the root state. */ readonly rootRef: number; /** Code point of each letter index (position 0 holds the code point of letter 1). */ readonly charCodes: Int32Array; private readonly letterByCharCode; constructor(arcLabels: Uint8Array, arcTargets: Int32Array, rootRef: number, charCodes: Int32Array); static deserialize(bytes: Uint8Array): Gaddag; serialize(): Uint8Array; /** Number of arcs (including the unused sentinel at index 0). */ get arcsCount(): number; /** * Follows the arc labeled with `letter` from the state `ref` points at. * Returns the target ref, or 0 when there is no such arc. * * A state's arcs are stored in ascending letter order, so the scan stops as * soon as it passes the wanted letter. */ getArc(ref: number, letter: number): number; /** Maps a code point to its letter index, or -1 when the character is not in the alphabet. */ getLetter(charCode: number): number; has(word: string): boolean; hasPrefix(prefix: string): boolean; }