list-toolkit 2.2.6 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +40 -37
  2. package/llms-full.txt +743 -0
  3. package/llms.txt +100 -0
  4. package/package.json +34 -29
  5. package/src/cache/cache-fifo.d.ts +6 -0
  6. package/src/cache/cache-fifo.js +7 -4
  7. package/src/cache/cache-lfu.d.ts +18 -0
  8. package/src/cache/cache-lfu.js +18 -6
  9. package/src/cache/cache-lru.d.ts +74 -0
  10. package/src/cache/cache-lru.js +60 -5
  11. package/src/cache/cache-random.d.ts +20 -0
  12. package/src/cache/cache-random.js +17 -6
  13. package/src/cache/decorator.d.ts +46 -0
  14. package/src/cache/decorator.js +26 -2
  15. package/src/cache.d.ts +13 -0
  16. package/src/cache.js +7 -2
  17. package/src/ext-list.d.ts +3 -0
  18. package/src/ext-list.js +0 -2
  19. package/src/ext-slist.d.ts +3 -0
  20. package/src/ext-slist.js +0 -2
  21. package/src/ext-value-list.d.ts +3 -0
  22. package/src/ext-value-list.js +0 -2
  23. package/src/ext-value-slist.d.ts +3 -0
  24. package/src/ext-value-slist.js +0 -2
  25. package/src/heap/basics.d.ts +89 -0
  26. package/src/heap/basics.js +42 -5
  27. package/src/heap/leftist-heap.d.ts +107 -0
  28. package/src/heap/leftist-heap.js +54 -2
  29. package/src/heap/min-heap.d.ts +270 -0
  30. package/src/heap/min-heap.js +186 -2
  31. package/src/heap/skew-heap.d.ts +105 -0
  32. package/src/heap/skew-heap.js +54 -2
  33. package/src/heap.d.ts +3 -0
  34. package/src/heap.js +0 -2
  35. package/src/list/basics.d.ts +43 -0
  36. package/src/list/basics.js +26 -8
  37. package/src/list/core.d.ts +271 -0
  38. package/src/list/core.js +162 -7
  39. package/src/list/ext-value.d.ts +253 -0
  40. package/src/list/ext-value.js +40 -6
  41. package/src/list/ext.d.ts +242 -0
  42. package/src/list/ext.js +148 -10
  43. package/src/list/nodes.d.ts +336 -0
  44. package/src/list/nodes.js +141 -3
  45. package/src/list/ptr.d.ts +72 -0
  46. package/src/list/ptr.js +44 -2
  47. package/src/list/value.d.ts +292 -0
  48. package/src/list/value.js +47 -6
  49. package/src/list-helpers.d.ts +44 -0
  50. package/src/list-helpers.js +36 -3
  51. package/src/list-utils.d.ts +141 -0
  52. package/src/list-utils.js +89 -3
  53. package/src/list.d.ts +3 -0
  54. package/src/list.js +0 -2
  55. package/src/meta-utils.d.ts +212 -0
  56. package/src/meta-utils.js +152 -1
  57. package/src/nt-utils.d.ts +91 -0
  58. package/src/nt-utils.js +65 -4
  59. package/src/queue.d.ts +74 -0
  60. package/src/queue.js +28 -2
  61. package/src/slist/basics.d.ts +47 -0
  62. package/src/slist/basics.js +23 -8
  63. package/src/slist/core.d.ts +251 -0
  64. package/src/slist/core.js +151 -6
  65. package/src/slist/ext-value.d.ts +188 -0
  66. package/src/slist/ext-value.js +35 -6
  67. package/src/slist/ext.d.ts +182 -0
  68. package/src/slist/ext.js +114 -12
  69. package/src/slist/nodes.d.ts +361 -0
  70. package/src/slist/nodes.js +156 -3
  71. package/src/slist/ptr.d.ts +73 -0
  72. package/src/slist/ptr.js +45 -2
  73. package/src/slist/value.d.ts +246 -0
  74. package/src/slist/value.js +38 -6
  75. package/src/slist.d.ts +3 -0
  76. package/src/slist.js +0 -2
  77. package/src/stack.d.ts +59 -0
  78. package/src/stack.js +29 -3
  79. package/src/tree/splay-tree.d.ts +151 -0
  80. package/src/tree/splay-tree.js +94 -3
  81. package/src/value-list.d.ts +3 -0
  82. package/src/value-list.js +0 -2
  83. package/src/value-slist.d.ts +3 -0
  84. package/src/value-slist.js +0 -2
  85. package/cjs/cache/cache-fifo.js +0 -37
  86. package/cjs/cache/cache-lfu.js +0 -76
  87. package/cjs/cache/cache-lru.js +0 -100
  88. package/cjs/cache/cache-random.js +0 -77
  89. package/cjs/cache/decorator.js +0 -47
  90. package/cjs/cache.js +0 -27
  91. package/cjs/ext-list.js +0 -21
  92. package/cjs/ext-slist.js +0 -21
  93. package/cjs/ext-value-list.js +0 -21
  94. package/cjs/ext-value-slist.js +0 -21
  95. package/cjs/heap/basics.js +0 -63
  96. package/cjs/heap/leftist-heap.js +0 -124
  97. package/cjs/heap/min-heap.js +0 -294
  98. package/cjs/heap/skew-heap.js +0 -114
  99. package/cjs/heap.js +0 -21
  100. package/cjs/list/basics.js +0 -88
  101. package/cjs/list/core.js +0 -305
  102. package/cjs/list/ext-value.js +0 -88
  103. package/cjs/list/ext.js +0 -356
  104. package/cjs/list/nodes.js +0 -240
  105. package/cjs/list/ptr.js +0 -61
  106. package/cjs/list/value.js +0 -99
  107. package/cjs/list-helpers.js +0 -91
  108. package/cjs/list-utils.js +0 -141
  109. package/cjs/list.js +0 -21
  110. package/cjs/meta-utils.js +0 -171
  111. package/cjs/nt-utils.js +0 -132
  112. package/cjs/package.json +0 -1
  113. package/cjs/queue.js +0 -58
  114. package/cjs/slist/basics.js +0 -71
  115. package/cjs/slist/core.js +0 -362
  116. package/cjs/slist/ext-value.js +0 -82
  117. package/cjs/slist/ext.js +0 -336
  118. package/cjs/slist/nodes.js +0 -276
  119. package/cjs/slist/ptr.js +0 -87
  120. package/cjs/slist/value.js +0 -90
  121. package/cjs/slist.js +0 -21
  122. package/cjs/stack.js +0 -55
  123. package/cjs/tree/splay-tree.js +0 -362
  124. package/cjs/value-list.js +0 -21
  125. package/cjs/value-slist.js +0 -21
@@ -0,0 +1,105 @@
1
+ import HeapBase, {HeapOptions} from './basics.js';
2
+
3
+ /** Node used internally by {@link SkewHeap}. */
4
+ export class SkewHeapNode<T = unknown> {
5
+ /** The stored value. */
6
+ value: T;
7
+ /** Left child, or `null`. */
8
+ left: SkewHeapNode<T> | null;
9
+ /** Right child, or `null`. */
10
+ right: SkewHeapNode<T> | null;
11
+
12
+ /** @param value - Value to store. */
13
+ constructor(value: T);
14
+
15
+ /** Reset children to `null`. */
16
+ clear(): void;
17
+
18
+ /**
19
+ * Create a deep copy of this subtree.
20
+ * @returns A new SkewHeapNode tree.
21
+ */
22
+ clone(): SkewHeapNode<T>;
23
+ }
24
+
25
+ /** Merge-based skew heap. */
26
+ export class SkewHeap<T = unknown> extends HeapBase<T> {
27
+ /** Root node, or `null` if empty. */
28
+ root: SkewHeapNode<T> | null;
29
+ /** Number of elements. */
30
+ size: number;
31
+
32
+ /**
33
+ * @param options - Ordering functions.
34
+ * @param args - Initial heaps to merge.
35
+ */
36
+ constructor(options?: HeapOptions<T>, ...args: SkewHeap<T>[]);
37
+
38
+ /** Whether the heap has no elements. */
39
+ get isEmpty(): boolean;
40
+
41
+ /** Number of elements. */
42
+ get length(): number;
43
+
44
+ /** The minimum element without removing it. */
45
+ get top(): T | undefined;
46
+
47
+ /** Alias for {@link top}. */
48
+ peek(): T | undefined;
49
+
50
+ /**
51
+ * Insert a value into the heap.
52
+ * @param value - Value to insert.
53
+ * @returns `this` for chaining.
54
+ */
55
+ push(value: T): this;
56
+
57
+ /**
58
+ * Remove and return the minimum element.
59
+ * @returns The minimum element, or `undefined` if empty.
60
+ */
61
+ pop(): T | undefined;
62
+
63
+ /**
64
+ * Push a value then immediately pop the minimum.
65
+ * @param value - Value to push.
66
+ * @returns The minimum element after the push.
67
+ */
68
+ pushPop(value: T): T;
69
+
70
+ /**
71
+ * Pop the minimum then push a new value.
72
+ * @param value - Value to push after popping.
73
+ * @returns The old minimum element, or `undefined` if was empty.
74
+ */
75
+ replaceTop(value: T): T | undefined;
76
+
77
+ /**
78
+ * Remove all elements.
79
+ * @returns `this` for chaining.
80
+ */
81
+ clear(): this;
82
+
83
+ /**
84
+ * Merge other skew heaps into this one, consuming them.
85
+ * @param args - Heaps to merge (they are cleared).
86
+ * @returns `this` for chaining.
87
+ */
88
+ merge(...args: SkewHeap<T>[]): this;
89
+
90
+ /**
91
+ * Create a deep copy of this heap.
92
+ * @returns A new SkewHeap with the same elements.
93
+ */
94
+ clone(): SkewHeap<T>;
95
+
96
+ /**
97
+ * Build a SkewHeap from an iterable.
98
+ * @param array - Iterable of values.
99
+ * @param options - Ordering functions.
100
+ * @returns A new SkewHeap.
101
+ */
102
+ static from<T = unknown>(array: Iterable<T>, options?: HeapOptions<T>): SkewHeap<T>;
103
+ }
104
+
105
+ export default SkewHeap;
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  import HeapBase from './basics.js';
4
2
 
5
3
  const merge = (a, b, less) => {
@@ -14,14 +12,21 @@ const merge = (a, b, less) => {
14
12
  return a;
15
13
  };
16
14
 
15
+ /** Node for a skew heap. */
17
16
  export class SkewHeapNode {
17
+ /** @param {*} value - Value to store. */
18
18
  constructor(value) {
19
19
  this.value = value;
20
20
  this.right = this.left = null;
21
21
  }
22
+ /** Reset child links. */
22
23
  clear() {
23
24
  this.left = this.right = null;
24
25
  }
26
+ /**
27
+ * Deep-clone this node and its subtree.
28
+ * @returns {SkewHeapNode} A new node tree.
29
+ */
25
30
  clone() {
26
31
  const node = new SkewHeapNode(this.value);
27
32
  node.left = this.left && this.left.clone();
@@ -30,7 +35,12 @@ export class SkewHeapNode {
30
35
  }
31
36
  }
32
37
 
38
+ /** Skew heap — a self-adjusting merge-based min-heap. */
33
39
  export class SkewHeap extends HeapBase {
40
+ /**
41
+ * @param {object} [options] - Ordering options (`less`, `compare`).
42
+ * @param {...SkewHeap} args - Initial heaps to merge.
43
+ */
34
44
  constructor(options, ...args) {
35
45
  super(options);
36
46
  if (typeof this.compare == 'function') {
@@ -40,23 +50,36 @@ export class SkewHeap extends HeapBase {
40
50
  this.size = 0;
41
51
  if (args.length) this.merge(...args);
42
52
  }
53
+ /** Whether the heap has no elements. */
43
54
  get isEmpty() {
44
55
  return !this.root;
45
56
  }
57
+ /** The number of elements. */
46
58
  get length() {
47
59
  return this.size;
48
60
  }
61
+ /** The minimum element without removing it. */
49
62
  get top() {
50
63
  return this.root ? this.root.value : undefined;
51
64
  }
65
+ /** Alias for {@link SkewHeap#top|top}. */
52
66
  peek() {
53
67
  return this.root ? this.root.value : undefined;
54
68
  }
69
+ /**
70
+ * Add an element.
71
+ * @param {*} value - Element to add.
72
+ * @returns {SkewHeap} `this` for chaining.
73
+ */
55
74
  push(value) {
56
75
  this.root = merge(this.root, new SkewHeapNode(value), this.less);
57
76
  ++this.size;
58
77
  return this;
59
78
  }
79
+ /**
80
+ * Remove and return the minimum element.
81
+ * @returns {*} The removed element, or `undefined` if empty.
82
+ */
60
83
  pop() {
61
84
  if (!this.root) return;
62
85
  const z = this.root;
@@ -64,6 +87,11 @@ export class SkewHeap extends HeapBase {
64
87
  --this.size;
65
88
  return z.value;
66
89
  }
90
+ /**
91
+ * Push then pop in one operation.
92
+ * @param {*} value - Element to push.
93
+ * @returns {*} The popped element.
94
+ */
67
95
  pushPop(value) {
68
96
  if (!this.root || this.less(value, this.root.value)) return value;
69
97
  const z = this.root;
@@ -71,6 +99,11 @@ export class SkewHeap extends HeapBase {
71
99
  this.root = merge(this.root, z.right, this.less);
72
100
  return z.value;
73
101
  }
102
+ /**
103
+ * Pop then push in one operation.
104
+ * @param {*} value - Element to push.
105
+ * @returns {*} The previously minimum element, or `undefined` if was empty.
106
+ */
74
107
  replaceTop(value) {
75
108
  if (!this.root) {
76
109
  this.root = new SkewHeapNode(value);
@@ -82,11 +115,20 @@ export class SkewHeap extends HeapBase {
82
115
  this.root = merge(this.root, z.right, this.less);
83
116
  return z.value;
84
117
  }
118
+ /**
119
+ * Remove all elements.
120
+ * @returns {SkewHeap} `this` for chaining.
121
+ */
85
122
  clear() {
86
123
  this.root = null;
87
124
  this.size = 0;
88
125
  return this;
89
126
  }
127
+ /**
128
+ * Merge one or more heaps into this heap, consuming them.
129
+ * @param {...SkewHeap} args - Heaps to merge.
130
+ * @returns {SkewHeap} `this` for chaining.
131
+ */
90
132
  merge(...args) {
91
133
  for (const other of args) {
92
134
  this.root = merge(this.root, other.root, this.less);
@@ -96,6 +138,10 @@ export class SkewHeap extends HeapBase {
96
138
  }
97
139
  return this;
98
140
  }
141
+ /**
142
+ * Create a deep copy of this heap.
143
+ * @returns {SkewHeap} A new SkewHeap with cloned nodes.
144
+ */
99
145
  clone() {
100
146
  const heap = new SkewHeap(this);
101
147
  heap.root = this.root && this.root.clone();
@@ -103,6 +149,12 @@ export class SkewHeap extends HeapBase {
103
149
  return heap;
104
150
  }
105
151
 
152
+ /**
153
+ * Build a SkewHeap from an iterable.
154
+ * @param {Iterable} array - Elements to insert.
155
+ * @param {object} [options] - Ordering options.
156
+ * @returns {SkewHeap} A new SkewHeap.
157
+ */
106
158
  static from(array, options = HeapBase.defaults) {
107
159
  const heap = new SkewHeap(options);
108
160
  for (const value of array) heap.push(value);
package/src/heap.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './heap/min-heap.js';
2
+ import Heap from './heap/min-heap.js';
3
+ export default Heap;
package/src/heap.js CHANGED
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  export * from './heap/min-heap.js';
4
2
  import Heap from './heap/min-heap.js';
5
3
 
@@ -0,0 +1,43 @@
1
+ import {DllOptions, DllRange} from './nodes.js';
2
+
3
+ /** Result of extracting or popping nodes from a circular list. */
4
+ export interface ExtractResult<T extends object> {
5
+ /** The extracted node (or first node of the extracted range). */
6
+ extracted: T;
7
+ /** The remaining circular list head, or `null` if nothing remains. */
8
+ rest: T | null;
9
+ }
10
+
11
+ /**
12
+ * Extract a range of nodes from a circular list.
13
+ * @param options - Link property names.
14
+ * @param range - Range to extract (`from` and optionally `to`).
15
+ * @returns The extracted circular sub-list and the remaining list.
16
+ */
17
+ export function extract<T extends object>(options: DllOptions, range: DllRange<T>): ExtractResult<T>;
18
+
19
+ /**
20
+ * Pop a single node out of its circular list.
21
+ * @param options - Link property names.
22
+ * @param node - Node to remove.
23
+ * @returns The popped node (now stand-alone) and the remaining list.
24
+ */
25
+ export function pop<T extends object>(options: DllOptions, node: T): ExtractResult<T>;
26
+
27
+ /**
28
+ * Splice a circular list into another list after a target node.
29
+ * @param options - Link property names.
30
+ * @param target - Node after which to insert.
31
+ * @param circularList - Head of the circular list to splice in.
32
+ * @returns The target node.
33
+ */
34
+ export function splice<T extends object>(options: DllOptions, target: T, circularList: T): T;
35
+
36
+ /**
37
+ * Extract a range and splice it after a target node in one operation.
38
+ * @param options - Link property names.
39
+ * @param target - Node after which to insert.
40
+ * @param range - Range to extract and append (`from` and optionally `to`).
41
+ * @returns The target node.
42
+ */
43
+ export function append<T extends object>(options: DllOptions, target: T, range: DllRange<T>): T;
@@ -1,7 +1,9 @@
1
- 'use strict';
2
-
3
- // useful low-level operations on doubly linked lists
4
-
1
+ /**
2
+ * Extract a range of nodes from a circular DLL.
3
+ * @param {object} options - Link property names.
4
+ * @param {object} range - Range descriptor with `from` and optional `to`.
5
+ * @returns {{extracted: object, rest: object|null}} The extracted sub-list and the remaining list.
6
+ */
5
7
  export const extract = ({nextName, prevName}, {from, to = from}) => {
6
8
  const next = to[nextName],
7
9
  prev = from[prevName];
@@ -17,8 +19,12 @@ export const extract = ({nextName, prevName}, {from, to = from}) => {
17
19
  return {extracted: from, rest: next === from ? null : next};
18
20
  };
19
21
 
20
- // pop(options, head).node === extract(options, {from: node})
21
-
22
+ /**
23
+ * Pop a single node out of its circular DLL.
24
+ * @param {object} options - Link property names.
25
+ * @param {object} node - The node to pop.
26
+ * @returns {{extracted: object, rest: object|null}} The popped node (now stand-alone) and the remaining list.
27
+ */
22
28
  export const pop = ({nextName, prevName}, node) => {
23
29
  const next = node[nextName],
24
30
  prev = node[prevName];
@@ -33,6 +39,13 @@ export const pop = ({nextName, prevName}, node) => {
33
39
  return {extracted: node, rest: next === node ? null : next};
34
40
  };
35
41
 
42
+ /**
43
+ * Splice a circular DLL into another list after a target node.
44
+ * @param {object} options - Link property names.
45
+ * @param {object} target - Node after which to insert.
46
+ * @param {object} circularList - Head of the circular list to splice in.
47
+ * @returns {object} The target node.
48
+ */
36
49
  export const splice = ({nextName, prevName}, target, circularList) => {
37
50
  const next = target[nextName],
38
51
  from = circularList,
@@ -47,8 +60,13 @@ export const splice = ({nextName, prevName}, target, circularList) => {
47
60
  return target;
48
61
  };
49
62
 
50
- // append(options, target, range) === splice(options, target, extract(options, range))
51
-
63
+ /**
64
+ * Extract a range and splice it after a target node in one operation.
65
+ * @param {object} options - Link property names.
66
+ * @param {object} target - Node after which to insert.
67
+ * @param {object} range - Range descriptor with `from` and optional `to`.
68
+ * @returns {object} The target node.
69
+ */
52
70
  export const append = ({nextName, prevName}, target, {from, to = from}) => {
53
71
  // extract
54
72
  from[prevName][nextName] = to[nextName];
@@ -0,0 +1,271 @@
1
+ import {HeadNode, ExtListBase, PtrBase, DllOptions, DllRange} from './nodes.js';
2
+ import {Ptr} from './ptr.js';
3
+
4
+ /** Hosted node-based doubly linked list with a sentinel head. */
5
+ export class List<T extends object = object> extends HeadNode {
6
+ /** The first node after the head. */
7
+ get front(): T;
8
+
9
+ /** The last node before the head. */
10
+ get back(): T;
11
+
12
+ /** A range spanning all nodes, or `null` if empty. */
13
+ get range(): DllRange<T> | null;
14
+
15
+ /** Pointer to the first node. */
16
+ get frontPtr(): Ptr<T>;
17
+
18
+ /** Pointer to the last node. */
19
+ get backPtr(): Ptr<T>;
20
+
21
+ /**
22
+ * Create a pointer to a node in this list.
23
+ * @param node - Target node, or `undefined` for the front.
24
+ * @returns A new Ptr.
25
+ */
26
+ makePtr(node?: T): Ptr<T>;
27
+
28
+ /**
29
+ * Create a pointer to the node after `prev`.
30
+ * @param prev - Preceding node, or `undefined` for the front.
31
+ * @returns A new Ptr.
32
+ */
33
+ makePtrFromPrev(prev?: T): Ptr<T>;
34
+
35
+ /**
36
+ * Insert a value at the front.
37
+ * @param value - Value or node to insert.
38
+ * @returns A Ptr to the inserted node.
39
+ */
40
+ pushFront(value: T | PtrBase<T>): Ptr<T>;
41
+
42
+ /**
43
+ * Insert a value at the back.
44
+ * @param value - Value or node to insert.
45
+ * @returns A Ptr to the inserted node.
46
+ */
47
+ pushBack(value: T | PtrBase<T>): Ptr<T>;
48
+
49
+ /**
50
+ * Remove and return the front node.
51
+ * @returns The removed node, or `undefined` if empty.
52
+ */
53
+ popFrontNode(): T | undefined;
54
+
55
+ /**
56
+ * Remove and return the back node.
57
+ * @returns The removed node, or `undefined` if empty.
58
+ */
59
+ popBackNode(): T | undefined;
60
+
61
+ /** Alias for {@link popFrontNode}. */
62
+ popFront(): T | undefined;
63
+
64
+ /** Alias for {@link popFrontNode}. */
65
+ pop(): T | undefined;
66
+
67
+ /** Alias for {@link popBackNode}. */
68
+ popBack(): T | undefined;
69
+
70
+ /**
71
+ * Insert an existing node at the front.
72
+ * @param nodeOrPtr - Node or pointer to insert.
73
+ * @returns A Ptr to the inserted node.
74
+ */
75
+ pushFrontNode(nodeOrPtr: T | PtrBase<T>): Ptr<T>;
76
+
77
+ /** Alias for {@link pushFront}. */
78
+ push(value: T | PtrBase<T>): Ptr<T>;
79
+
80
+ /**
81
+ * Insert an existing node at the back.
82
+ * @param nodeOrPtr - Node or pointer to insert.
83
+ * @returns A Ptr to the inserted node.
84
+ */
85
+ pushBackNode(nodeOrPtr: T | PtrBase<T>): Ptr<T>;
86
+
87
+ /**
88
+ * Move all nodes from another list to the front.
89
+ * @param list - Compatible list to consume.
90
+ * @returns A Ptr to the new front.
91
+ */
92
+ appendFront(list: HeadNode): Ptr<T>;
93
+
94
+ /**
95
+ * Move all nodes from another list to the back.
96
+ * @param list - Compatible list to consume.
97
+ * @returns A Ptr to the first appended node.
98
+ */
99
+ appendBack(list: HeadNode): Ptr<T>;
100
+
101
+ /** Alias for {@link appendBack}. */
102
+ append(list: HeadNode): Ptr<T>;
103
+
104
+ /**
105
+ * Move a node to the front of the list.
106
+ * @param nodeOrPtr - Node or pointer to move.
107
+ * @returns A Ptr to the front.
108
+ */
109
+ moveToFront(nodeOrPtr: T | PtrBase<T>): Ptr<T>;
110
+
111
+ /**
112
+ * Move a node to the back of the list.
113
+ * @param nodeOrPtr - Node or pointer to move.
114
+ * @returns A Ptr to the back.
115
+ */
116
+ moveToBack(nodeOrPtr: T | PtrBase<T>): Ptr<T>;
117
+
118
+ /**
119
+ * Remove all nodes.
120
+ * @param drop - If `true`, pop nodes one by one (making each stand-alone).
121
+ * @returns `this` for chaining.
122
+ */
123
+ clear(drop?: boolean): this;
124
+
125
+ /**
126
+ * Remove a single node from the list.
127
+ * @param nodeOrPtr - Node or pointer to remove.
128
+ * @returns The removed node.
129
+ */
130
+ removeNode(nodeOrPtr: T | PtrBase<T>): T;
131
+
132
+ /**
133
+ * Remove a range of nodes and optionally drop them.
134
+ * @param range - Range to remove.
135
+ * @param drop - If `true`, make each removed node stand-alone.
136
+ * @returns A new List containing the removed nodes.
137
+ */
138
+ removeRange(range?: DllRange<T>, drop?: boolean): List<T>;
139
+
140
+ /**
141
+ * Extract a range of nodes into a new list.
142
+ * @param range - Range to extract (defaults to the whole list).
143
+ * @returns A new List containing the extracted nodes.
144
+ */
145
+ extractRange(range?: DllRange<T>): List<T>;
146
+
147
+ /**
148
+ * Extract nodes that satisfy a condition into a new list.
149
+ * @param condition - Predicate receiving each node.
150
+ * @returns A new List containing the extracted nodes.
151
+ */
152
+ extractBy(condition: (node: T) => boolean): List<T>;
153
+
154
+ /**
155
+ * Reverse the order of all nodes in place.
156
+ * @returns `this` for chaining.
157
+ */
158
+ reverse(): this;
159
+
160
+ /**
161
+ * Sort nodes in place using merge sort.
162
+ * @param lessFn - Comparison function returning `true` if `a` should precede `b`.
163
+ * @returns `this` for chaining.
164
+ */
165
+ sort(lessFn: (a: T, b: T) => boolean): this;
166
+
167
+ /**
168
+ * Detach all nodes as a raw circular list (no sentinel).
169
+ * @returns Head of the raw circular list, or `null` if empty.
170
+ */
171
+ releaseRawList(): T | null;
172
+
173
+ /**
174
+ * Detach all nodes as a null-terminated list.
175
+ * @returns Object with `head` and `tail`, or `null` if empty.
176
+ */
177
+ releaseNTList(): {head: T; tail: T} | null;
178
+
179
+ /**
180
+ * Validate that a range is reachable within this list.
181
+ * @param range - Range to validate.
182
+ * @returns `true` if the range is valid.
183
+ */
184
+ validateRange(range?: DllRange<T>): boolean;
185
+
186
+ /** Iterate over nodes from front to back. */
187
+ [Symbol.iterator](): IterableIterator<T>;
188
+
189
+ /**
190
+ * Get an iterable over nodes in a range.
191
+ * @param range - Sub-range to iterate (defaults to the whole list).
192
+ * @returns An iterable iterator of nodes.
193
+ */
194
+ getNodeIterator(range?: DllRange<T>): IterableIterator<T>;
195
+
196
+ /** Alias for {@link getNodeIterator}. */
197
+ getIterator(range?: DllRange<T>): IterableIterator<T>;
198
+
199
+ /**
200
+ * Get an iterable of Ptr objects over a range.
201
+ * @param range - Sub-range to iterate.
202
+ * @returns An iterable iterator of Ptrs.
203
+ */
204
+ getPtrIterator(range?: DllRange<T>): IterableIterator<Ptr<T>>;
205
+
206
+ /**
207
+ * Get an iterable over nodes in reverse order.
208
+ * @param range - Sub-range to iterate (defaults to the whole list).
209
+ * @returns An iterable iterator of nodes.
210
+ */
211
+ getReverseNodeIterator(range?: DllRange<T>): IterableIterator<T>;
212
+
213
+ /** Alias for {@link getReverseNodeIterator}. */
214
+ getReverseIterator(range?: DllRange<T>): IterableIterator<T>;
215
+
216
+ /**
217
+ * Get an iterable of Ptr objects in reverse order.
218
+ * @param range - Sub-range to iterate.
219
+ * @returns An iterable iterator of Ptrs.
220
+ */
221
+ getReversePtrIterator(range?: DllRange<T>): IterableIterator<Ptr<T>>;
222
+
223
+ /**
224
+ * Create an empty list with the same options.
225
+ * @returns A new empty List.
226
+ */
227
+ make(): List<T>;
228
+
229
+ /**
230
+ * Create a list from values with the same options.
231
+ * @param values - Iterable of values.
232
+ * @returns A new List.
233
+ */
234
+ makeFrom(values: Iterable<T>): List<T>;
235
+
236
+ /**
237
+ * Create a list by extracting a range with the same options.
238
+ * @param range - Range to extract.
239
+ * @returns A new List.
240
+ */
241
+ makeFromRange(range: DllRange<T>): List<T>;
242
+
243
+ /**
244
+ * Build a list from an iterable.
245
+ * @param values - Iterable of values.
246
+ * @param options - Link property names.
247
+ * @returns A new List.
248
+ */
249
+ static from<T extends object = object>(values: Iterable<T>, options?: DllOptions): List<T>;
250
+
251
+ /**
252
+ * Build a list by extracting a range.
253
+ * @param range - Fully specified range.
254
+ * @param options - Link property names.
255
+ * @returns A new List.
256
+ */
257
+ static fromRange<T extends object = object>(range: DllRange<T> | null, options?: DllOptions): List<T>;
258
+
259
+ /**
260
+ * Convert an external list into a hosted list.
261
+ * @param extList - External list to consume (will be cleared).
262
+ * @returns A new List.
263
+ */
264
+ static fromExtList<T extends object = object>(extList: ExtListBase<T>): List<T>;
265
+
266
+ /** The Ptr class associated with this list type. */
267
+ static Ptr: typeof Ptr;
268
+ }
269
+
270
+ export {Ptr};
271
+ export default List;