/// import { Collection } from "@tsplus/stdlib/collections/Collection/definition"; import { HKT } from "@tsplus/stdlib/prelude/HKT"; import { Equals } from "@tsplus/stdlib/structure/Equals"; import { Hash } from "@tsplus/stdlib/structure/Hash"; import { AtomicNumber } from "@tsplus/stdlib/data/AtomicNumber"; import { IndexOutOfBounds } from "@tsplus/stdlib/exceptions"; export declare const BufferSize = 64; export declare const ChunkTypeId: unique symbol; export type ChunkTypeId = typeof ChunkTypeId; export declare const alloc: ((size: number, fill?: string | number | Buffer | undefined, encoding?: BufferEncoding | undefined) => Buffer) | ((n: number) => Uint8Array); export declare function isByte(u: unknown): boolean; export type IterableArrayLike = ArrayLike & Iterable; /** * A `Chunk` represents a chunk of values of type `A`. Chunks are usually * backed by arrays, but expose a purely functional, safe interface * to the underlying elements, and they become lazy on operations that would be * costly with arrays, such as repeated concatenation. * * The implementation of balanced concatenation is based on the one for * Conc-Trees in "Conc-Trees for Functional and Parallel Programming" by * Aleksandar Prokopec and Martin Odersky. * * http://aleksandar-prokopec.com/resources/docs/lcpc-conc-trees.pdf * * @tsplus type Chunk */ export interface Chunk extends Collection { readonly [ChunkTypeId]: ChunkTypeId; readonly length: number; [Symbol.iterator](): Iterator; } export interface ChunkF extends HKT { readonly type: Chunk; } export declare namespace Chunk { type HKT = ChunkF; } /** * @tsplus type Chunk.Ops */ export interface ChunkOps { $: ChunkAspects; } export declare const Chunk: ChunkOps; /** * @tsplus type Chunk.Aspects */ export interface ChunkAspects { } /** * @tsplus unify Chunk */ export declare function unifyChunk>(self: X): Chunk<[X] extends [Chunk] ? A : never>; /** * Internal base class */ export declare abstract class ChunkInternal implements Chunk, Equals { readonly [ChunkTypeId]: ChunkTypeId; abstract readonly binary: boolean; abstract readonly length: number; abstract readonly depth: number; abstract readonly left: ChunkInternal; abstract readonly right: ChunkInternal; abstract _copyToArray(n: number, array: Array | Uint8Array): void; abstract _get(n: number): A; protected arrayLikeCache: IterableArrayLike | undefined; _arrayLike(): IterableArrayLike; private arrayCache; _array(): readonly A[]; [Equals.sym](that: unknown): boolean; [Hash.sym](): number; toString(): string; toJSON(): readonly A[]; abstract [Symbol.iterator](): Iterator; abstract _arrayLikeIterator(): Iterator>; abstract _reverseArrayLikeIterator(): Iterator>; _buckets(): Iterable>; _reverseBuckets(): Iterable>; _reverse(): Iterable; _materialize(): ChunkInternal; _append(a1: A1): ChunkInternal; _prepend(a1: A1): ChunkInternal; _take(n: number): ChunkInternal; _concat(that: ChunkInternal): ChunkInternal; } export declare const EmptyTypeId: unique symbol; export type EmptyTypeId = typeof EmptyTypeId; /** * Internal Empty Chunk */ export declare class Empty extends ChunkInternal { readonly depth = 0; readonly _typeId: EmptyTypeId; readonly left: this; readonly right: this; readonly binary = true; readonly length = 0; _get(n: number): A; constructor(); _materialize(): ChunkInternal; _copyToArray(_n: number, _array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } export declare const _Empty: ChunkInternal; /** * @tsplus macro remove */ export declare function concreteChunk(_: Chunk): asserts _ is Empty | AppendN | Arr | Slice | Singleton | PrependN | Concat; /** * @tsplus macro identity */ export declare function concreteChunkId(_: Chunk): Empty | AppendN | Arr | Slice | Singleton | PrependN | Concat; export declare const AppendNTypeId: unique symbol; export type AppendNTypeId = typeof AppendNTypeId; /** * Internal Append Chunk */ export declare class AppendN extends ChunkInternal { readonly start: ChunkInternal; readonly buffer: Array | Uint8Array; readonly bufferUsed: number; readonly chain: AtomicNumber; readonly binary: boolean; readonly _typeId: AppendNTypeId; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly length: number; constructor(start: ChunkInternal, buffer: Array | Uint8Array, bufferUsed: number, chain: AtomicNumber, binary: boolean); _get(n: number): A; _append(a1: A1): ChunkInternal; _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } export declare const ArrTypeId: unique symbol; export type ArrTypeId = typeof ArrTypeId; /** * Internal Array Chunk */ export declare abstract class Arr extends ChunkInternal { readonly _typeId: ArrTypeId; } /** * Internal Plain Array Chunk */ export declare class PlainArr extends Arr { readonly array: readonly A[]; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly length: number; private isBytes?; constructor(array: readonly A[]); get binary(): boolean; _get(n: number): A; _arrayLike(): IterableArrayLike; _array(): readonly A[]; _materialize(): this; _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } /** * Internal Binary Array Chunk */ export declare class Uint8Arr extends Arr { readonly array: Uint8Array; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly length: number; readonly binary = true; constructor(array: Uint8Array); _arrayLike(): Uint8Array; _get(n: number): number; _materialize(): this; _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } export declare const SliceTypeId: unique symbol; export type SliceTypeId = typeof SliceTypeId; /** * Internal Slice Chunk */ export declare class Slice extends ChunkInternal { readonly chunk: ChunkInternal; readonly offset: number; readonly length: number; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly binary: boolean; readonly _typeId: SliceTypeId; _get(n: number): A; constructor(chunk: ChunkInternal, offset: number, length: number); _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } export declare const SingletonTypeId: unique symbol; export type SingletonTypeId = typeof SingletonTypeId; /** * Internal Singleton Chunk */ export declare class Singleton extends ChunkInternal { readonly a: A; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly length = 1; readonly _typeId: SingletonTypeId; _get(n: number): A; readonly binary: boolean; constructor(a: A); _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } export declare const PrependNTypeId: unique symbol; export type PrependNTypeId = typeof PrependNTypeId; /** * Internal Prepend Chunk */ export declare class PrependN extends ChunkInternal { readonly end: ChunkInternal; readonly buffer: Array | Uint8Array; readonly bufferUsed: number; readonly chain: AtomicNumber; readonly binary: boolean; readonly depth = 0; readonly left: ChunkInternal; readonly right: ChunkInternal; readonly length: number; readonly _typeId: PrependNTypeId; _get(n: number): A; constructor(end: ChunkInternal, buffer: Array | Uint8Array, bufferUsed: number, chain: AtomicNumber, binary: boolean); _copyToArray(n: number, array: Array | Uint8Array): void; prepend(a1: A1): ChunkInternal; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } /** * Internal copy arrays */ export declare function _copy(src: IterableArrayLike, srcPos: number, dest: A[] | Uint8Array, destPos: number, len: number): Uint8Array | A[]; export declare const ConcatTypeId: unique symbol; export type ConcatTypeId = typeof ConcatTypeId; /** * Internal Concat Chunk */ export declare class Concat extends ChunkInternal { readonly left: ChunkInternal; readonly right: ChunkInternal; readonly depth: number; readonly _typeId: ConcatTypeId; readonly length: number; readonly binary: boolean; _get(n: number): A; constructor(left: ChunkInternal, right: ChunkInternal); _copyToArray(n: number, array: Array | Uint8Array): void; [Symbol.iterator](): Iterator; _arrayLikeIterator(): Iterator>; _reverseArrayLikeIterator(): Iterator>; } /** * Type guard * @tsplus static Chunk.Ops isChunk * @tsplus location "@tsplus/stdlib/collections/Chunk/definition" */ export declare function isChunk(u: Iterable): u is Chunk; export declare function isChunk(u: unknown): u is Chunk; /** * Builds a chunk from an array. * @tsplus static Chunk.Ops from * @tsplus location "@tsplus/stdlib/collections/Chunk/definition" */ export declare function from(array: Iterable): Chunk; /** * Determines whether this chunk and the specified chunk have the same length * and every pair of corresponding elements of this chunk and the specified * chunk satisfy the specified predicate. * @tsplus fluent Chunk corresponds * @tsplus location "@tsplus/stdlib/collections/Chunk/definition" */ export declare function corresponds_(self: Chunk, that: Chunk, f: (a: A, b: B) => boolean): boolean; /** * Determines whether this chunk and the specified chunk have the same length * and every pair of corresponding elements of this chunk and the specified * chunk satisfy the specified predicate. * @tsplus static Chunk.Aspects corresponds * @tsplus pipeable Chunk corresponds * @tsplus location "@tsplus/stdlib/collections/Chunk/definition" */ export declare const corresponds: (that: Chunk, f: (a: A, b: B) => boolean) => (self: Chunk) => boolean; //# sourceMappingURL=definition.d.ts.map