{"version":3,"sources":["../../src/data-structures/base/iterable-element-base.ts","../../src/data-structures/base/linear-base.ts","../../src/data-structures/linked-list/singly-linked-list.ts","../../src/utils/utils.ts","../../src/common/index.ts"],"names":["value","DFSOperation"],"mappings":";;;;;;;;AAaO,IAAe,oBAAA,GAAf,MAAe,oBAAA,CAAiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU3D,YAAY,OAAA,EAA4C;AAclE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,aAAA,CAAA,IAAA,EAAU,cAAA,CAAA;AAbR,IAAA,IAAI,OAAA,EAAS;AACX,MAAA,MAAM,EAAE,aAAY,GAAI,OAAA;AACxB,MAAA,IAAI,OAAO,WAAA,KAAgB,UAAA,EAAY,IAAA,CAAK,YAAA,GAAe,WAAA;AAAA,WAAA,IAClD,WAAA,EAAa,MAAM,IAAI,SAAA,CAAU,qCAAqC,CAAA;AAAA,IACjF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,IAAI,WAAA,GAAkD;AACpD,IAAA,OAAO,IAAA,CAAK,YAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,EAAE,MAAA,CAAO,QAAQ,CAAA,CAAA,GAAK,IAAA,EAAsC;AAC1D,IAAA,OAAO,IAAA,CAAK,YAAA,CAAa,GAAG,IAAI,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,CAAC,MAAA,GAA8B;AAC7B,IAAA,KAAA,MAAW,IAAA,IAAQ,MAAM,MAAM,IAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,KAAA,CAAM,WAA2C,OAAA,EAA4B;AAC3E,IAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,IAAA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IAAI,EAAE,YAAA,CAAa,GAAG,CAAA,IAAK,YAAA,CAAa,IAAI,CAAA,CAAA,EAAI,MAAM,IAAI,UAAA,CAAW,+BAA+B,CAAA;AACpG,IAAA,IAAI,GAAA,GAAM,IAAA,EAAM,MAAM,IAAI,WAAW,wCAAwC,CAAA;AAAA,EAC/E;AAAA;AAAA,EAGA,SAAA,CAAU,KAAQ,UAAA,EAA6C;AAC7D,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,UAAA,GAAa,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,GAAG,CAAA,IAAK,CAAA,GAAI,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,GAAG,CAAA,GAAI,CAAA;AAChG,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,WAAA,GAAc,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,IAAI,CAAA,IAAK,CAAA,GAAI,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,IAAI,CAAA,GAAI,CAAA;AACpG,IAAA,OAAO,QAAA,IAAY,SAAA;AAAA,EACrB;AACF,CAAA;AAjBsB,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA;AAAf,IAAM,KAAA,GAAN","file":"index.cjs","sourcesContent":["import type { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';\n\n/**\n * Base class that makes a data structure iterable and provides common\n * element-wise utilities (e.g., map/filter/reduce/find).\n *\n * @template E The public element type yielded by the structure.\n * @template R The underlying \"raw\" element type used internally or by converters.\n *\n * @remarks\n * This class implements the JavaScript iteration protocol (via `Symbol.iterator`)\n * and offers array-like helpers with predictable time/space complexity.\n */\nexport abstract class IterableElementBase<E, R> implements Iterable<E> {\n  /**\n   * Create a new iterable base.\n   *\n   * @param options Optional behavior overrides. When provided, a `toElementFn`\n   * is used to convert a raw element (`R`) into a public element (`E`).\n   *\n   * @remarks\n   * Time O(1), Space O(1).\n   */\n  protected constructor(options?: IterableElementBaseOptions<E, R>) {\n    if (options) {\n      const { toElementFn } = options;\n      if (typeof toElementFn === 'function') this._toElementFn = toElementFn;\n      else if (toElementFn) throw new TypeError('toElementFn must be a function type');\n    }\n  }\n\n  /**\n   * The converter used to transform a raw element (`R`) into a public element (`E`).\n   *\n   * @remarks\n   * Time O(1), Space O(1).\n   */\n  protected _toElementFn?: (rawElement: R) => E;\n\n  /**\n   * Exposes the current `toElementFn`, if configured.\n   *\n   * @returns The converter function or `undefined` when not set.\n   * @remarks\n   * Time O(1), Space O(1).\n   */\n  get toElementFn(): ((rawElement: R) => E) | undefined {\n    return this._toElementFn;\n  }\n\n  /**\n   * Returns an iterator over the structure's elements.\n   *\n   * @param args Optional iterator arguments forwarded to the internal iterator.\n   * @returns An `IterableIterator<E>` that yields the elements in traversal order.\n   *\n   * @remarks\n   * Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.\n   */\n  *[Symbol.iterator](...args: unknown[]): IterableIterator<E> {\n    yield* this._getIterator(...args);\n  }\n\n  /**\n   * Returns an iterator over the values (alias of the default iterator).\n   *\n   * @returns An `IterableIterator<E>` over all elements.\n   * @remarks\n   * Creating the iterator is O(1); full iteration is Time O(n), Space O(1).\n   */\n  *values(): IterableIterator<E> {\n    for (const item of this) yield item;\n  }\n\n  /**\n   * Tests whether all elements satisfy the predicate.\n   *\n   * @template TReturn\n   * @param predicate Function invoked for each element with signature `(value, index, self)`.\n   * @param thisArg Optional `this` binding for the predicate.\n   * @returns `true` if every element passes; otherwise `false`.\n   *\n   * @remarks\n   * Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).\n   */\n  every(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {\n    let index = 0;\n    for (const item of this) {\n      if (thisArg === undefined) {\n        if (!predicate(item, index++, this)) return false;\n      } else {\n        const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n        if (!fn.call(thisArg, item, index++, this)) return false;\n      }\n    }\n    return true;\n  }\n\n  /**\n   * Tests whether at least one element satisfies the predicate.\n   *\n   * @param predicate Function invoked for each element with signature `(value, index, self)`.\n   * @param thisArg Optional `this` binding for the predicate.\n   * @returns `true` if any element passes; otherwise `false`.\n   *\n   * @remarks\n   * Time O(n) in the worst case; may exit early on first success. Space O(1).\n   */\n  some(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): boolean {\n    let index = 0;\n    for (const item of this) {\n      if (thisArg === undefined) {\n        if (predicate(item, index++, this)) return true;\n      } else {\n        const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n        if (fn.call(thisArg, item, index++, this)) return true;\n      }\n    }\n    return false;\n  }\n\n  /**\n   * Invokes a callback for each element in iteration order.\n   *\n   * @param callbackfn Function invoked per element with signature `(value, index, self)`.\n   * @param thisArg Optional `this` binding for the callback.\n   * @returns `void`.\n   *\n   * @remarks\n   * Time O(n), Space O(1).\n   */\n  forEach(callbackfn: ElementCallback<E, R, void>, thisArg?: unknown): void {\n    let index = 0;\n    for (const item of this) {\n      if (thisArg === undefined) {\n        callbackfn(item, index++, this);\n      } else {\n        const fn = callbackfn as (this: unknown, v: E, i: number, self: this) => void;\n        fn.call(thisArg, item, index++, this);\n      }\n    }\n  }\n\n  /**\n   * Finds the first element that satisfies the predicate and returns it.\n   *\n   * @overload\n   * Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.\n   * @template S\n   * @param predicate Type-guard predicate: `(value, index, self) => value is S`.\n   * @param thisArg Optional `this` binding for the predicate.\n   * @returns The matched element typed as `S`, or `undefined` if not found.\n   *\n   * @overload\n   * @param predicate Boolean predicate: `(value, index, self) => boolean`.\n   * @param thisArg Optional `this` binding for the predicate.\n   * @returns The first matching element as `E`, or `undefined` if not found.\n   *\n   * @remarks\n   * Time O(n) in the worst case; may exit early on the first match. Space O(1).\n   */\n  find<S extends E>(predicate: ElementCallback<E, R, S>, thisArg?: unknown): S | undefined;\n  find(predicate: ElementCallback<E, R, unknown>, thisArg?: unknown): E | undefined;\n\n  // Implementation signature\n  find(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): E | undefined {\n    let index = 0;\n    for (const item of this) {\n      if (thisArg === undefined) {\n        if (predicate(item, index++, this)) return item;\n      } else {\n        const fn = predicate as (this: unknown, v: E, i: number, self: this) => boolean;\n        if (fn.call(thisArg, item, index++, this)) return item;\n      }\n    }\n    return;\n  }\n\n  /**\n   * Checks whether a strictly-equal element exists in the structure.\n   *\n   * @param element The element to test with `===` equality.\n   * @returns `true` if an equal element is found; otherwise `false`.\n   *\n   * @remarks\n   * Time O(n) in the worst case. Space O(1).\n   */\n  has(element: E): boolean {\n    for (const ele of this) if (ele === element) return true;\n    return false;\n  }\n\n  reduce(callbackfn: ReduceElementCallback<E, R>): E;\n  reduce(callbackfn: ReduceElementCallback<E, R>, initialValue: E): E;\n  reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue: U): U;\n\n  /**\n   * Reduces all elements to a single accumulated value.\n   *\n   * @overload\n   * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.\n   * @returns The final accumulated value typed as `E`.\n   *\n   * @overload\n   * @param callbackfn Reducer of signature `(acc, value, index, self) => nextAcc`.\n   * @param initialValue The initial accumulator value of type `E`.\n   * @returns The final accumulated value typed as `E`.\n   *\n   * @overload\n   * @template U The accumulator type when it differs from `E`.\n   * @param callbackfn Reducer of signature `(acc: U, value, index, self) => U`.\n   * @param initialValue The initial accumulator value of type `U`.\n   * @returns The final accumulated value typed as `U`.\n   *\n   * @remarks\n   * Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.\n   */\n  reduce<U>(callbackfn: ReduceElementCallback<E, R, U>, initialValue?: U): U {\n    let index = 0;\n    const iter = this[Symbol.iterator]();\n    let acc: U;\n\n    if (arguments.length >= 2) {\n      acc = initialValue as U;\n    } else {\n      const first = iter.next();\n      if (first.done) throw new TypeError('Reduce of empty structure with no initial value');\n      acc = first.value as unknown as U;\n      index = 1;\n    }\n\n    for (const value of iter as unknown as Iterable<E>) {\n      acc = callbackfn(acc, value, index++, this);\n    }\n    return acc;\n  }\n\n  /**\n   * Materializes the elements into a new array.\n   *\n   * @returns A shallow array copy of the iteration order.\n   * @remarks\n   * Time O(n), Space O(n).\n   */\n  toArray(): E[] {\n    return [...this];\n  }\n\n  /**\n   * Returns a representation of the structure suitable for quick visualization.\n   * Defaults to an array of elements; subclasses may override to provide richer visuals.\n   *\n   * @returns A visual representation (array by default).\n   * @remarks\n   * Time O(n), Space O(n).\n   */\n  toVisual(): E[] {\n    return [...this];\n  }\n\n  /**\n   * Prints `toVisual()` to the console. Intended for quick debugging.\n   *\n   * @returns `void`.\n   * @remarks\n   * Time O(n) due to materialization, Space O(n) for the intermediate representation.\n   */\n  print(): void {\n    console.log(this.toVisual());\n  }\n\n  /**\n   * Indicates whether the structure currently contains no elements.\n   *\n   * @returns `true` if empty; otherwise `false`.\n   * @remarks\n   * Expected Time O(1), Space O(1) for most implementations.\n   */\n  abstract isEmpty(): boolean;\n\n  /**\n   * Removes all elements from the structure.\n   *\n   * @returns `void`.\n   * @remarks\n   * Expected Time O(1) or O(n) depending on the implementation; Space O(1).\n   */\n  abstract clear(): void;\n\n  /**\n   * Creates a structural copy with the same element values and configuration.\n   *\n   * @returns A clone of the current instance (same concrete type).\n   * @remarks\n   * Expected Time O(n) to copy elements; Space O(n).\n   */\n  abstract clone(): this;\n\n  /**\n   * Maps each element to a new element and returns a new iterable structure.\n   *\n   * @template EM The mapped element type.\n   * @template RM The mapped raw element type used internally by the target structure.\n   * @param callback Function with signature `(value, index, self) => mapped`.\n   * @param options Optional options for the returned structure, including its `toElementFn`.\n   * @param thisArg Optional `this` binding for the callback.\n   * @returns A new `IterableElementBase<EM, RM>` containing mapped elements.\n   *\n   * @remarks\n   * Time O(n), Space O(n).\n   */\n  abstract map<EM, RM>(\n    callback: ElementCallback<E, R, EM>,\n    options?: IterableElementBaseOptions<EM, RM>,\n    thisArg?: unknown\n  ): IterableElementBase<EM, RM>;\n\n  /**\n   * Maps each element to the same element type and returns the same concrete structure type.\n   *\n   * @param callback Function with signature `(value, index, self) => mappedValue`.\n   * @param thisArg Optional `this` binding for the callback.\n   * @returns A new instance of the same concrete type with mapped elements.\n   *\n   * @remarks\n   * Time O(n), Space O(n).\n   */\n  abstract mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;\n\n  /**\n   * Filters elements using the provided predicate and returns the same concrete structure type.\n   *\n   * @param predicate Function with signature `(value, index, self) => boolean`.\n   * @param thisArg Optional `this` binding for the predicate.\n   * @returns A new instance of the same concrete type containing only elements that pass the predicate.\n   *\n   * @remarks\n   * Time O(n), Space O(k) where `k` is the number of kept elements.\n   */\n  abstract filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;\n\n  /**\n   * Internal iterator factory used by the default iterator.\n   *\n   * @param args Optional iterator arguments.\n   * @returns An iterator over elements.\n   *\n   * @remarks\n   * Implementations should yield in O(1) per element with O(1) extra space when possible.\n   */\n  protected abstract _getIterator(...args: unknown[]): IterableIterator<E>;\n}\n","import type { ElementCallback, LinearBaseOptions, ReduceLinearCallback } from '../../types';\nimport { IterableElementBase } from './iterable-element-base';\n\n/**\n * Singly-linked list node.\n * @template E - Element type.\n * @remarks Time O(1), Space O(1)\n */\nexport class LinkedListNode<E = any> {\n  /**\n   * Initialize a node.\n   * @param value - Element value.\n   * @remarks Time O(1), Space O(1)\n   */\n  constructor(value: E) {\n    this._value = value;\n    this._next = undefined;\n  }\n\n  protected _value: E;\n\n  /**\n   * Element payload getter.\n   * @returns Element value.\n   * @remarks Time O(1), Space O(1)\n   */\n  get value(): E {\n    return this._value;\n  }\n\n  /**\n   * Element payload setter.\n   * @param value - New value.\n   * @remarks Time O(1), Space O(1)\n   */\n  set value(value: E) {\n    this._value = value;\n  }\n\n  protected _next: LinkedListNode<E> | undefined;\n\n  /**\n   * Next node getter.\n   * @returns Next node or `undefined`.\n   * @remarks Time O(1), Space O(1)\n   */\n  get next(): LinkedListNode<E> | undefined {\n    return this._next;\n  }\n\n  /**\n   * Next node setter.\n   * @param value - Next node or `undefined`.\n   * @remarks Time O(1), Space O(1)\n   */\n  set next(value: LinkedListNode<E> | undefined) {\n    this._next = value;\n  }\n}\n\n/**\n * Abstract linear container with array-like utilities.\n * @template E - Element type.\n * @template R - Return type for mapped/derived views.\n * @template NODE - Linked node type used by some implementations.\n * @remarks Time O(1), Space O(1)\n */\nexport abstract class LinearBase<\n  E,\n  R = any,\n  NODE extends LinkedListNode<E> = LinkedListNode<E>\n> extends IterableElementBase<E, R> {\n  /**\n   * Construct a linear container with runtime options.\n   * @param options - `{ maxLen?, ... }` bounds/behavior options.\n   * @remarks Time O(1), Space O(1)\n   */\n  protected constructor(options?: LinearBaseOptions<E, R>) {\n    super(options);\n    if (options) {\n      const { maxLen } = options;\n      if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n    }\n  }\n\n  /**\n   * Element count.\n   * @returns Number of elements.\n   * @remarks Time O(1), Space O(1)\n   */\n  abstract get length(): number;\n\n  protected _maxLen: number = -1;\n\n  /**\n   * Upper bound for length (if positive), or `-1` when unbounded.\n   * @returns Maximum allowed length.\n   * @remarks Time O(1), Space O(1)\n   */\n  get maxLen() {\n    return this._maxLen;\n  }\n\n  /**\n   * First index of a value from the left.\n   * @param searchElement - Value to match.\n   * @param fromIndex - Start position (supports negative index).\n   * @returns Index or `-1` if not found.\n   * @remarks Time O(n), Space O(1)\n   */\n  indexOf(searchElement: E, fromIndex: number = 0): number {\n    if (this.length === 0) return -1;\n    if (fromIndex < 0) fromIndex = this.length + fromIndex;\n    if (fromIndex < 0) fromIndex = 0;\n\n    for (let i = fromIndex; i < this.length; i++) {\n      const element = this.at(i);\n      if (element === searchElement) return i;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Last index of a value from the right.\n   * @param searchElement - Value to match.\n   * @param fromIndex - Start position (supports negative index).\n   * @returns Index or `-1` if not found.\n   * @remarks Time O(n), Space O(1)\n   */\n  lastIndexOf(searchElement: E, fromIndex: number = this.length - 1): number {\n    if (this.length === 0) return -1;\n    if (fromIndex >= this.length) fromIndex = this.length - 1;\n    if (fromIndex < 0) fromIndex = this.length + fromIndex;\n\n    for (let i = fromIndex; i >= 0; i--) {\n      const element = this.at(i);\n      if (element === searchElement) return i;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Find the first index matching a predicate.\n   * @param predicate - `(element, index, self) => boolean`.\n   * @param thisArg - Optional `this` for callback.\n   * @returns Index or `-1`.\n   * @remarks Time O(n), Space O(1)\n   */\n  findIndex(predicate: ElementCallback<E, R, boolean>, thisArg?: any): number {\n    for (let i = 0; i < this.length; i++) {\n      const item = this.at(i);\n      if (item !== undefined && predicate.call(thisArg, item, i, this)) return i;\n    }\n    return -1;\n  }\n\n  /**\n   * Concatenate multiple containers of the same species.\n   * @param items - Other lists to append.\n   * @returns New container with combined elements (`this` type).\n   * @remarks Time O(sum(length)), Space O(sum(length))\n   */\n  concat(...items: this[]): this;\n\n  /**\n   * Concatenate elements and/or containers.\n   * @param items - Elements or other containers.\n   * @returns New container with combined elements (`this` type).\n   * @remarks Time O(sum(length)), Space O(sum(length))\n   */\n  concat(...items: (E | this)[]): this {\n    const newList = this.clone();\n\n    for (const item of items) {\n      if (item instanceof LinearBase) {\n        newList.pushMany(item);\n      } else {\n        newList.push(item);\n      }\n    }\n\n    return newList;\n  }\n\n  /**\n   * In-place stable order via array sort semantics.\n   * @param compareFn - Comparator `(a, b) => number`.\n   * @returns This container.\n   * @remarks Time O(n log n), Space O(n) (materializes to array temporarily)\n   */\n  sort(compareFn?: (a: E, b: E) => number): this {\n    const arr = this.toArray();\n    arr.sort(compareFn);\n    this.clear();\n    for (const item of arr) this.push(item);\n    return this;\n  }\n\n  /**\n   * Remove and/or insert elements at a position (array-compatible).\n   * @param start - Start index (supports negative index).\n   * @param deleteCount - How many to remove.\n   * @param items - Elements to insert.\n   * @returns Removed elements as a new list (`this` type).\n   * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n   */\n  splice(start: number, deleteCount: number = 0, ...items: E[]): this {\n    const removedList = this._createInstance();\n\n    start = start < 0 ? this.length + start : start;\n    start = Math.max(0, Math.min(start, this.length));\n    deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));\n\n    for (let i = 0; i < deleteCount; i++) {\n      const removed = this.deleteAt(start);\n      if (removed !== undefined) {\n        removedList.push(removed);\n      }\n    }\n\n    for (let i = 0; i < items.length; i++) {\n      this.addAt(start + i, items[i]);\n    }\n\n    return removedList;\n  }\n\n  /**\n   * Join all elements into a string.\n   * @param separator - Separator string.\n   * @returns Concatenated string.\n   * @remarks Time O(n), Space O(n)\n   */\n  join(separator: string = ','): string {\n    return this.toArray().join(separator);\n  }\n\n  /**\n   * Snapshot elements into a reversed array.\n   * @returns New reversed array.\n   * @remarks Time O(n), Space O(n)\n   */\n  toReversedArray(): E[] {\n    const array: E[] = [];\n    for (let i = this.length - 1; i >= 0; i--) {\n      array.push(this.at(i)!);\n    }\n    return array;\n  }\n\n  reduceRight(callbackfn: ReduceLinearCallback<E>): E;\n\n  reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;\n\n  /**\n   * Right-to-left reduction over elements.\n   * @param callbackfn - `(acc, element, index, self) => acc`.\n   * @param initialValue - Initial accumulator (optional generic overloads supported).\n   * @returns Final accumulator.\n   * @remarks Time O(n), Space O(1)\n   */\n  reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;\n\n  reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue?: U): U {\n    let accumulator = initialValue ?? (0 as U);\n    for (let i = this.length - 1; i >= 0; i--) {\n      accumulator = callbackfn(accumulator, this.at(i)!, i, this);\n    }\n    return accumulator;\n  }\n\n  /**\n   * Create a shallow copy of a subrange.\n   * @param start - Inclusive start (supports negative index).\n   * @param end - Exclusive end (supports negative index).\n   * @returns New list with the range (`this` type).\n   * @remarks Time O(n), Space O(n)\n   */\n  slice(start: number = 0, end: number = this.length): this {\n    start = start < 0 ? this.length + start : start;\n    end = end < 0 ? this.length + end : end;\n\n    const newList = this._createInstance();\n    for (let i = start; i < end; i++) {\n      newList.push(this.at(i)!);\n    }\n    return newList;\n  }\n\n  /**\n   * Fill a range with a value.\n   * @param value - Value to set.\n   * @param start - Inclusive start.\n   * @param end - Exclusive end.\n   * @returns This list.\n   * @remarks Time O(n), Space O(1)\n   */\n  fill(value: E, start = 0, end = this.length): this {\n    start = start < 0 ? this.length + start : start;\n    end = end < 0 ? this.length + end : end;\n\n    if (start < 0) start = 0;\n    if (end > this.length) end = this.length;\n    if (start >= end) return this;\n\n    for (let i = start; i < end; i++) {\n      this.setAt(i, value);\n    }\n\n    return this;\n  }\n\n  /**\n   * Set the value at an index.\n   * @param index - Position (0-based).\n   * @param value - New value.\n   * @returns `true` if updated.\n   * @remarks Time O(1) typical, Space O(1)\n   */\n  abstract setAt(index: number, value: E): boolean;\n\n  /**\n   * Deep clone while preserving concrete subtype.\n   * @returns New list of the same species (`this` type).\n   * @remarks Time O(n), Space O(n)\n   */\n  abstract override clone(): this;\n\n  /**\n   * Reverse the order of elements in-place (or equivalent).\n   * @returns This list.\n   * @remarks Time O(n), Space O(1)\n   */\n  abstract reverse(): this;\n\n  /**\n   * Append one element or node to the tail.\n   * @param elementOrNode - Element or node.\n   * @returns `true` if appended.\n   * @remarks Time O(1) amortized typical, Space O(1)\n   */\n  abstract push(elementOrNode: E | NODE): boolean;\n\n  /**\n   * Append many elements/nodes at once.\n   * @param elements - Iterable of elements or nodes.\n   * @returns Array of booleans indicating append success.\n   * @remarks Time O(n), Space O(1)\n   */\n  abstract pushMany(elements: Iterable<E> | Iterable<R> | Iterable<NODE>): boolean[];\n\n  /**\n   * Remove one element or node if present.\n   * @param elementOrNode - Element or node to delete.\n   * @returns `true` if removed.\n   * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n   */\n  abstract delete(elementOrNode: E | NODE | undefined): boolean;\n\n  /**\n   * Get element at an index.\n   * @param index - Position (0-based).\n   * @returns Element or `undefined`.\n   * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n   */\n  abstract at(index: number): E | undefined;\n\n  /**\n   * Remove element at a position.\n   * @param pos - Position (0-based).\n   * @returns Removed element or `undefined`.\n   * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n   */\n  abstract deleteAt(pos: number): E | undefined;\n\n  /**\n   * Insert an element/node at a position.\n   * @param index - Position (0-based).\n   * @param newElementOrNode - Element or node to insert.\n   * @returns `true` if inserted.\n   * @remarks Time O(1)~O(n) depending on implementation, Space O(1)\n   */\n  abstract addAt(index: number, newElementOrNode: E | NODE): boolean;\n\n  /**\n   * Create an empty list of the same species.\n   * @param options - Runtime options to carry.\n   * @returns Empty list (`this` type).\n   * @remarks Time O(1), Space O(1)\n   */\n  protected abstract _createInstance(options?: LinearBaseOptions<E, R>): this;\n\n  /**\n   * Reverse-direction iterator over elements.\n   * @returns Iterator of elements from tail to head.\n   * @remarks Time O(n), Space O(1)\n   */\n  protected abstract _getReverseIterator(...args: any[]): IterableIterator<E>;\n}\n\n/**\n * Linked-list specialized linear container.\n * @template E - Element type.\n * @template R - Return type for mapped/derived views.\n * @template NODE - Linked node type.\n * @remarks Time O(1), Space O(1)\n */\nexport abstract class LinearLinkedBase<\n  E,\n  R = any,\n  NODE extends LinkedListNode<E> = LinkedListNode<E>\n> extends LinearBase<E, R, NODE> {\n  protected constructor(options?: LinearBaseOptions<E, R>) {\n    super(options);\n    if (options) {\n      const { maxLen } = options;\n      if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;\n    }\n  }\n\n  /**\n   * Linked-list optimized `indexOf` (forwards scan).\n   * @param searchElement - Value to match.\n   * @param fromIndex - Start position.\n   * @returns Index or `-1`.\n   * @remarks Time O(n), Space O(1)\n   */\n  override indexOf(searchElement: E, fromIndex: number = 0): number {\n    const iterator = this._getIterator();\n    let current = iterator.next();\n\n    let index = 0;\n    while (index < fromIndex) {\n      current = iterator.next();\n      index++;\n    }\n\n    while (!current.done) {\n      if (current.value === searchElement) return index;\n      current = iterator.next();\n      index++;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Linked-list optimized `lastIndexOf` (reverse scan).\n   * @param searchElement - Value to match.\n   * @param fromIndex - Start position.\n   * @returns Index or `-1`.\n   * @remarks Time O(n), Space O(1)\n   */\n  override lastIndexOf(searchElement: E, fromIndex: number = this.length - 1): number {\n    const iterator = this._getReverseIterator();\n    let current = iterator.next();\n\n    let index = this.length - 1;\n    while (index > fromIndex) {\n      current = iterator.next();\n      index--;\n    }\n\n    while (!current.done) {\n      if (current.value === searchElement) return index;\n      current = iterator.next();\n      index--;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Concatenate lists/elements preserving order.\n   * @param items - Elements or `LinearBase` instances.\n   * @returns New list with combined elements (`this` type).\n   * @remarks Time O(sum(length)), Space O(sum(length))\n   */\n  override concat(...items: LinearBase<E, R>[]): this;\n\n  override concat(...items: (E | LinearBase<E, R>)[]): this {\n    const newList = this.clone();\n\n    for (const item of items) {\n      if (item instanceof LinearBase) {\n        newList.pushMany(item);\n      } else {\n        newList.push(item);\n      }\n    }\n\n    return newList;\n  }\n\n  /**\n   * Slice via forward iteration (no random access required).\n   * @param start - Inclusive start (supports negative index).\n   * @param end - Exclusive end (supports negative index).\n   * @returns New list (`this` type).\n   * @remarks Time O(n), Space O(n)\n   */\n  override slice(start: number = 0, end: number = this.length): this {\n    start = start < 0 ? this.length + start : start;\n    end = end < 0 ? this.length + end : end;\n\n    const newList = this._createInstance();\n    const iterator = this._getIterator();\n    let current = iterator.next();\n    let c = 0;\n    while (c < start) {\n      current = iterator.next();\n      c++;\n    }\n    for (let i = start; i < end; i++) {\n      newList.push(current.value);\n      current = iterator.next();\n    }\n\n    return newList;\n  }\n\n  /**\n   * Splice by walking node iterators from the start index.\n   * @param start - Start index.\n   * @param deleteCount - How many elements to remove.\n   * @param items - Elements to insert after the splice point.\n   * @returns Removed elements as a new list (`this` type).\n   * @remarks Time O(n + m), Space O(min(n, m)) where `m = items.length`\n   */\n  override splice(start: number, deleteCount: number = 0, ...items: E[]): this {\n    const removedList = this._createInstance();\n\n    start = start < 0 ? this.length + start : start;\n    start = Math.max(0, Math.min(start, this.length));\n    deleteCount = Math.max(0, deleteCount);\n\n    let currentIndex = 0;\n    let currentNode: NODE | undefined = undefined;\n    let previousNode: NODE | undefined = undefined;\n\n    const iterator = this._getNodeIterator();\n    for (const node of iterator) {\n      if (currentIndex === start) {\n        currentNode = node;\n        break;\n      }\n      previousNode = node;\n      currentIndex++;\n    }\n\n    for (let i = 0; i < deleteCount && currentNode; i++) {\n      removedList.push(currentNode.value);\n      const nextNode = currentNode.next;\n      this.delete(currentNode);\n      currentNode = nextNode as NODE;\n    }\n\n    for (let i = 0; i < items.length; i++) {\n      if (previousNode) {\n        this.addAfter(previousNode, items[i]);\n        previousNode = previousNode.next as NODE;\n      } else {\n        this.addAt(0, items[i]);\n        previousNode = this._getNodeIterator().next().value;\n      }\n    }\n\n    return removedList;\n  }\n\n  override reduceRight(callbackfn: ReduceLinearCallback<E>): E;\n\n  override reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;\n\n  /**\n   * Right-to-left reduction using reverse iterator.\n   * @param callbackfn - `(acc, element, index, self) => acc`.\n   * @param initialValue - Initial accumulator.\n   * @returns Final accumulator.\n   * @remarks Time O(n), Space O(1)\n   */\n  override reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;\n\n  override reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue?: U): U {\n    let accumulator = initialValue ?? (0 as U);\n    let index = this.length - 1;\n    for (const item of this._getReverseIterator()) {\n      accumulator = callbackfn(accumulator, item, index--, this);\n    }\n    return accumulator;\n  }\n\n  /**\n   * Delete by element or node in a linked list.\n   * @param elementOrNode - Element or node.\n   * @returns `true` if removed.\n   * @remarks Time O(1)~O(n) depending on availability of links, Space O(1)\n   */\n  abstract override delete(elementOrNode: E | NODE | undefined): boolean;\n\n  /**\n   * Insert new element/node before an existing node.\n   * @param existingElementOrNode - Reference element/node.\n   * @param newElementOrNode - Element/node to insert.\n   * @returns `true` if inserted.\n   * @remarks Time O(1)~O(n) depending on reference access, Space O(1)\n   */\n  abstract addBefore(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;\n\n  /**\n   * Insert new element/node after an existing node.\n   * @param existingElementOrNode - Reference element/node.\n   * @param newElementOrNode - Element/node to insert.\n   * @returns `true` if inserted.\n   * @remarks Time O(1)~O(n) depending on reference access, Space O(1)\n   */\n  abstract addAfter(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;\n\n  /**\n   * Node at index (for random-access emulation).\n   * @param index - Position (0-based).\n   * @returns Node or `undefined`.\n   * @remarks Time O(n), Space O(1)\n   */\n  abstract getNodeAt(index: number): NODE | undefined;\n\n  /**\n   * Iterate linked nodes from head to tail.\n   * @returns Iterator over nodes.\n   * @remarks Time O(n), Space O(1)\n   */\n  protected abstract _getNodeIterator(...args: any[]): IterableIterator<NODE>;\n\n  /**\n   * Get previous node of a given node.\n   * @param node - Current node.\n   * @returns Previous node or `undefined`.\n   * @remarks Time O(1)~O(n) depending on list variant (singly vs doubly), Space O(1)\n   */\n  protected abstract _getPrevNode(node: NODE): NODE | undefined;\n}\n","/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>\n * @license MIT License\n */\n\nimport type { ElementCallback, SinglyLinkedListOptions } from '../../types';\nimport { LinearLinkedBase, LinkedListNode } from '../base/linear-base';\n\n/**\n * Node of a singly linked list; stores value and the next link.\n * @remarks Time O(1), Space O(1)\n * @template E\n */\nexport class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {\n  /**\n   * Create a list node.\n   * @remarks Time O(1), Space O(1)\n   * @param value - Element value to store.\n   * @returns New node instance.\n   */\n\n  constructor(value: E) {\n    super(value);\n    this._value = value;\n    this._next = undefined;\n  }\n\n  protected override _next: SinglyLinkedListNode<E> | undefined;\n\n  /**\n   * Get the next node.\n   * @remarks Time O(1), Space O(1)\n   * @returns Next node or undefined.\n   */\n\n  override get next(): SinglyLinkedListNode<E> | undefined {\n    return this._next;\n  }\n\n  /**\n   * Set the next node.\n   * @remarks Time O(1), Space O(1)\n   * @param value - Next node or undefined.\n   * @returns void\n   */\n\n  override set next(value: SinglyLinkedListNode<E> | undefined) {\n    this._next = value;\n  }\n}\n\n/**\n * Singly linked list with O(1) push/pop-like ends operations and linear scans.\n * @remarks Time O(1), Space O(1)\n * @template E\n * @template R\n * 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.\n * 2. Bidirectional Traversal: Unlike doubly linked lists, singly linked lists can be easily traversed forwards but not backwards.\n * 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.\n * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.\n * Caution: Although our linked list classes provide methods such as at, setAt, addAt, and indexOf that are based on array indices, their time complexity, like that of the native Array.lastIndexOf, is 𝑂(𝑛). If you need to use these methods frequently, you might want to consider other data structures, such as Deque or Queue (designed for random access). Similarly, since the native Array.shift method has a time complexity of 𝑂(𝑛), using an array to simulate a queue can be inefficient. In such cases, you should use Queue or Deque, as these data structures leverage deferred array rearrangement, effectively reducing the average time complexity to 𝑂(1).\n * @example\n * // implementation of a basic text editor\n *     class TextEditor {\n *       private content: SinglyLinkedList<string>;\n *       private cursorIndex: number;\n *       private undoStack: Stack<{ operation: string; data?: any }>;\n *\n *       constructor() {\n *         this.content = new SinglyLinkedList<string>();\n *         this.cursorIndex = 0; // Cursor starts at the beginning\n *         this.undoStack = new Stack<{ operation: string; data?: any }>(); // Stack to keep track of operations for undo\n *       }\n *\n *       insert(char: string) {\n *         this.content.addAt(this.cursorIndex, char);\n *         this.cursorIndex++;\n *         this.undoStack.push({ operation: 'insert', data: { index: this.cursorIndex - 1 } });\n *       }\n *\n *       delete() {\n *         if (this.cursorIndex === 0) return; // Nothing to delete\n *         const deleted = this.content.deleteAt(this.cursorIndex - 1);\n *         this.cursorIndex--;\n *         this.undoStack.push({ operation: 'delete', data: { index: this.cursorIndex, char: deleted } });\n *       }\n *\n *       moveCursor(index: number) {\n *         this.cursorIndex = Math.max(0, Math.min(index, this.content.length));\n *       }\n *\n *       undo() {\n *         if (this.undoStack.size === 0) return; // No operations to undo\n *         const lastAction = this.undoStack.pop();\n *\n *         if (lastAction!.operation === 'insert') {\n *           this.content.deleteAt(lastAction!.data.index);\n *           this.cursorIndex = lastAction!.data.index;\n *         } else if (lastAction!.operation === 'delete') {\n *           this.content.addAt(lastAction!.data.index, lastAction!.data.char);\n *           this.cursorIndex = lastAction!.data.index + 1;\n *         }\n *       }\n *\n *       getText(): string {\n *         return [...this.content].join('');\n *       }\n *     }\n *\n *     // Example Usage\n *     const editor = new TextEditor();\n *     editor.insert('H');\n *     editor.insert('e');\n *     editor.insert('l');\n *     editor.insert('l');\n *     editor.insert('o');\n *     console.log(editor.getText()); // 'Hello' // Output: \"Hello\"\n *\n *     editor.delete();\n *     console.log(editor.getText()); // 'Hell' // Output: \"Hell\"\n *\n *     editor.undo();\n *     console.log(editor.getText()); // 'Hello' // Output: \"Hello\"\n *\n *     editor.moveCursor(1);\n *     editor.insert('a');\n *     console.log(editor.getText()); // 'Haello'\n */\nexport class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, SinglyLinkedListNode<E>> {\n  protected _equals: (a: E, b: E) => boolean = Object.is as unknown as (a: E, b: E) => boolean;\n\n  /**\n   * Create a SinglyLinkedList and optionally bulk-insert elements.\n   * @remarks Time O(N), Space O(N)\n   * @param [elements] - Iterable of elements or nodes (or raw records if toElementFn is provided).\n   * @param [options] - Options such as maxLen and toElementFn.\n   * @returns New SinglyLinkedList instance.\n   */\n\n  constructor(\n    elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>> = [],\n    options?: SinglyLinkedListOptions<E, R>\n  ) {\n    super(options);\n    this.pushMany(elements);\n  }\n\n  protected _head: SinglyLinkedListNode<E> | undefined;\n\n  /**\n   * Get the head node.\n   * @remarks Time O(1), Space O(1)\n   * @returns Head node or undefined.\n   */\n\n  get head(): SinglyLinkedListNode<E> | undefined {\n    return this._head;\n  }\n\n  protected _tail: SinglyLinkedListNode<E> | undefined;\n\n  /**\n   * Get the tail node.\n   * @remarks Time O(1), Space O(1)\n   * @returns Tail node or undefined.\n   */\n\n  get tail(): SinglyLinkedListNode<E> | undefined {\n    return this._tail;\n  }\n\n  protected _length = 0;\n\n  /**\n   * Get the number of elements.\n   * @remarks Time O(1), Space O(1)\n   * @returns Current length.\n   */\n\n  get length(): number {\n    return this._length;\n  }\n\n  /**\n   * Get the first element value.\n   * @remarks Time O(1), Space O(1)\n   * @returns First element or undefined.\n   */\n\n  get first(): E | undefined {\n    return this.head?.value;\n  }\n\n  /**\n   * Get the last element value.\n   * @remarks Time O(1), Space O(1)\n   * @returns Last element or undefined.\n   */\n\n  get last(): E | undefined {\n    return this.tail?.value;\n  }\n\n  /**\n   * Create a new list from an iterable of elements.\n   * @remarks Time O(N), Space O(N)\n   * @template E\n   * @template R\n   * @template S\n   * @param this - The constructor (subclass) to instantiate.\n   * @param data - Iterable of elements to insert.\n   * @param [options] - Options forwarded to the constructor.\n   * @returns A new list populated with the iterable's elements.\n   */\n\n  static from<E, R = any, S extends SinglyLinkedList<E, R> = SinglyLinkedList<E, R>>(\n    this: new (\n      elements?: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>,\n      options?: SinglyLinkedListOptions<E, R>\n    ) => S,\n    data: Iterable<E>,\n    options?: SinglyLinkedListOptions<E, R>\n  ): S {\n    const list = new this([], options);\n    for (const x of data) list.push(x);\n    return list;\n  }\n\n  /**\n   * Append an element/node to the tail.\n   * @remarks Time O(1), Space O(1)\n   * @param elementOrNode - Element or node to append.\n   * @returns True when appended.\n   */\n\n  push(elementOrNode: E | SinglyLinkedListNode<E>): boolean {\n    const newNode = this._ensureNode(elementOrNode);\n    if (!this.head) {\n      this._head = this._tail = newNode;\n    } else {\n      this.tail!.next = newNode;\n      this._tail = newNode;\n    }\n    this._length++;\n    if (this._maxLen > 0 && this.length > this._maxLen) this.shift();\n    return true;\n  }\n\n  /**\n   * Remove and return the tail element.\n   * @remarks Time O(N), Space O(1)\n   * @returns Removed element or undefined.\n   */\n\n  pop(): E | undefined {\n    if (!this.head) return undefined;\n    if (this.head === this.tail) {\n      const value = this.head.value;\n      this._head = undefined;\n      this._tail = undefined;\n      this._length--;\n      return value;\n    }\n    let current = this.head;\n    while (current.next !== this.tail) current = current.next!;\n    const value = this.tail!.value;\n    current.next = undefined;\n    this._tail = current;\n    this._length--;\n    return value;\n  }\n\n  /**\n   * Remove and return the head element.\n   * @remarks Time O(1), Space O(1)\n   * @returns Removed element or undefined.\n   */\n\n  shift(): E | undefined {\n    if (!this.head) return undefined;\n    const removed = this.head;\n    this._head = this.head.next;\n    if (!this._head) this._tail = undefined;\n    this._length--;\n    return removed.value;\n  }\n\n  /**\n   * Prepend an element/node to the head.\n   * @remarks Time O(1), Space O(1)\n   * @param elementOrNode - Element or node to prepend.\n   * @returns True when prepended.\n   */\n\n  unshift(elementOrNode: E | SinglyLinkedListNode<E>): boolean {\n    const newNode = this._ensureNode(elementOrNode);\n    if (!this.head) {\n      this._head = this._tail = newNode;\n    } else {\n      newNode.next = this.head;\n      this._head = newNode;\n    }\n    this._length++;\n    return true;\n  }\n\n  /**\n   * Append a sequence of elements/nodes.\n   * @remarks Time O(N), Space O(1)\n   * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n   * @returns Array of per-element success flags.\n   */\n\n  pushMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[] {\n    const ans: boolean[] = [];\n    for (const el of elements) {\n      if (this.toElementFn) ans.push(this.push(this.toElementFn(el as R)));\n      else ans.push(this.push(el as E | SinglyLinkedListNode<E>));\n    }\n    return ans;\n  }\n\n  /**\n   * Prepend a sequence of elements/nodes.\n   * @remarks Time O(N), Space O(1)\n   * @param elements - Iterable of elements or nodes (or raw records if toElementFn is provided).\n   * @returns Array of per-element success flags.\n   */\n\n  unshiftMany(elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>>): boolean[] {\n    const ans: boolean[] = [];\n    for (const el of elements) {\n      if (this.toElementFn) ans.push(this.unshift(this.toElementFn(el as R)));\n      else ans.push(this.unshift(el as E | SinglyLinkedListNode<E>));\n    }\n    return ans;\n  }\n\n  /**\n   * Find the first value matching a predicate (by node).\n   * @remarks Time O(N), Space O(1)\n   * @param elementNodeOrPredicate - Element, node, or node predicate to match.\n   * @returns Matched value or undefined.\n   */\n\n  search(\n    elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)\n  ): E | undefined {\n    const predicate = this._ensurePredicate(elementNodeOrPredicate);\n    let current = this.head;\n    while (current) {\n      if (predicate(current)) return current.value;\n      current = current.next;\n    }\n    return undefined;\n  }\n\n  /**\n   * Get the element at a given index.\n   * @remarks Time O(N), Space O(1)\n   * @param index - Zero-based index.\n   * @returns Element or undefined.\n   */\n\n  at(index: number): E | undefined {\n    if (index < 0 || index >= this._length) return undefined;\n    let current = this.head;\n    for (let i = 0; i < index; i++) current = current!.next;\n    return current!.value;\n  }\n\n  /**\n   * Type guard: check whether the input is a SinglyLinkedListNode.\n   * @remarks Time O(1), Space O(1)\n   * @param elementNodeOrPredicate - Element, node, or predicate.\n   * @returns True if the value is a SinglyLinkedListNode.\n   */\n\n  isNode(\n    elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)\n  ): elementNodeOrPredicate is SinglyLinkedListNode<E> {\n    return elementNodeOrPredicate instanceof SinglyLinkedListNode;\n  }\n\n  /**\n   * Get the node reference at a given index.\n   * @remarks Time O(N), Space O(1)\n   * @param index - Zero-based index.\n   * @returns Node or undefined.\n   */\n\n  getNodeAt(index: number): SinglyLinkedListNode<E> | undefined {\n    if (index < 0 || index >= this._length) return undefined;\n    let current = this.head;\n    for (let i = 0; i < index; i++) current = current!.next;\n    return current;\n  }\n\n  /**\n   * Delete the element at an index.\n   * @remarks Time O(N), Space O(1)\n   * @param index - Zero-based index.\n   * @returns Removed element or undefined.\n   */\n\n  deleteAt(index: number): E | undefined {\n    if (index < 0 || index >= this._length) return undefined;\n    if (index === 0) return this.shift();\n    const targetNode = this.getNodeAt(index)!;\n    const prevNode = this._getPrevNode(targetNode)!;\n    const value = targetNode.value;\n    prevNode.next = targetNode.next;\n    if (targetNode === this.tail) this._tail = prevNode;\n    this._length--;\n    return value;\n  }\n\n  /**\n   * Delete the first match by value/node.\n   * @remarks Time O(N), Space O(1)\n   * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.\n   * @returns True if removed.\n   */\n\n  delete(elementOrNode: E | SinglyLinkedListNode<E> | undefined): boolean {\n    if (elementOrNode === undefined || !this.head) return false;\n    const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);\n    if (!node) return false;\n    const prevNode = this._getPrevNode(node);\n\n    if (!prevNode) {\n      this._head = node.next;\n      if (node === this.tail) this._tail = undefined;\n    } else {\n      prevNode.next = node.next;\n      if (node === this.tail) this._tail = prevNode;\n    }\n    this._length--;\n    return true;\n  }\n\n  /**\n   * Insert a new element/node at an index, shifting following nodes.\n   * @remarks Time O(N), Space O(1)\n   * @param index - Zero-based index.\n   * @param newElementOrNode - Element or node to insert.\n   * @returns True if inserted.\n   */\n\n  addAt(index: number, newElementOrNode: E | SinglyLinkedListNode<E>): boolean {\n    if (index < 0 || index > this._length) return false;\n    if (index === 0) return this.unshift(newElementOrNode);\n    if (index === this._length) return this.push(newElementOrNode);\n    const newNode = this._ensureNode(newElementOrNode);\n    const prevNode = this.getNodeAt(index - 1)!;\n    newNode.next = prevNode.next;\n    prevNode.next = newNode;\n    this._length++;\n    return true;\n  }\n\n  /**\n   * Set the element value at an index.\n   * @remarks Time O(N), Space O(1)\n   * @param index - Zero-based index.\n   * @param value - New value.\n   * @returns True if updated.\n   */\n\n  setAt(index: number, value: E): boolean {\n    const node = this.getNodeAt(index);\n    if (!node) return false;\n    node.value = value;\n    return true;\n  }\n\n  /**\n   * Check whether the list is empty.\n   * @remarks Time O(1), Space O(1)\n   * @returns True if length is 0.\n   */\n\n  isEmpty(): boolean {\n    return this._length === 0;\n  }\n\n  /**\n   * Remove all nodes and reset length.\n   * @remarks Time O(N), Space O(1)\n   * @returns void\n   */\n\n  clear(): void {\n    this._head = undefined;\n    this._tail = undefined;\n    this._length = 0;\n  }\n\n  /**\n   * Reverse the list in place.\n   * @remarks Time O(N), Space O(1)\n   * @returns This list.\n   */\n\n  reverse(): this {\n    if (!this.head || this.head === this.tail) return this;\n    let prev: SinglyLinkedListNode<E> | undefined;\n    let current: SinglyLinkedListNode<E> | undefined = this.head;\n    let next: SinglyLinkedListNode<E> | undefined;\n    while (current) {\n      next = current.next;\n      current.next = prev;\n      prev = current;\n      current = next;\n    }\n    [this._head, this._tail] = [this.tail!, this.head!];\n    return this;\n  }\n\n  /**\n   * Find a node by value, reference, or predicate.\n   * @remarks Time O(N), Space O(1)\n   * @param [elementNodeOrPredicate] - Element, node, or node predicate to match.\n   * @returns Matching node or undefined.\n   */\n\n  getNode(\n    elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean) | undefined\n  ): SinglyLinkedListNode<E> | undefined {\n    if (elementNodeOrPredicate === undefined) return;\n    if (this.isNode(elementNodeOrPredicate)) return elementNodeOrPredicate;\n    const predicate = this._ensurePredicate(elementNodeOrPredicate);\n    let current = this.head;\n    while (current) {\n      if (predicate(current)) return current;\n      current = current.next;\n    }\n    return undefined;\n  }\n\n  /**\n   * Insert a new element/node before an existing one.\n   * @remarks Time O(N), Space O(1)\n   * @param existingElementOrNode - Existing element or node.\n   * @param newElementOrNode - Element or node to insert.\n   * @returns True if inserted.\n   */\n\n  addBefore(\n    existingElementOrNode: E | SinglyLinkedListNode<E>,\n    newElementOrNode: E | SinglyLinkedListNode<E>\n  ): boolean {\n    const existingNode = this.getNode(existingElementOrNode);\n    if (!existingNode) return false;\n    const prevNode = this._getPrevNode(existingNode);\n    const newNode = this._ensureNode(newElementOrNode);\n\n    if (!prevNode) {\n      newNode.next = this._head;\n      this._head = newNode;\n      if (!this._tail) this._tail = newNode;\n      this._length++;\n    } else {\n      prevNode.next = newNode;\n      newNode.next = existingNode;\n      this._length++;\n    }\n    return true;\n  }\n\n  /**\n   * Insert a new element/node after an existing one.\n   * @remarks Time O(N), Space O(1)\n   * @param existingElementOrNode - Existing element or node.\n   * @param newElementOrNode - Element or node to insert.\n   * @returns True if inserted.\n   */\n\n  addAfter(existingElementOrNode: E | SinglyLinkedListNode<E>, newElementOrNode: E | SinglyLinkedListNode<E>): boolean {\n    const existingNode = this.getNode(existingElementOrNode);\n    if (!existingNode) return false;\n    const newNode = this._ensureNode(newElementOrNode);\n    newNode.next = existingNode.next;\n    existingNode.next = newNode;\n    if (existingNode === this.tail) this._tail = newNode;\n    this._length++;\n    return true;\n  }\n\n  /**\n   * Remove and/or insert elements at a position (array-like behavior).\n   * @remarks Time O(N + M), Space O(M)\n   * @param start - Start index (clamped to [0, length]).\n   * @param [deleteCount] - Number of elements to remove (default 0).\n   * @param [items] - Elements to insert after `start`.\n   * @returns A new list containing the removed elements (typed as `this`).\n   */\n\n  override splice(start: number, deleteCount = 0, ...items: E[]): this {\n    start = Math.max(0, Math.min(start, this.length));\n    deleteCount = Math.max(0, deleteCount);\n\n    const removedList = this._createInstance();\n\n    const prevNode = start === 0 ? undefined : this.getNodeAt(start - 1);\n    let cur = prevNode ? prevNode.next : this.head;\n\n    let removedCount = 0;\n    while (removedCount < deleteCount && cur) {\n      removedList.push(cur.value);\n      cur = cur.next;\n      removedCount++;\n    }\n    const afterNode = cur;\n\n    if (prevNode) {\n      prevNode.next = afterNode;\n    } else {\n      this._head = afterNode;\n    }\n    if (!afterNode) this._tail = prevNode;\n\n    if (items.length > 0) {\n      let firstInserted: SinglyLinkedListNode<E> | undefined;\n      let lastInserted: SinglyLinkedListNode<E> | undefined;\n      for (const it of items) {\n        const node = this._ensureNode(it);\n        if (!firstInserted) firstInserted = node;\n        if (lastInserted) lastInserted.next = node;\n        lastInserted = node;\n      }\n      if (prevNode) prevNode.next = firstInserted!;\n      else this._head = firstInserted!;\n\n      lastInserted!.next = afterNode;\n      if (!afterNode) this._tail = lastInserted!;\n    }\n\n    this._length += items.length - removedCount;\n    if (this._length === 0) {\n      this._head = undefined;\n      this._tail = undefined;\n    }\n\n    return removedList as unknown as this;\n  }\n\n  /**\n   * Count how many nodes match a value/node/predicate.\n   * @remarks Time O(N), Space O(1)\n   * @param elementOrNode - Element, node, or node predicate to match.\n   * @returns Number of matches in the list.\n   */\n\n  countOccurrences(elementOrNode: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)): number {\n    const predicate = elementOrPredicate(elementOrNode, this._equals);\n    let count = 0;\n    let current = this.head;\n    while (current) {\n      if (predicate(current)) count++;\n      current = current.next;\n    }\n    return count;\n  }\n\n  /**\n   * Set the equality comparator used to compare values.\n   * @remarks Time O(1), Space O(1)\n   * @param equals - Equality predicate (a, b) → boolean.\n   * @returns This list.\n   */\n\n  setEquality(equals: (a: E, b: E) => boolean): this {\n    this._equals = equals;\n    return this;\n  }\n\n  /**\n   * Delete the first node whose value matches a predicate.\n   * @remarks Time O(N), Space O(1)\n   * @param predicate - Predicate (value, index, list) → boolean to decide deletion.\n   * @returns True if a node was removed.\n   */\n\n  deleteWhere(predicate: (value: E, index: number, list: this) => boolean): boolean {\n    let prev: SinglyLinkedListNode<E> | undefined;\n    let current = this.head;\n    let i = 0;\n    while (current) {\n      if (predicate(current.value, i++, this)) {\n        if (!prev) {\n          this._head = current.next;\n          if (current === this._tail) this._tail = undefined;\n        } else {\n          prev.next = current.next;\n          if (current === this._tail) this._tail = prev;\n        }\n        this._length--;\n        return true;\n      }\n      prev = current;\n      current = current.next;\n    }\n    return false;\n  }\n\n  /**\n   * Deep clone this list (values are copied by reference).\n   * @remarks Time O(N), Space O(N)\n   * @returns A new list with the same element sequence.\n   */\n\n  clone(): this {\n    const out = this._createInstance();\n    for (const v of this) out.push(v);\n    return out;\n  }\n\n  /**\n   * Filter values into a new list of the same class.\n   * @remarks Time O(N), Space O(N)\n   * @param callback - Predicate (value, index, list) → boolean to keep value.\n   * @param [thisArg] - Value for `this` inside the callback.\n   * @returns A new list with kept values.\n   */\n\n  filter(callback: ElementCallback<E, R, boolean>, thisArg?: any): this {\n    const out = this._createInstance();\n    let index = 0;\n    for (const value of this) if (callback.call(thisArg, value, index++, this)) out.push(value);\n    return out;\n  }\n\n  /**\n   * Map values into a new list of the same class.\n   * @remarks Time O(N), Space O(N)\n   * @param callback - Mapping function (value, index, list) → newValue.\n   * @param [thisArg] - Value for `this` inside the callback.\n   * @returns A new list with mapped values.\n   */\n\n  mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this {\n    const out = this._createInstance();\n    let index = 0;\n    for (const value of this) {\n      const mv = thisArg === undefined ? callback(value, index++, this) : callback.call(thisArg, value, index++, this);\n      out.push(mv);\n    }\n    return out;\n  }\n\n  /**\n   * Map values into a new list (possibly different element type).\n   * @remarks Time O(N), Space O(N)\n   * @template EM\n   * @template RM\n   * @param callback - Mapping function (value, index, list) → newElement.\n   * @param [options] - Options for the output list (e.g., maxLen, toElementFn).\n   * @param [thisArg] - Value for `this` inside the callback.\n   * @returns A new SinglyLinkedList with mapped values.\n   */\n\n  map<EM, RM = any>(\n    callback: ElementCallback<E, R, EM>,\n    options?: SinglyLinkedListOptions<EM, RM>,\n    thisArg?: any\n  ): SinglyLinkedList<EM, RM> {\n    const out = this._createLike<EM, RM>([], { ...(options ?? {}), maxLen: this._maxLen as number });\n    let index = 0;\n    for (const value of this) out.push(callback.call(thisArg, value, index++, this));\n    return out;\n  }\n\n  /**\n   * (Protected) Create a node from a value.\n   * @remarks Time O(1), Space O(1)\n   * @param value - Value to wrap in a node.\n   * @returns A new SinglyLinkedListNode instance.\n   */\n\n  protected createNode(value: E): SinglyLinkedListNode<E> {\n    return new SinglyLinkedListNode<E>(value);\n  }\n\n  /**\n   * (Protected) Check if input is a node predicate function.\n   * @remarks Time O(1), Space O(1)\n   * @param elementNodeOrPredicate - Element, node, or node predicate.\n   * @returns True if input is a predicate function.\n   */\n\n  protected _isPredicate(\n    elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)\n  ): elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean {\n    return typeof elementNodeOrPredicate === 'function';\n  }\n\n  /**\n   * (Protected) Normalize input into a node instance.\n   * @remarks Time O(1), Space O(1)\n   * @param elementOrNode - Element or node.\n   * @returns A SinglyLinkedListNode for the provided input.\n   */\n\n  protected _ensureNode(elementOrNode: E | SinglyLinkedListNode<E>) {\n    if (this.isNode(elementOrNode)) return elementOrNode;\n    return this.createNode(elementOrNode);\n  }\n\n  /**\n   * (Protected) Normalize input into a node predicate.\n   * @remarks Time O(1), Space O(1)\n   * @param elementNodeOrPredicate - Element, node, or predicate.\n   * @returns A predicate taking a node and returning true/false.\n   */\n\n  protected _ensurePredicate(\n    elementNodeOrPredicate: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean)\n  ) {\n    if (this.isNode(elementNodeOrPredicate)) return (node: SinglyLinkedListNode<E>) => node === elementNodeOrPredicate;\n    if (this._isPredicate(elementNodeOrPredicate)) return elementNodeOrPredicate;\n    const value = elementNodeOrPredicate as E;\n    return (node: SinglyLinkedListNode<E>) => this._equals(node.value, value);\n  }\n\n  /**\n   * (Protected) Get the previous node of a given node.\n   * @remarks Time O(N), Space O(1)\n   * @param node - A node in the list.\n   * @returns Previous node or undefined.\n   */\n\n  protected _getPrevNode(node: SinglyLinkedListNode<E>): SinglyLinkedListNode<E> | undefined {\n    if (!this.head || this.head === node) return undefined;\n    let current = this.head;\n    while (current.next && current.next !== node) current = current.next;\n    return current.next === node ? current : undefined;\n  }\n\n  /**\n   * (Protected) Iterate values from head to tail.\n   * @remarks Time O(N), Space O(1)\n   * @returns Iterator of values (E).\n   */\n\n  protected *_getIterator(): IterableIterator<E> {\n    let current = this.head;\n    while (current) {\n      yield current.value;\n      current = current.next;\n    }\n  }\n\n  /**\n   * (Protected) Iterate values from tail to head.\n   * @remarks Time O(N), Space O(N)\n   * @returns Iterator of values (E).\n   */\n\n  protected *_getReverseIterator(): IterableIterator<E> {\n    const reversedArr = [...this].reverse();\n    for (const item of reversedArr) yield item;\n  }\n\n  /**\n   * (Protected) Iterate nodes from head to tail.\n   * @remarks Time O(N), Space O(1)\n   * @returns Iterator of nodes.\n   */\n\n  protected *_getNodeIterator(): IterableIterator<SinglyLinkedListNode<E>> {\n    let current = this.head;\n    while (current) {\n      yield current;\n      current = current.next;\n    }\n  }\n\n  /**\n   * (Protected) Create an empty instance of the same concrete class.\n   * @remarks Time O(1), Space O(1)\n   * @param [options] - Options forwarded to the constructor.\n   * @returns An empty like-kind list instance.\n   */\n\n  protected _createInstance(options?: SinglyLinkedListOptions<E, R>): this {\n    const Ctor: any = this.constructor;\n    return new Ctor([], options);\n  }\n\n  /**\n   * (Protected) Create a like-kind instance and seed it from an iterable.\n   * @remarks Time O(N), Space O(N)\n   * @template EM\n   * @template RM\n   * @param [elements] - Iterable used to seed the new list.\n   * @param [options] - Options forwarded to the constructor.\n   * @returns A like-kind SinglyLinkedList instance.\n   */\n\n  protected _createLike<EM, RM>(\n    elements: Iterable<EM> | Iterable<RM> | Iterable<SinglyLinkedListNode<EM>> = [],\n    options?: SinglyLinkedListOptions<EM, RM>\n  ): SinglyLinkedList<EM, RM> {\n    const Ctor: any = this.constructor;\n    return new Ctor(elements, options) as SinglyLinkedList<EM, RM>;\n  }\n\n  /**\n   * (Protected) Spawn an empty like-kind list instance.\n   * @remarks Time O(1), Space O(1)\n   * @template EM\n   * @template RM\n   * @param [options] - Options forwarded to the constructor.\n   * @returns An empty like-kind SinglyLinkedList instance.\n   */\n\n  protected _spawnLike<EM, RM>(options?: SinglyLinkedListOptions<EM, RM>): SinglyLinkedList<EM, RM> {\n    return this._createLike<EM, RM>([], options);\n  }\n}\n\nfunction elementOrPredicate<E>(\n  input: E | SinglyLinkedListNode<E> | ((node: SinglyLinkedListNode<E>) => boolean),\n  equals: (a: E, b: E) => boolean\n) {\n  if (input instanceof SinglyLinkedListNode) return (node: SinglyLinkedListNode<E>) => node === input;\n  if (typeof input === 'function') return input as (node: SinglyLinkedListNode<E>) => boolean;\n  const value = input as E;\n  return (node: SinglyLinkedListNode<E>) => equals(node.value, value);\n}\n","/**\n * data-structure-typed\n *\n * @author Pablo Zeng\n * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>\n * @license MIT License\n */\nimport type { Comparable, ComparablePrimitive, Trampoline, TrampolineThunk } from '../types';\n\n/**\n * The function generates a random UUID (Universally Unique Identifier) in TypeScript.\n * @returns A randomly generated UUID (Universally Unique Identifier) in the format\n * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal\n * character.\n */\nexport const uuidV4 = function () {\n  return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {\n    const r = (Math.random() * 16) | 0,\n      v = c == 'x' ? r : (r & 0x3) | 0x8;\n    return v.toString(16);\n  });\n};\n\n/**\n * The `arrayRemove` function removes elements from an array based on a specified predicate function\n * and returns the removed elements.\n * @param {T[]} array - An array of elements that you want to filter based on the provided predicate\n * function.\n * @param predicate - The `predicate` parameter is a function that takes three arguments:\n * @returns The `arrayRemove` function returns an array containing the elements that satisfy the given\n * `predicate` function.\n */\nexport const arrayRemove = function <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean): T[] {\n  let i = -1,\n    len = array ? array.length : 0;\n  const result = [];\n\n  while (++i < len) {\n    const value = array[i];\n    if (predicate(value, i, array)) {\n      result.push(value);\n      Array.prototype.splice.call(array, i--, 1);\n      len--;\n    }\n  }\n\n  return result;\n};\n\n/**\n * The function `getMSB` returns the most significant bit of a given number.\n * @param {number} value - The `value` parameter is a number for which we want to find the position of\n * the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the\n * position of the MSB in its binary representation.\n * @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the\n * input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the\n * MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.\n */\nexport const getMSB = (value: number): number => {\n  if (value <= 0) {\n    return 0;\n  }\n  return 1 << (31 - Math.clz32(value));\n};\n\n/**\n * The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range\n * and throws a `RangeError` with a custom message if it is out of bounds.\n * @param {number} index - The `index` parameter represents the value that you want to check if it\n * falls within a specified range.\n * @param {number} min - The `min` parameter represents the minimum value that the `index` should be\n * compared against in the `rangeCheck` function.\n * @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value\n * that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a\n * `RangeError` will be thrown.\n * @param [message=Index out of bounds.] - The `message` parameter is a string that represents the\n * error message to be thrown if the index is out of bounds. By default, if no message is provided when\n * calling the `rangeCheck` function, the message \"Index out of bounds.\" will be used.\n */\nexport const rangeCheck = (index: number, min: number, max: number, message = 'Index out of bounds.'): void => {\n  if (index < min || index > max) throw new RangeError(message);\n};\n\n/**\n * The function `throwRangeError` throws a RangeError with a custom message if called.\n * @param [message=The value is off-limits.] - The `message` parameter is a string that represents the\n * error message to be displayed when a `RangeError` is thrown. If no message is provided, the default\n * message is 'The value is off-limits.'.\n */\nexport const throwRangeError = (message = 'The value is off-limits.'): void => {\n  throw new RangeError(message);\n};\n\n/**\n * The function `isWeakKey` checks if the input is an object or a function in TypeScript.\n * @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,\n * which means it can be any type. The function checks if the `input` is an object (excluding `null`)\n * or a function, and returns a boolean indicating whether the `input` is a weak\n * @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object\n * or a function.\n */\nexport const isWeakKey = (input: unknown): input is object => {\n  const inputType = typeof input;\n  return (inputType === 'object' && input !== null) || inputType === 'function';\n};\n\n/**\n * The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a\n * given total quantity based on a specified unit size.\n * @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items\n * that need to be processed or handled.\n * @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It\n * is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to\n * accommodate a total quantity of items.\n */\nexport const calcMinUnitsRequired = (totalQuantity: number, unitSize: number) =>\n  Math.floor((totalQuantity + unitSize - 1) / unitSize);\n\n/**\n * The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.\n * @param {number} num - The `num` parameter is a number that you want to round to a certain number of\n * decimal places.\n * @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number\n * of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.\n * @returns The function `roundFixed` returns a number that is rounded to the specified number of\n * decimal places (default is 10 decimal places).\n */\nexport const roundFixed = (num: number, digit: number = 10) => {\n  const multiplier = Math.pow(10, digit);\n  return Math.round(num * multiplier) / multiplier;\n};\n\n/**\n * The function `isPrimitiveComparable` checks if a value is a primitive type that can be compared.\n * @param {unknown} value - The `value` parameter in the `isPrimitiveComparable` function is of type\n * `unknown`, which means it can be any type. The function checks if the `value` is a primitive type\n * that can be compared, such as number, bigint, string, or boolean.\n * @returns The function `isPrimitiveComparable` returns a boolean value indicating whether the input\n * `value` is a primitive value that can be compared using standard comparison operators (<, >, <=,\n * >=).\n */\nfunction isPrimitiveComparable(value: unknown): value is ComparablePrimitive {\n  const valueType = typeof value;\n  if (valueType === 'number') return true;\n  // if (valueType === 'number') return !Number.isNaN(value);\n  return valueType === 'bigint' || valueType === 'string' || valueType === 'boolean';\n}\n\n/**\n * The function `tryObjectToPrimitive` attempts to convert an object to a comparable primitive value by\n * first checking the `valueOf` method and then the `toString` method.\n * @param {object} obj - The `obj` parameter in the `tryObjectToPrimitive` function is an object that\n * you want to convert to a primitive value. The function attempts to convert the object to a primitive\n * value by first checking if the object has a `valueOf` method. If the `valueOf` method exists, it\n * @returns The function `tryObjectToPrimitive` returns a value of type `ComparablePrimitive` if a\n * primitive comparable value is found within the object, or a string value if the object has a custom\n * `toString` method that does not return `'[object Object]'`. If neither condition is met, the\n * function returns `null`.\n */\nfunction tryObjectToPrimitive(obj: object): ComparablePrimitive | null {\n  if (typeof obj.valueOf === 'function') {\n    const valueOfResult = obj.valueOf();\n    if (valueOfResult !== obj) {\n      if (isPrimitiveComparable(valueOfResult)) return valueOfResult;\n      if (typeof valueOfResult === 'object' && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);\n    }\n  }\n  if (typeof obj.toString === 'function') {\n    const stringResult = obj.toString();\n    if (stringResult !== '[object Object]') return stringResult;\n  }\n  return null;\n}\n\n/**\n * The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values\n * and objects with optional force comparison.\n * @param {unknown} value - The `value` parameter in the `isComparable` function represents the value\n * that you want to check if it is comparable. It can be of any type (`unknown`), and the function will\n * determine if it is comparable based on certain conditions.\n * @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the\n * `isComparable` function is a boolean flag that determines whether to treat non-primitive values as\n * comparable objects. When set to `true`, it forces the function to consider non-primitive values as\n * comparable objects, regardless of their type.\n * @returns The function `isComparable` returns a boolean value indicating whether the `value` is\n * considered comparable or not.\n */\nexport function isComparable(value: unknown, isForceObjectComparable = false): value is Comparable {\n  if (value === null || value === undefined) return false;\n  if (isPrimitiveComparable(value)) return true;\n\n  if (typeof value !== 'object') return false;\n  if (value instanceof Date) return true;\n  // if (value instanceof Date) return !Number.isNaN(value.getTime());\n  if (isForceObjectComparable) return true;\n  const comparableValue = tryObjectToPrimitive(value);\n  if (comparableValue === null || comparableValue === undefined) return false;\n  return isPrimitiveComparable(comparableValue);\n}\n\n/**\n * Creates a trampoline thunk object.\n *\n * A \"thunk\" is a deferred computation — instead of performing a recursive call immediately,\n * it wraps the next step of the computation in a function. This allows recursive processes\n * to be executed iteratively, preventing stack overflows.\n *\n * @template T - The type of the final computation result.\n * @param computation - A function that, when executed, returns the next trampoline step.\n * @returns A TrampolineThunk object containing the deferred computation.\n */\nexport const makeTrampolineThunk = <T>(computation: () => Trampoline<T>): TrampolineThunk<T> => ({\n  isThunk: true, // Marker indicating this is a thunk\n  fn: computation // The deferred computation function\n});\n\n/**\n * Type guard to check whether a given value is a TrampolineThunk.\n *\n * This function is used to distinguish between a final computation result (value)\n * and a deferred computation (thunk).\n *\n * @template T - The type of the value being checked.\n * @param value - The value to test.\n * @returns True if the value is a valid TrampolineThunk, false otherwise.\n */\nexport const isTrampolineThunk = <T>(value: Trampoline<T>): value is TrampolineThunk<T> =>\n  typeof value === 'object' && // Must be an object\n  value !== null && // Must not be null\n  'isThunk' in value && // Must have the 'isThunk' property\n  value.isThunk; // The flag must be true\n\n/**\n * Executes a trampoline computation until a final (non-thunk) result is obtained.\n *\n * The trampoline function repeatedly invokes the deferred computations (thunks)\n * in an iterative loop. This avoids deep recursive calls and prevents stack overflow,\n * which is particularly useful for implementing recursion in a stack-safe manner.\n *\n * @template T - The type of the final result.\n * @param initial - The initial Trampoline value or thunk to start execution from.\n * @returns The final result of the computation (a non-thunk value).\n */\nexport function trampoline<T>(initial: Trampoline<T>): T {\n  let current = initial; // Start with the initial trampoline value\n  while (isTrampolineThunk(current)) {\n    // Keep unwrapping while we have thunks\n    current = current.fn(); // Execute the deferred function to get the next step\n  }\n  return current; // Once no thunks remain, return the final result\n}\n\n/**\n * Wraps a recursive function inside a trampoline executor.\n *\n * This function transforms a potentially recursive function (that returns a Trampoline<Result>)\n * into a *stack-safe* function that executes iteratively using the `trampoline` runner.\n *\n * In other words, it allows you to write functions that look recursive,\n * but actually run in constant stack space.\n *\n * @template Args - The tuple type representing the argument list of the original function.\n * @template Result - The final return type after all trampoline steps are resolved.\n *\n * @param fn - A function that performs a single step of computation\n *             and returns a Trampoline (either a final value or a deferred thunk).\n *\n * @returns A new function with the same arguments, but which automatically\n *          runs the trampoline process and returns the *final result* instead\n *          of a Trampoline.\n *\n * @example\n * // Example: Computing factorial in a stack-safe way\n * const factorial = makeTrampoline(function fact(n: number, acc: number = 1): Trampoline<number> {\n *   return n === 0\n *     ? acc\n *     : makeTrampolineThunk(() => fact(n - 1, acc * n));\n * });\n *\n * console.log(factorial(100000)); // Works without stack overflow\n */\nexport function makeTrampoline<Args extends any[], Result>(\n  fn: (...args: Args) => Trampoline<Result> // A function that returns a trampoline step\n): (...args: Args) => Result {\n  // Return a wrapped function that automatically runs the trampoline execution loop\n  return (...args: Args) => trampoline(fn(...args));\n}\n\n/**\n * Executes an asynchronous trampoline computation until a final (non-thunk) result is obtained.\n *\n * This function repeatedly invokes asynchronous deferred computations (thunks)\n * in an iterative loop. Each thunk may return either a Trampoline<T> or a Promise<Trampoline<T>>.\n *\n * It ensures that asynchronous recursive functions can run without growing the call stack,\n * making it suitable for stack-safe async recursion.\n *\n * @template T - The type of the final result.\n * @param initial - The initial Trampoline or Promise of Trampoline to start execution from.\n * @returns A Promise that resolves to the final result (a non-thunk value).\n */\nexport async function asyncTrampoline<T>(initial: Trampoline<T> | Promise<Trampoline<T>>): Promise<T> {\n  let current = await initial; // Wait for the initial step to resolve if it's a Promise\n\n  // Keep executing thunks until we reach a non-thunk (final) value\n  while (isTrampolineThunk(current)) {\n    current = await current.fn(); // Execute the thunk function (may be async)\n  }\n\n  // Once the final value is reached, return it\n  return current;\n}\n\n/**\n * Wraps an asynchronous recursive function inside an async trampoline executor.\n *\n * This helper transforms a recursive async function that returns a Trampoline<Result>\n * (or Promise<Trampoline<Result>>) into a *stack-safe* async function that executes\n * iteratively via the `asyncTrampoline` runner.\n *\n * @template Args - The tuple type representing the argument list of the original function.\n * @template Result - The final return type after all async trampoline steps are resolved.\n *\n * @param fn - An async or sync function that performs a single step of computation\n *             and returns a Trampoline (either a final value or a deferred thunk).\n *\n * @returns An async function with the same arguments, but which automatically\n *          runs the trampoline process and resolves to the *final result*.\n *\n * @example\n * // Example: Async factorial using trampoline\n * const asyncFactorial = makeAsyncTrampoline(async function fact(\n *   n: number,\n *   acc: number = 1\n * ): Promise<Trampoline<number>> {\n *   return n === 0\n *     ? acc\n *     : makeTrampolineThunk(() => fact(n - 1, acc * n));\n * });\n *\n * asyncFactorial(100000).then(console.log); // Works without stack overflow\n */\nexport function makeAsyncTrampoline<Args extends any[], Result>(\n  fn: (...args: Args) => Trampoline<Result> | Promise<Trampoline<Result>>\n): (...args: Args) => Promise<Result> {\n  // Return a wrapped async function that runs through the async trampoline loop\n  return async (...args: Args): Promise<Result> => {\n    return asyncTrampoline(fn(...args));\n  };\n}\n","import { isComparable } from '../utils';\n\nexport enum DFSOperation {\n  VISIT = 0,\n  PROCESS = 1\n}\n\nexport class Range<K> {\n  constructor(\n    public low: K,\n    public high: K,\n    public includeLow: boolean = true,\n    public includeHigh: boolean = true\n  ) {\n    if (!(isComparable(low) && isComparable(high))) throw new RangeError('low or high is not comparable');\n    if (low > high) throw new RangeError('low must be less than or equal to high');\n  }\n\n  // Determine whether a key is within the range\n  isInRange(key: K, comparator: (a: K, b: K) => number): boolean {\n    const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;\n    const highCheck = this.includeHigh ? comparator(key, this.high) <= 0 : comparator(key, this.high) < 0;\n    return lowCheck && highCheck;\n  }\n}\n"]}