@thi.ng/dcons
Version:
Double-linked lists with comprehensive set of operations (incl. optional self-organizing behaviors)
37 lines • 1.41 kB
TypeScript
import type { Fn, ICompare, ICopy, IEmpty, ISeq, Maybe } from "@thi.ng/api";
import { AList } from "./alist.js";
import type { ConsCell } from "./api.js";
/**
* A closed-loop doubly-linked list/ring with a similar (but more limited API)
* as {@link DCons}.
*/
export declare class DRing<T> extends AList<DRing<T>, T> implements ICopy<DRing<T>>, ICompare<DRing<T>>, IEmpty<DRing<T>> {
constructor(src?: Iterable<T>);
get tail(): Maybe<ConsCell<T>>;
append(value: T): ConsCell<T>;
copy(): DRing<T>;
drop(): T | undefined;
empty(): DRing<T>;
insertBefore(cell: ConsCell<T>, value: T): ConsCell<T>;
insertAfter(cell: ConsCell<T>, value: T): ConsCell<T>;
map<R>(fn: Fn<T, R>): DRing<R>;
nth(n: number, notFound?: T): T | undefined;
nthCell(n: number): Maybe<ConsCell<T>>;
prepend(value: T): ConsCell<T>;
remove(v: ConsCell<T>): void;
rotateLeft(): this;
rotateRight(): this;
/**
* Implementation of
* [ISeqable.seq](https://docs.thi.ng/umbrella/api/interfaces/ISeqable.html#seq.seq-1)
*/
seq(): ISeq<T> | undefined;
traverse(fn: Fn<ConsCell<T>, boolean | number>, start?: Maybe<ConsCell<T>>, end?: Maybe<ConsCell<T>>): ConsCell<T> | undefined;
}
/**
* Functional syntax sugar for `new DRing(src?)`.
*
* @param src -
*/
export declare const defDRing: <T>(src?: Iterable<T>) => DRing<T>;
//# sourceMappingURL=ring.d.ts.map