/** * Generic typed ring buffer (circular buffer). * Overwrites oldest entries when capacity is exceeded. */ export declare class RingBuffer { private capacity; private buffer; private head; private count; private nextId; private pushCallback; constructor(capacity: number); /** Register a callback that fires whenever a new item is pushed. */ onPush(cb: ((item: T) => void) | null): void; push(item: T): void; /** Returns all items in insertion order (oldest first). */ toArray(): T[]; /** Returns the most recent N items (newest first). */ latest(n: number): T[]; getNextId(): number; size(): number; getCapacity(): number; clear(): void; /** * Find a single item by predicate, searching from newest to oldest. * Returns immediately on first match without copying the buffer. */ findFromEnd(predicate: (item: T) => boolean): T | undefined; /** * Collect items from the end of the buffer while the predicate holds. * Iterates from newest to oldest and stops at the first non-match. * Returns items in insertion order (oldest first). * * Useful for efficiently getting "items since ID X" without copying the * entire buffer, since IDs are monotonically increasing. */ collectFromEnd(predicate: (item: T) => boolean): T[]; /** Bulk-load items (e.g. from disk). Pushes each in order, respecting capacity. */ load(items: T[]): void; /** Restore the auto-increment counter (e.g. after loading persisted data). */ setNextId(id: number): void; }