/** * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. * * from https://github.com/dsehnal/CIFTools.js * @author David Sehnal */ /** * A generic chunked array builder. * * When adding elements, the array grows by a specified number * of elements and no copying is done until ChunkedArray.compact * is called. */ interface ChunkedArray { ctor: { new (size: number): ArrayLike; }; elementSize: C; growBy: number; allocatedSize: number; /** current size of the array */ elementCount: number; currentSize: number; currentChunk: any; currentIndex: number; chunks: any[][]; } declare namespace ChunkedArray { type Sizes = 1 | 2 | 3 | 4; export function is(x: any): x is ChunkedArray; export function add4(array: ChunkedArray, x: T, y: T, z: T, w: T): number; export function add3(array: ChunkedArray, x: T, y: T, z: T): number; export function add2(array: ChunkedArray, x: T, y: T): number; export function add(array: ChunkedArray, x: T): number; export function addRepeat(array: ChunkedArray, n: number, x: T): number; export function addMany(array: ChunkedArray, data: ArrayLike): number; /** If doNotResizeSingleton = true and the data fit into a single chunk, do not resize it. */ export function compact(array: ChunkedArray, doNotResizeSingleton?: boolean): ArrayLike; export function _compact(array: ChunkedArray, doNotResizeSingleton: boolean): ArrayLike; /** * The size of the initial chunk is elementSize * initialCount. * Use the provided array as the initial chunk. The size of the array must be divisible by the elementSize. */ export function create(ctor: { new (size: number): ArrayLike; }, elementSize: C, chunkSize: number, initialChunkOrCount?: number | ArrayLike): ChunkedArray; export {}; } export { ChunkedArray };