export type Many = [T, T, ...T[]]; export type OneMany = T | Many; export type Opt = undefined | OneMany; export type Compare = (a: T, b: T) => number; declare const kSorted: unique symbol; export type SortedMany = Many & { readonly [kSorted]: true; }; export type SortedOneMany = T | SortedMany; export type SortedOpt = undefined | SortedOneMany; export declare class Sorted { compare: Compare; constructor(compare: Compare); add>(data: SortedOpt, item: U): SortedOneMany; union>(a: SortedOpt, b: SortedOpt): SortedOpt; filter>(data: SortedOpt, cb: (item: U) => boolean): SortedOpt; leadingRun, K>(data: SortedOpt, key: (item: U) => K, compareKeys: Compare, bound: K): SortedOpt; range, K>(data: SortedOpt, key: (item: U) => K, compareKeys: Compare, bound: K): SortedOpt; forEachRun, K>(data: SortedOpt, key: (item: U) => K, compareKeys: Compare, fn: (key: K, run: SortedOneMany) => void): void; reduceRuns, K, R>(data: SortedOpt, key: (item: U) => K, compareKeys: Compare, fn: (acc: R, key: K, run: SortedOneMany) => R, initial: R): R; find>(data: SortedOpt, item: U): U | undefined; has>(data: SortedOpt, item: U): boolean; findIndex>(data: SortedOpt, item: U): number; intersects>(a: SortedOpt, b: SortedOpt): boolean; difference>(a: SortedOpt, b: SortedOpt): SortedOpt; isSuperset>(superset: SortedOpt, subset: SortedOpt): boolean; } export declare function push(data: Opt, item: T): OneMany; export declare function concat(a: Opt, b: Opt): Opt; export declare function size(data: Opt): number; export declare function filter(data: Opt, cb: (item: T) => boolean): Opt; export declare function forEach(data: Opt, cb: (item: T, index: number) => void): void; export declare function fromIter(data: Iterable): T | Many | undefined; export declare function find(data: Opt, cb: (item: T, index: number) => boolean): Opt; export declare function some(data: Opt, cb: (item: T, index: number) => unknown): boolean; export declare function every(data: Opt, cb: (item: T, index: number) => boolean): boolean; export declare function reduce(data: Opt, cb: (acc: R | undefined, item: T, index: number) => R | undefined): R | undefined; export declare function reduce(data: Opt, cb: (acc: R, item: T, index: number) => R, initial: R): R; export declare function reduceWhile(data: Opt, cb: (acc: R, item: T) => R | undefined, initial: R): R | undefined; export declare function toArray(data: Opt, cb: (item: T, index: number) => R): R[]; export declare function toSet(data: Opt): Set; export declare function mapToString(data: Opt, sep: string, cb: (item: T, index: number) => string): string; export declare function findSorted(compare: Compare, data: T[], item: T): T | undefined; export declare function findIndexSorted(compare: Compare, data: T[], item: T): number; export declare function addSorted(compare: Compare, data: U, item: T): U; export declare function at(data: Opt, index: number): T | undefined; export declare function first(data: OneMany): T; export declare function last(data: OneMany): T; export declare function rest(data: OneMany): Opt; export {};