UNPKG

@thi.ng/dcons

Version:

Double-linked lists with comprehensive set of operations (incl. optional self-organizing behaviors)

52 lines 2.44 kB
import type { Comparator, Fn, IClear, ICopy, IEmpty, IEquiv, IInto, ILength, IRelease, Maybe, Predicate } from "@thi.ng/api"; import { type IReducible, type Reduced, type ReductionFn } from "@thi.ng/transducers"; import type { ConsCell } from "./api.js"; export declare abstract class AList<L extends AList<any, T>, T> implements IClear, ICopy<L>, IEmpty<L>, IEquiv, IInto<T, L>, Iterable<T>, ILength, IReducible<T, any>, IRelease { _head: Maybe<ConsCell<T>>; protected _length: number; constructor(src?: Iterable<T>); get length(): number; get head(): Maybe<ConsCell<T>>; abstract get tail(): Maybe<ConsCell<T>>; [Symbol.iterator](): Generator<T, void, unknown>; reverseIterator(): Generator<T, void, unknown>; abstract append(n: T): ConsCell<T>; clear(): void; compare(o: L, cmp?: Comparator<T>): number; concat(...slices: Iterable<T>[]): L; abstract copy(): L; abstract drop(): Maybe<T>; abstract empty(): L; equiv(o: any): boolean; filter(fn: Predicate<T>): L; find(value: T): ConsCell<T> | undefined; findWith(fn: Predicate<T>): ConsCell<T> | undefined; first(): T | undefined; abstract insertAfter(cell: ConsCell<T>, value: T): ConsCell<T>; abstract insertBefore(cell: ConsCell<T>, value: T): ConsCell<T>; insertSorted(value: T, cmp?: Comparator<T>): ConsCell<T>; into(src: Iterable<T>): L; nth(n: number, notFound?: T): T | undefined; abstract nthCell(n: number): Maybe<ConsCell<T>>; nthCellUnsafe(n: number): Maybe<ConsCell<T>>; peek(): T | undefined; abstract prepend(n: T): ConsCell<T>; /** * Implementation of * [IReducible.$reduce](https://docs.thi.ng/umbrella/transducers/interfaces/IReducible.html#_reduce._reduce-1) */ $reduce<R>(rfn: ReductionFn<T, any>, acc: R | Reduced<R>): R | Reduced<R>; reduce<R>(rfn: ReductionFn<T, R>, initial: R | Reduced<R>): R | Reduced<R>; release(): boolean; reverse(): this; setHead(v: T): ConsCell<T>; setNth(n: number, v: T): Maybe<ConsCell<T>>; setTail(v: T): ConsCell<T>; swap(a: ConsCell<T>, b: ConsCell<T>): this; toArray(out?: T[]): T[]; toJSON(): T[]; toString(): any; traverse(fn: Fn<ConsCell<T>, boolean | number>, start?: Maybe<ConsCell<T>>, end?: Maybe<ConsCell<T>>): ConsCell<T> | undefined; protected _map<R extends AList<any, V>, V>(res: R, fn: Fn<T, V>): R; } //# sourceMappingURL=alist.d.ts.map