UNPKG

@thi.ng/vector-pools

Version:

Data structures for managing & working with strided, memory mapped vectors

43 lines 1.71 kB
import type { Maybe } from "@thi.ng/api"; import { GLType, type Type, type TypedArray } from "@thi.ng/api/typedarray"; import type { MemPoolOpts, MemPoolStats } from "@thi.ng/malloc"; import { MemPool } from "@thi.ng/malloc/pool"; import type { StridedVec } from "@thi.ng/vectors"; import type { IVecPool } from "./api.js"; export declare class VecPool implements IVecPool { pool: MemPool; constructor(pool?: MemPool); constructor(opts?: Partial<MemPoolOpts>); stats(): MemPoolStats; malloc(size: number, type?: GLType | Type): Maybe<TypedArray>; mallocWrapped(size: number, stride?: number, type?: GLType | Type): Maybe<StridedVec>; /** * Intended to provide individual vector views of a larger * underlying buffer. Attempts to allocate a single block of * sufficient memory to hold `num` vectors of `size` elements and if * successful returns array of vectors mapping the buffer with given * stride lengths (both component and element strides can be * provided). * * *Note:* Since all result vectors share the same continuous memory * block, freeing any of them from the pool will invalidate all of * them. * * Also see: * - `Vec2.mapBuffer()` * - `Vec3.mapBuffer()` * - `Vec4.mapBuffer()` * - `NDArray1.mapBuffer()` * * @param num - * @param size - * @param cstride - * @param estride - * @param type - */ mallocArray(num: number, size: number, cstride?: number, estride?: number, type?: GLType | Type): Maybe<StridedVec[]>; free(vec: StridedVec | TypedArray): boolean; freeAll(): void; release(): boolean; } //# sourceMappingURL=vec-pool.d.ts.map