declare class LinkedListEmptyError extends Error { constructor(message?: string); } declare class InvalidIndexError extends Error { constructor(message?: string); } /** * @public */ declare class LinkedList { /** * 没有节点时移除节点错误 */ static readonly LinkedListEmptyError: typeof LinkedListEmptyError; /** * 下标错误 */ static readonly InvalidIndexError: typeof InvalidIndexError; /** * 头结点,占位 * 减少一些判断 */ private head; /** * 节点个数 */ private size; constructor(list?: LinkedList); /** * 长度 */ getSize(): number; /** * 是否为空 */ isEmpty(): boolean; /** * 是否非空 */ isNotEmpty(): boolean; /** * 清空链表 */ clear(): void; /** * 头插 */ insertFirst(value: T): number; /** * 在指定下标插入 */ insertAt(index: number, value: T): number; /** * 尾插 */ insertLast(value: T): number; /** * 移除头结点 */ removeFirst(): T; /** * 移除最后一个节点 */ removeLast(): T; /** * 移除指定下标的节点 */ removeAt(index: number): T; /** * 移除满足条件的节点 */ removeEach(callback: (value: T, index: number, context: LinkedList) => boolean): number; /** * 检查链表是否为空 */ private checkListIsEmpty; /** * 检查下标是否合法 */ private checkIndexIsValid; /** * 深克隆 * 只克隆 LinkedList 中的节点 */ private deepClone; /** * 克隆一个新的list */ clone(list: LinkedList): LinkedList; /** * 遍历链表 */ forEach(callback: (value: T, index: number, context: LinkedList) => void): void; /** * 遍历并过滤 */ filter(callback: (value: T, index: number, context: LinkedList) => boolean): LinkedList; /** * 查找指定值 */ find(callback: (value: T, index: number, context: LinkedList) => boolean): T | undefined; /** * 获取首个元素 */ getFirst(): T; /** * 转数组 */ toArray(): T[]; /** * 迭代器 */ [Symbol.iterator](): { next: () => { value: T; done: boolean; }; }; /** * 创建空间点,比如头结点 */ private createEmptyNode; /** * 从数组创建链表 */ static fromArray(values: T[]): LinkedList; } export default LinkedList;