///
import { _A } from "../../../Effect/commons.js";
import * as St from "../../../Structural/index.js";
import { AtomicNumber } from "../../../Support/AtomicNumber/index.js";
export declare const BufferSize = 64;
export declare const ChunkTypeId: unique symbol;
export declare 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 declare 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
*/
export interface Chunk {
readonly [ChunkTypeId]: ChunkTypeId;
readonly [_A]: () => A;
readonly length: number;
[Symbol.iterator](): Iterator;
}
/**
* Internal base class
*/
export declare abstract class ChunkInternal implements Iterable, Chunk, St.HasEquals, St.HasHash {
readonly [ChunkTypeId]: ChunkTypeId;
readonly [_A]: () => A;
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[];
[St.equalsSym](that: unknown): boolean;
get [St.hashSym](): 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 declare 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;
/**
* @ets_optimize remove
*/
export declare function concrete(_: Chunk): asserts _ is Empty | AppendN | Arr | Slice | Singleton | PrependN | Concat;
/**
* @ets_optimize identity
*/
export declare function concreteId(_: Chunk): Empty | AppendN | Arr | Slice | Singleton | PrependN | Concat;
export declare const AppendNTypeId: unique symbol;
export declare 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 declare 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 declare 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 declare 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 declare 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 declare 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
*/
export declare function isChunk(u: Iterable): u is Chunk;
export declare function isChunk(u: unknown): u is Chunk;
/**
* Builds a chunk from an array.
*/
export declare const 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.
*/
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.
*
* @ets_data_first corresponds_
*/
export declare function corresponds(that: Chunk, f: (a: A, b: B) => boolean): (self: Chunk) => boolean;
export declare function toString(self: Chunk): string;
//# sourceMappingURL=definition.d.ts.map