/** * Resizable typed array utilities. * * Wraps typed arrays with automatic buffer expansion (ArrayList semantics). * Uses SharedArrayBuffer (if available) for zero-copy worker transfer. * * @module */ /** * Use SharedArrayBuffer if the runtime supports it, otherwise fall back to ArrayBuffer. * SharedArrayBuffer enables zero-copy transfer between workers. */ export declare const BufferConstructor: ArrayBufferConstructor | SharedArrayBufferConstructor; /** The buffer type used by this runtime (SharedArrayBuffer or ArrayBuffer). */ export type BufferType = InstanceType; /** * Union of all standard typed array types. * Generic over buffer type to preserve SharedArrayBuffer compatibility. */ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; /** * Constructor interface for typed arrays. */ export interface TypedArrayConstructor = TypedArray> { new (buffer: BufferType): T; readonly BYTES_PER_ELEMENT: number; } /** * Float64Array for storing OSM IDs. * * OSM IDs are 64-bit integers. JavaScript's number type (IEEE 754 double) * can exactly represent integers up to 2^53, which covers all current OSM IDs. * Float64Array allows typed array operations while maintaining precision. */ export declare const IdArrayType: Float64ArrayConstructor; /** * Uint32Array for storing array indices. * * Internal indices into typed arrays never exceed 2^32 elements, * so Uint32Array provides the best balance of range and memory efficiency. */ export declare const IndexArrayType: Uint32ArrayConstructor; /** * Initial buffer size for ResizeableTypedArray. * 1 MiB provides reasonable initial capacity while avoiding excessive memory allocation. */ export declare const DEFAULT_BUFFER_SIZE: number; /** * Auto-expanding typed array wrapper. * * - `push()` appends elements, doubling buffer size as needed. * - `compact()` shrinks buffer to fit data. * - Supports growable SharedArrayBuffer and resizable ArrayBuffer. */ export declare class ResizeableTypedArray { /** The typed array constructor for this instance */ ArrayType: TypedArrayConstructor; /** The current typed array view into the buffer */ array: TA; /** Number of items actually stored (may be less than array.length) */ items: number; /** The underlying ArrayBuffer or SharedArrayBuffer */ buffer: BufferType; /** Current buffer size in bytes */ bufferSize: number; /** Maximum byte length for growable buffers */ maxByteLength: number; /** Buffer constructor (SharedArrayBuffer or ArrayBuffer) */ BC: SharedArrayBufferConstructor | ArrayBufferConstructor; /** * Reconstruct a ResizeableTypedArray from an existing buffer. * * Used after transferring buffers between workers. The resulting array * is considered "compacted" with items = array.length. * * @param ArrayType - The typed array constructor. * @param buffer - The existing buffer to wrap. * @returns A new ResizeableTypedArray wrapping the buffer. */ static from(ArrayType: TypedArrayConstructor, buffer: BufferType): ResizeableTypedArray; /** * Create a new ResizeableTypedArray with an empty buffer. * * @param ArrayType - The typed array constructor (e.g., Float64Array). * @param BC - Buffer constructor to use (defaults to SharedArrayBuffer if available). */ constructor(ArrayType: TypedArrayConstructor, BC?: SharedArrayBufferConstructor | ArrayBufferConstructor); /** * Iterate over the array values. */ [Symbol.iterator](): ArrayIterator; /** * Double the buffer capacity. * Uses in-place grow/resize if supported, otherwise allocates new buffer and copies. */ expandArray(): void; /** * Get the value at an index. Handles negative indices. */ at(index: number): number; /** * Get a slice of the array. */ slice(start: number, end: number): Float32Array | Float64Array | Int16Array | Int32Array | Int8Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray; get length(): number; /** * Push a value to the end of the array. */ push(value: number): number; /** * Set a value at a specific index. Expands array if needed. */ set(index: number, value: number): void; /** * Push multiple values to the end of the array. */ pushMany(values: number[] | TypedArray): void; /** * Shrink the buffer to exactly fit stored items. * Buffer becomes fixed-length after compacting. */ compact(): TA; } //# sourceMappingURL=typed-arrays.d.ts.map