/** * Generic fixed-capacity ring buffer (circular buffer). * * All writes are O(1). When the buffer is full the oldest entry is evicted * (FIFO); eviction is observable through `evictedCount` and the optional * `onEvict` callback. Reading all entries is O(n) where n ≤ capacity. * * This is the canonical ring-buffer utility for the SDK. Prefer this over * ad-hoc implementations when bounded-memory queues are needed. */ export interface RingBufferOptions { readonly onEvict?: ((item: T) => void) | undefined; } /** * A generic ring buffer with a fixed capacity. * * Entries are stored in insertion order. When the buffer is full the oldest * entry is overwritten (FIFO eviction). All push operations are O(1). */ export declare class RingBuffer { private readonly _buf; private readonly _onEvict; private _head; private _count; private _evictedCount; readonly capacity: number; constructor(capacity: number, options?: RingBufferOptions); /** Number of entries currently stored (≤ capacity). */ get size(): number; /** True when the buffer holds at least one entry. */ get isEmpty(): boolean; /** Number of entries evicted since construction or the last `clear()`. */ get evictedCount(): number; /** * Push an entry into the buffer. * * If the buffer is full the oldest entry is evicted to make room and * `evictedCount` is incremented. * Always O(1). */ push(item: T): void; /** * Return all entries in insertion order (oldest → newest). * * Allocates a new array of length `size` per call. */ toArray(): T[]; /** * Return the N most recent entries in insertion order (oldest → newest). * * If `n >= size` returns the same result as `toArray()`. */ takeLast(n: number): T[]; /** * Return the N most recent entries in reverse insertion order (newest → oldest). * * Useful for "latest first" display without an extra `.reverse()` call. */ takeLastReversed(n: number): T[]; /** Remove all entries and reset internal state. Capacity is preserved. */ clear(): void; } //# sourceMappingURL=ring-buffer.d.ts.map