data-structure-typed 2.6.0 → 2.6.2

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 (160) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/CHANGELOG.md +9 -1
  4. package/dist/cjs/binary-tree.cjs +2927 -23688
  5. package/dist/cjs/graph.cjs +845 -2634
  6. package/dist/cjs/hash.cjs +185 -616
  7. package/dist/cjs/heap.cjs +266 -818
  8. package/dist/cjs/index.cjs +5116 -31358
  9. package/dist/cjs/linked-list.cjs +644 -2615
  10. package/dist/cjs/matrix.cjs +220 -535
  11. package/dist/cjs/priority-queue.cjs +266 -818
  12. package/dist/cjs/queue.cjs +637 -2343
  13. package/dist/cjs/stack.cjs +124 -530
  14. package/dist/cjs/trie.cjs +145 -592
  15. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  16. package/dist/cjs-legacy/graph.cjs +847 -2636
  17. package/dist/cjs-legacy/hash.cjs +181 -612
  18. package/dist/cjs-legacy/heap.cjs +266 -818
  19. package/dist/cjs-legacy/index.cjs +6657 -32899
  20. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  21. package/dist/cjs-legacy/matrix.cjs +220 -535
  22. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  23. package/dist/cjs-legacy/queue.cjs +634 -2340
  24. package/dist/cjs-legacy/stack.cjs +124 -530
  25. package/dist/cjs-legacy/trie.cjs +145 -592
  26. package/dist/esm/binary-tree.mjs +2927 -23688
  27. package/dist/esm/graph.mjs +845 -2634
  28. package/dist/esm/hash.mjs +185 -616
  29. package/dist/esm/heap.mjs +266 -818
  30. package/dist/esm/index.mjs +5116 -31358
  31. package/dist/esm/linked-list.mjs +644 -2615
  32. package/dist/esm/matrix.mjs +220 -535
  33. package/dist/esm/priority-queue.mjs +266 -818
  34. package/dist/esm/queue.mjs +637 -2343
  35. package/dist/esm/stack.mjs +124 -530
  36. package/dist/esm/trie.mjs +145 -592
  37. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  38. package/dist/esm-legacy/graph.mjs +847 -2636
  39. package/dist/esm-legacy/hash.mjs +181 -612
  40. package/dist/esm-legacy/heap.mjs +266 -818
  41. package/dist/esm-legacy/index.mjs +6657 -32899
  42. package/dist/esm-legacy/linked-list.mjs +640 -2611
  43. package/dist/esm-legacy/matrix.mjs +220 -535
  44. package/dist/esm-legacy/priority-queue.mjs +266 -818
  45. package/dist/esm-legacy/queue.mjs +634 -2340
  46. package/dist/esm-legacy/stack.mjs +124 -530
  47. package/dist/esm-legacy/trie.mjs +145 -592
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  49. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  50. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  51. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  52. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  53. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  54. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  55. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  56. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  57. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  58. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  59. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  60. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  61. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  62. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  63. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  64. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  65. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  66. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  67. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  68. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  69. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  70. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  71. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  72. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  73. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  74. package/dist/umd/data-structure-typed.js +6580 -32822
  75. package/dist/umd/data-structure-typed.min.js +3 -3
  76. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  77. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  78. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  79. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  80. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  81. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  82. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  90. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  91. package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
  92. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
  93. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
  94. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
  95. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  96. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
  97. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  98. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  99. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
  100. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
  101. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
  102. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
  103. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
  104. package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
  105. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  106. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  107. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
  108. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  109. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  110. package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
  111. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  112. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
  113. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
  114. package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
  115. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  116. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  117. package/package.json +45 -46
  118. package/src/common/error.ts +15 -32
  119. package/src/common/index.ts +0 -3
  120. package/src/data-structures/base/iterable-element-base.ts +0 -3
  121. package/src/data-structures/base/linear-base.ts +2 -36
  122. package/src/data-structures/binary-tree/avl-tree.ts +31 -529
  123. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
  124. package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
  125. package/src/data-structures/binary-tree/bst.ts +158 -1082
  126. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
  127. package/src/data-structures/binary-tree/segment-tree.ts +73 -351
  128. package/src/data-structures/binary-tree/tree-map.ts +462 -5124
  129. package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
  130. package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
  131. package/src/data-structures/binary-tree/tree-set.ts +338 -4836
  132. package/src/data-structures/graph/abstract-graph.ts +98 -167
  133. package/src/data-structures/graph/directed-graph.ts +137 -562
  134. package/src/data-structures/graph/map-graph.ts +0 -3
  135. package/src/data-structures/graph/undirected-graph.ts +132 -511
  136. package/src/data-structures/hash/hash-map.ts +154 -582
  137. package/src/data-structures/heap/heap.ts +200 -795
  138. package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
  139. package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
  140. package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
  141. package/src/data-structures/matrix/matrix.ts +179 -518
  142. package/src/data-structures/matrix/navigator.ts +0 -1
  143. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  144. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  145. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  146. package/src/data-structures/queue/deque.ts +214 -882
  147. package/src/data-structures/queue/queue.ts +102 -625
  148. package/src/data-structures/stack/stack.ts +76 -505
  149. package/src/data-structures/trie/trie.ts +98 -628
  150. package/src/types/common.ts +0 -10
  151. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  152. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  153. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  154. package/src/types/data-structures/hash/hash-map.ts +0 -3
  155. package/src/types/data-structures/hash/index.ts +0 -1
  156. package/src/types/data-structures/matrix/navigator.ts +0 -2
  157. package/src/types/utils/utils.ts +0 -7
  158. package/src/types/utils/validate-type.ts +0 -7
  159. package/src/utils/number.ts +0 -2
  160. package/src/utils/utils.ts +0 -5
@@ -723,7 +723,6 @@ var SinglyLinkedList = class extends LinearLinkedBase {
723
723
  static {
724
724
  __name(this, "SinglyLinkedList");
725
725
  }
726
- _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
727
726
  /**
728
727
  * Create a SinglyLinkedList and optionally bulk-insert elements.
729
728
  * @remarks Time O(N), Space O(N)
@@ -795,68 +794,26 @@ var SinglyLinkedList = class extends LinearLinkedBase {
795
794
  return list;
796
795
  }
797
796
  /**
798
- * Append an element/node to the tail.
799
- * @remarks Time O(1), Space O(1)
800
- * @param elementOrNode - Element or node to append.
801
- * @returns True when appended.
802
-
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
-
844
- * @example
845
- * // basic SinglyLinkedList creation and push operation
846
- * // Create a simple SinglyLinkedList with initial values
847
- * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
848
- *
849
- * // Verify the list maintains insertion order
850
- * console.log([...list]); // [1, 2, 3, 4, 5];
851
- *
852
- * // Check length
853
- * console.log(list.length); // 5;
854
- *
855
- * // Push a new element to the end
856
- * list.push(6);
857
- * console.log(list.length); // 6;
858
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
859
- */
797
+ * Append an element/node to the tail.
798
+ * @remarks Time O(1), Space O(1)
799
+ * @param elementOrNode - Element or node to append.
800
+ * @returns True when appended.
801
+ * @example
802
+ * // basic SinglyLinkedList creation and push operation
803
+ * // Create a simple SinglyLinkedList with initial values
804
+ * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
805
+ *
806
+ * // Verify the list maintains insertion order
807
+ * console.log([...list]); // [1, 2, 3, 4, 5];
808
+ *
809
+ * // Check length
810
+ * console.log(list.length); // 5;
811
+ *
812
+ * // Push a new element to the end
813
+ * list.push(6);
814
+ * console.log(list.length); // 6;
815
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
816
+ */
860
817
  push(elementOrNode) {
861
818
  const newNode = this._ensureNode(elementOrNode);
862
819
  if (!this.head) {
@@ -870,67 +827,25 @@ var SinglyLinkedList = class extends LinearLinkedBase {
870
827
  return true;
871
828
  }
872
829
  /**
873
- * Remove and return the tail element.
874
- * @remarks Time O(N), Space O(1)
875
- * @returns Removed element or undefined.
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
-
905
-
906
-
907
-
908
-
909
-
910
-
911
-
912
-
913
-
914
-
915
-
916
-
917
-
918
- * @example
919
- * // SinglyLinkedList pop and shift operations
920
- * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
921
- *
922
- * // Pop removes from the end
923
- * const last = list.pop();
924
- * console.log(last); // 50;
925
- *
926
- * // Shift removes from the beginning
927
- * const first = list.shift();
928
- * console.log(first); // 10;
929
- *
930
- * // Verify remaining elements
931
- * console.log([...list]); // [20, 30, 40];
932
- * console.log(list.length); // 3;
933
- */
830
+ * Remove and return the tail element.
831
+ * @remarks Time O(N), Space O(1)
832
+ * @returns Removed element or undefined.
833
+ * @example
834
+ * // SinglyLinkedList pop and shift operations
835
+ * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
836
+ *
837
+ * // Pop removes from the end
838
+ * const last = list.pop();
839
+ * console.log(last); // 50;
840
+ *
841
+ * // Shift removes from the beginning
842
+ * const first = list.shift();
843
+ * console.log(first); // 10;
844
+ *
845
+ * // Verify remaining elements
846
+ * console.log([...list]); // [20, 30, 40];
847
+ * console.log(list.length); // 3;
848
+ */
934
849
  pop() {
935
850
  if (!this.head) return void 0;
936
851
  if (this.head === this.tail) {
@@ -949,57 +864,15 @@ var SinglyLinkedList = class extends LinearLinkedBase {
949
864
  return value;
950
865
  }
951
866
  /**
952
- * Remove and return the head element.
953
- * @remarks Time O(1), Space O(1)
954
- * @returns Removed element or undefined.
955
-
956
-
957
-
958
-
959
-
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
-
971
-
972
-
973
-
974
-
975
-
976
-
977
-
978
-
979
-
980
-
981
-
982
-
983
-
984
-
985
-
986
-
987
-
988
-
989
-
990
-
991
-
992
-
993
-
994
-
995
-
996
-
997
- * @example
998
- * // Remove from the front
999
- * const list = new SinglyLinkedList<number>([10, 20, 30]);
1000
- * console.log(list.shift()); // 10;
1001
- * console.log(list.length); // 2;
1002
- */
867
+ * Remove and return the head element.
868
+ * @remarks Time O(1), Space O(1)
869
+ * @returns Removed element or undefined.
870
+ * @example
871
+ * // Remove from the front
872
+ * const list = new SinglyLinkedList<number>([10, 20, 30]);
873
+ * console.log(list.shift()); // 10;
874
+ * console.log(list.length); // 2;
875
+ */
1003
876
  shift() {
1004
877
  if (!this.head) return void 0;
1005
878
  const removed = this.head;
@@ -1009,73 +882,31 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1009
882
  return removed.value;
1010
883
  }
1011
884
  /**
1012
- * Prepend an element/node to the head.
1013
- * @remarks Time O(1), Space O(1)
1014
- * @param elementOrNode - Element or node to prepend.
1015
- * @returns True when prepended.
1016
-
1017
-
1018
-
1019
-
1020
-
1021
-
1022
-
1023
-
1024
-
1025
-
1026
-
1027
-
1028
-
1029
-
1030
-
1031
-
1032
-
1033
-
1034
-
1035
-
1036
-
1037
-
1038
-
1039
-
1040
-
1041
-
1042
-
1043
-
1044
-
1045
-
1046
-
1047
-
1048
-
1049
-
1050
-
1051
-
1052
-
1053
-
1054
-
1055
-
1056
-
1057
-
1058
- * @example
1059
- * // SinglyLinkedList unshift and forward traversal
1060
- * const list = new SinglyLinkedList<number>([20, 30, 40]);
1061
- *
1062
- * // Unshift adds to the beginning
1063
- * list.unshift(10);
1064
- * console.log([...list]); // [10, 20, 30, 40];
1065
- *
1066
- * // Access elements (forward traversal only for singly linked)
1067
- * const second = list.at(1);
1068
- * console.log(second); // 20;
1069
- *
1070
- * // SinglyLinkedList allows forward iteration only
1071
- * const elements: number[] = [];
1072
- * for (const item of list) {
1073
- * elements.push(item);
1074
- * }
1075
- * console.log(elements); // [10, 20, 30, 40];
1076
- *
1077
- * console.log(list.length); // 4;
1078
- */
885
+ * Prepend an element/node to the head.
886
+ * @remarks Time O(1), Space O(1)
887
+ * @param elementOrNode - Element or node to prepend.
888
+ * @returns True when prepended.
889
+ * @example
890
+ * // SinglyLinkedList unshift and forward traversal
891
+ * const list = new SinglyLinkedList<number>([20, 30, 40]);
892
+ *
893
+ * // Unshift adds to the beginning
894
+ * list.unshift(10);
895
+ * console.log([...list]); // [10, 20, 30, 40];
896
+ *
897
+ * // Access elements (forward traversal only for singly linked)
898
+ * const second = list.at(1);
899
+ * console.log(second); // 20;
900
+ *
901
+ * // SinglyLinkedList allows forward iteration only
902
+ * const elements: number[] = [];
903
+ * for (const item of list) {
904
+ * elements.push(item);
905
+ * }
906
+ * console.log(elements); // [10, 20, 30, 40];
907
+ *
908
+ * console.log(list.length); // 4;
909
+ */
1079
910
  unshift(elementOrNode) {
1080
911
  const newNode = this._ensureNode(elementOrNode);
1081
912
  if (!this.head) {
@@ -1131,59 +962,17 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1131
962
  return void 0;
1132
963
  }
1133
964
  /**
1134
- * Get the element at a given index.
1135
- * @remarks Time O(N), Space O(1)
1136
- * @param index - Zero-based index.
1137
- * @returns Element or undefined.
1138
-
1139
-
1140
-
1141
-
1142
-
1143
-
1144
-
1145
-
1146
-
1147
-
1148
-
1149
-
1150
-
1151
-
1152
-
1153
-
1154
-
1155
-
1156
-
1157
-
1158
-
1159
-
1160
-
1161
-
1162
-
1163
-
1164
-
1165
-
1166
-
1167
-
1168
-
1169
-
1170
-
1171
-
1172
-
1173
-
1174
-
1175
-
1176
-
1177
-
1178
-
1179
-
1180
- * @example
1181
- * // Access element by index
1182
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
1183
- * console.log(list.at(0)); // 'a';
1184
- * console.log(list.at(2)); // 'c';
1185
- * console.log(list.at(3)); // 'd';
1186
- */
965
+ * Get the element at a given index.
966
+ * @remarks Time O(N), Space O(1)
967
+ * @param index - Zero-based index.
968
+ * @returns Element or undefined.
969
+ * @example
970
+ * // Access element by index
971
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
972
+ * console.log(list.at(0)); // 'a';
973
+ * console.log(list.at(2)); // 'c';
974
+ * console.log(list.at(3)); // 'd';
975
+ */
1187
976
  at(index) {
1188
977
  if (index < 0 || index >= this._length) return void 0;
1189
978
  let current = this.head;
@@ -1200,54 +989,15 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1200
989
  return elementNodeOrPredicate instanceof SinglyLinkedListNode;
1201
990
  }
1202
991
  /**
1203
- * Get the node reference at a given index.
1204
- * @remarks Time O(N), Space O(1)
1205
- * @param index - Zero-based index.
1206
- * @returns Node or undefined.
1207
-
1208
-
1209
-
1210
-
1211
-
1212
-
1213
-
1214
-
1215
-
1216
-
1217
-
1218
-
1219
-
1220
-
1221
-
1222
-
1223
-
1224
-
1225
-
1226
-
1227
-
1228
-
1229
-
1230
-
1231
-
1232
-
1233
-
1234
-
1235
-
1236
-
1237
-
1238
-
1239
-
1240
-
1241
-
1242
-
1243
-
1244
-
1245
-
1246
- * @example
1247
- * // Get node at index
1248
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1249
- * console.log(list.getNodeAt(1)?.value); // 'b';
1250
- */
992
+ * Get the node reference at a given index.
993
+ * @remarks Time O(N), Space O(1)
994
+ * @param index - Zero-based index.
995
+ * @returns Node or undefined.
996
+ * @example
997
+ * // Get node at index
998
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
999
+ * console.log(list.getNodeAt(1)?.value); // 'b';
1000
+ */
1251
1001
  getNodeAt(index) {
1252
1002
  if (index < 0 || index >= this._length) return void 0;
1253
1003
  let current = this.head;
@@ -1255,55 +1005,16 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1255
1005
  return current;
1256
1006
  }
1257
1007
  /**
1258
- * Delete the element at an index.
1259
- * @remarks Time O(N), Space O(1)
1260
- * @param index - Zero-based index.
1261
- * @returns Removed element or undefined.
1262
-
1263
-
1264
-
1265
-
1266
-
1267
-
1268
-
1269
-
1270
-
1271
-
1272
-
1273
-
1274
-
1275
-
1276
-
1277
-
1278
-
1279
-
1280
-
1281
-
1282
-
1283
-
1284
-
1285
-
1286
-
1287
-
1288
-
1289
-
1290
-
1291
-
1292
-
1293
-
1294
-
1295
-
1296
-
1297
-
1298
-
1299
-
1300
-
1301
- * @example
1302
- * // Remove by index
1303
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1304
- * list.deleteAt(1);
1305
- * console.log(list.toArray()); // ['a', 'c'];
1306
- */
1008
+ * Delete the element at an index.
1009
+ * @remarks Time O(N), Space O(1)
1010
+ * @param index - Zero-based index.
1011
+ * @returns Removed element or undefined.
1012
+ * @example
1013
+ * // Remove by index
1014
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1015
+ * list.deleteAt(1);
1016
+ * console.log(list.toArray()); // ['a', 'c'];
1017
+ */
1307
1018
  deleteAt(index) {
1308
1019
  if (index < 0 || index >= this._length) return void 0;
1309
1020
  if (index === 0) return this.shift();
@@ -1316,55 +1027,16 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1316
1027
  return value;
1317
1028
  }
1318
1029
  /**
1319
- * Delete the first match by value/node.
1320
- * @remarks Time O(N), Space O(1)
1321
- * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
1322
- * @returns True if removed.
1323
-
1324
-
1325
-
1326
-
1327
-
1328
-
1329
-
1330
-
1331
-
1332
-
1333
-
1334
-
1335
-
1336
-
1337
-
1338
-
1339
-
1340
-
1341
-
1342
-
1343
-
1344
-
1345
-
1346
-
1347
-
1348
-
1349
-
1350
-
1351
-
1352
-
1353
-
1354
-
1355
-
1356
-
1357
-
1358
-
1359
-
1360
-
1361
-
1362
- * @example
1363
- * // Remove first occurrence
1364
- * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
1365
- * list.delete(2);
1366
- * console.log(list.toArray()); // [1, 3, 2];
1367
- */
1030
+ * Delete the first match by value/node.
1031
+ * @remarks Time O(N), Space O(1)
1032
+ * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
1033
+ * @returns True if removed.
1034
+ * @example
1035
+ * // Remove first occurrence
1036
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
1037
+ * list.delete(2);
1038
+ * console.log(list.toArray()); // [1, 3, 2];
1039
+ */
1368
1040
  delete(elementOrNode) {
1369
1041
  if (elementOrNode === void 0 || !this.head) return false;
1370
1042
  const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);
@@ -1381,56 +1053,17 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1381
1053
  return true;
1382
1054
  }
1383
1055
  /**
1384
- * Insert a new element/node at an index, shifting following nodes.
1385
- * @remarks Time O(N), Space O(1)
1386
- * @param index - Zero-based index.
1387
- * @param newElementOrNode - Element or node to insert.
1388
- * @returns True if inserted.
1389
-
1390
-
1391
-
1392
-
1393
-
1394
-
1395
-
1396
-
1397
-
1398
-
1399
-
1400
-
1401
-
1402
-
1403
-
1404
-
1405
-
1406
-
1407
-
1408
-
1409
-
1410
-
1411
-
1412
-
1413
-
1414
-
1415
-
1416
-
1417
-
1418
-
1419
-
1420
-
1421
-
1422
-
1423
-
1424
-
1425
-
1426
-
1427
-
1428
- * @example
1429
- * // Insert at index
1430
- * const list = new SinglyLinkedList<number>([1, 3]);
1431
- * list.addAt(1, 2);
1432
- * console.log(list.toArray()); // [1, 2, 3];
1433
- */
1056
+ * Insert a new element/node at an index, shifting following nodes.
1057
+ * @remarks Time O(N), Space O(1)
1058
+ * @param index - Zero-based index.
1059
+ * @param newElementOrNode - Element or node to insert.
1060
+ * @returns True if inserted.
1061
+ * @example
1062
+ * // Insert at index
1063
+ * const list = new SinglyLinkedList<number>([1, 3]);
1064
+ * list.addAt(1, 2);
1065
+ * console.log(list.toArray()); // [1, 2, 3];
1066
+ */
1434
1067
  addAt(index, newElementOrNode) {
1435
1068
  if (index < 0 || index > this._length) return false;
1436
1069
  if (index === 0) return this.unshift(newElementOrNode);
@@ -1456,163 +1089,41 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1456
1089
  return true;
1457
1090
  }
1458
1091
  /**
1459
- * Check whether the list is empty.
1460
- * @remarks Time O(1), Space O(1)
1461
- * @returns True if length is 0.
1462
-
1463
-
1464
-
1465
-
1466
-
1467
-
1468
-
1469
-
1470
-
1471
-
1472
-
1473
-
1474
-
1475
-
1476
-
1477
-
1478
-
1479
-
1480
-
1481
-
1482
-
1483
-
1484
-
1485
-
1486
-
1487
-
1488
-
1489
-
1490
-
1491
-
1492
-
1493
-
1494
-
1495
-
1496
-
1497
-
1498
-
1499
-
1500
-
1501
-
1502
- * @example
1503
- * // Check empty
1504
- * console.log(new SinglyLinkedList().isEmpty()); // true;
1505
- */
1092
+ * Check whether the list is empty.
1093
+ * @remarks Time O(1), Space O(1)
1094
+ * @returns True if length is 0.
1095
+ * @example
1096
+ * // Check empty
1097
+ * console.log(new SinglyLinkedList().isEmpty()); // true;
1098
+ */
1506
1099
  isEmpty() {
1507
1100
  return this._length === 0;
1508
1101
  }
1509
1102
  /**
1510
- * Remove all nodes and reset length.
1511
- * @remarks Time O(N), Space O(1)
1512
- * @returns void
1513
-
1514
-
1515
-
1516
-
1517
-
1518
-
1519
-
1520
-
1521
-
1522
-
1523
-
1524
-
1525
-
1526
-
1527
-
1528
-
1529
-
1530
-
1531
-
1532
-
1533
-
1534
-
1535
-
1536
-
1537
-
1538
-
1539
-
1540
-
1541
-
1542
-
1543
-
1544
-
1545
-
1546
-
1547
-
1548
-
1549
-
1550
-
1551
-
1552
-
1553
- * @example
1554
- * // Remove all
1555
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1556
- * list.clear();
1557
- * console.log(list.isEmpty()); // true;
1558
- */
1103
+ * Remove all nodes and reset length.
1104
+ * @remarks Time O(N), Space O(1)
1105
+ * @returns void
1106
+ * @example
1107
+ * // Remove all
1108
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1109
+ * list.clear();
1110
+ * console.log(list.isEmpty()); // true;
1111
+ */
1559
1112
  clear() {
1560
1113
  this._head = void 0;
1561
1114
  this._tail = void 0;
1562
1115
  this._length = 0;
1563
1116
  }
1564
1117
  /**
1565
- * Reverse the list in place.
1566
- * @remarks Time O(N), Space O(1)
1567
- * @returns This list.
1568
-
1569
-
1570
-
1571
-
1572
-
1573
-
1574
-
1575
-
1576
-
1577
-
1578
-
1579
-
1580
-
1581
-
1582
-
1583
-
1584
-
1585
-
1586
-
1587
-
1588
-
1589
-
1590
-
1591
-
1592
-
1593
-
1594
-
1595
-
1596
-
1597
-
1598
-
1599
-
1600
-
1601
-
1602
-
1603
-
1604
-
1605
-
1606
-
1607
-
1608
-
1609
-
1610
- * @example
1611
- * // Reverse the list in-place
1612
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
1613
- * list.reverse();
1614
- * console.log([...list]); // [4, 3, 2, 1];
1615
- */
1118
+ * Reverse the list in place.
1119
+ * @remarks Time O(N), Space O(1)
1120
+ * @returns This list.
1121
+ * @example
1122
+ * // Reverse the list in-place
1123
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
1124
+ * list.reverse();
1125
+ * console.log([...list]); // [4, 3, 2, 1];
1126
+ */
1616
1127
  reverse() {
1617
1128
  if (!this.head || this.head === this.tail) return this;
1618
1129
  let prev;
@@ -1787,126 +1298,44 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1787
1298
  return false;
1788
1299
  }
1789
1300
  /**
1790
- * Deep clone this list (values are copied by reference).
1791
- * @remarks Time O(N), Space O(N)
1792
- * @returns A new list with the same element sequence.
1793
-
1794
-
1795
-
1796
-
1797
-
1798
-
1799
-
1800
-
1801
-
1802
-
1803
-
1804
-
1805
-
1806
-
1807
-
1808
-
1809
-
1810
-
1811
-
1812
-
1813
-
1814
-
1815
-
1816
-
1817
-
1818
-
1819
-
1820
-
1821
-
1822
-
1823
-
1824
-
1825
-
1826
-
1827
-
1828
-
1829
-
1830
-
1831
-
1832
-
1833
- * @example
1834
- * // Deep copy
1835
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1836
- * const copy = list.clone();
1837
- * copy.pop();
1838
- * console.log(list.length); // 3;
1839
- * console.log(copy.length); // 2;
1840
- */
1301
+ * Deep clone this list (values are copied by reference).
1302
+ * @remarks Time O(N), Space O(N)
1303
+ * @returns A new list with the same element sequence.
1304
+ * @example
1305
+ * // Deep copy
1306
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1307
+ * const copy = list.clone();
1308
+ * copy.pop();
1309
+ * console.log(list.length); // 3;
1310
+ * console.log(copy.length); // 2;
1311
+ */
1841
1312
  clone() {
1842
1313
  const out = this._createInstance();
1843
1314
  for (const v of this) out.push(v);
1844
1315
  return out;
1845
1316
  }
1846
1317
  /**
1847
- * Filter values into a new list of the same class.
1848
- * @remarks Time O(N), Space O(N)
1849
- * @param callback - Predicate (value, index, list) → boolean to keep value.
1850
- * @param [thisArg] - Value for `this` inside the callback.
1851
- * @returns A new list with kept values.
1852
-
1853
-
1854
-
1855
-
1856
-
1857
-
1858
-
1859
-
1860
-
1861
-
1862
-
1863
-
1864
-
1865
-
1866
-
1867
-
1868
-
1869
-
1870
-
1871
-
1872
-
1873
-
1874
-
1875
-
1876
-
1877
-
1878
-
1879
-
1880
-
1881
-
1882
-
1883
-
1884
-
1885
-
1886
-
1887
-
1888
-
1889
-
1890
-
1891
-
1892
-
1893
-
1894
- * @example
1895
- * // SinglyLinkedList filter and map operations
1896
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
1897
- *
1898
- * // Filter even numbers
1899
- * const filtered = list.filter(value => value % 2 === 0);
1900
- * console.log(filtered.length); // 2;
1901
- *
1902
- * // Map to double values
1903
- * const doubled = list.map(value => value * 2);
1904
- * console.log(doubled.length); // 5;
1905
- *
1906
- * // Use reduce to sum
1907
- * const sum = list.reduce((acc, value) => acc + value, 0);
1908
- * console.log(sum); // 15;
1909
- */
1318
+ * Filter values into a new list of the same class.
1319
+ * @remarks Time O(N), Space O(N)
1320
+ * @param callback - Predicate (value, index, list) → boolean to keep value.
1321
+ * @param [thisArg] - Value for `this` inside the callback.
1322
+ * @returns A new list with kept values.
1323
+ * @example
1324
+ * // SinglyLinkedList filter and map operations
1325
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
1326
+ *
1327
+ * // Filter even numbers
1328
+ * const filtered = list.filter(value => value % 2 === 0);
1329
+ * console.log(filtered.length); // 2;
1330
+ *
1331
+ * // Map to double values
1332
+ * const doubled = list.map(value => value * 2);
1333
+ * console.log(doubled.length); // 5;
1334
+ *
1335
+ * // Use reduce to sum
1336
+ * const sum = list.reduce((acc, value) => acc + value, 0);
1337
+ * console.log(sum); // 15;
1338
+ */
1910
1339
  filter(callback, thisArg) {
1911
1340
  const out = this._createInstance();
1912
1341
  let index = 0;
@@ -1930,68 +1359,27 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1930
1359
  return out;
1931
1360
  }
1932
1361
  /**
1933
- * Map values into a new list (possibly different element type).
1934
- * @remarks Time O(N), Space O(N)
1935
- * @template EM
1936
- * @template RM
1937
- * @param callback - Mapping function (value, index, list) → newElement.
1938
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1939
- * @param [thisArg] - Value for `this` inside the callback.
1940
- * @returns A new SinglyLinkedList with mapped values.
1941
-
1942
-
1943
-
1944
-
1945
-
1946
-
1947
-
1948
-
1949
-
1950
-
1951
-
1952
-
1953
-
1954
-
1955
-
1956
-
1957
-
1958
-
1959
-
1960
-
1961
-
1962
-
1963
-
1964
-
1965
-
1966
-
1967
-
1968
-
1969
-
1970
-
1971
-
1972
-
1973
-
1974
-
1975
-
1976
-
1977
-
1978
-
1979
-
1980
-
1981
-
1982
-
1983
- * @example
1984
- * // Transform elements
1985
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1986
- * const doubled = list.map(n => n * 2);
1987
- * console.log([...doubled]); // [2, 4, 6];
1988
- */
1362
+ * Map values into a new list (possibly different element type).
1363
+ * @remarks Time O(N), Space O(N)
1364
+ * @template EM
1365
+ * @template RM
1366
+ * @param callback - Mapping function (value, index, list) → newElement.
1367
+ * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1368
+ * @param [thisArg] - Value for `this` inside the callback.
1369
+ * @returns A new SinglyLinkedList with mapped values.
1370
+ * @example
1371
+ * // Transform elements
1372
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1373
+ * const doubled = list.map(n => n * 2);
1374
+ * console.log([...doubled]); // [2, 4, 6];
1375
+ */
1989
1376
  map(callback, options, thisArg) {
1990
1377
  const out = this._createLike([], { ...options ?? {}, maxLen: this._maxLen });
1991
1378
  let index = 0;
1992
1379
  for (const value of this) out.push(callback.call(thisArg, value, index++, this));
1993
1380
  return out;
1994
1381
  }
1382
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
1995
1383
  /**
1996
1384
  * (Protected) Create a node from a value.
1997
1385
  * @remarks Time O(1), Space O(1)
@@ -2178,7 +1566,6 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2178
1566
  static {
2179
1567
  __name(this, "DoublyLinkedList");
2180
1568
  }
2181
- _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
2182
1569
  /**
2183
1570
  * Create a DoublyLinkedList and optionally bulk-insert elements.
2184
1571
  * @remarks Time O(N), Space O(N)
@@ -2261,68 +1648,26 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2261
1648
  return elementNodeOrPredicate instanceof DoublyLinkedListNode;
2262
1649
  }
2263
1650
  /**
2264
- * Append an element/node to the tail.
2265
- * @remarks Time O(1), Space O(1)
2266
- * @param elementOrNode - Element or node to append.
2267
- * @returns True when appended.
2268
-
2269
-
2270
-
2271
-
2272
-
2273
-
2274
-
2275
-
2276
-
2277
-
2278
-
2279
-
2280
-
2281
-
2282
-
2283
-
2284
-
2285
-
2286
-
2287
-
2288
-
2289
-
2290
-
2291
-
2292
-
2293
-
2294
-
2295
-
2296
-
2297
-
2298
-
2299
-
2300
-
2301
-
2302
-
2303
-
2304
-
2305
-
2306
-
2307
-
2308
-
2309
-
2310
- * @example
2311
- * // basic DoublyLinkedList creation and push operation
2312
- * // Create a simple DoublyLinkedList with initial values
2313
- * const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
2314
- *
2315
- * // Verify the list maintains insertion order
2316
- * console.log([...list]); // [1, 2, 3, 4, 5];
2317
- *
2318
- * // Check length
2319
- * console.log(list.length); // 5;
2320
- *
2321
- * // Push a new element to the end
2322
- * list.push(6);
2323
- * console.log(list.length); // 6;
2324
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
2325
- */
1651
+ * Append an element/node to the tail.
1652
+ * @remarks Time O(1), Space O(1)
1653
+ * @param elementOrNode - Element or node to append.
1654
+ * @returns True when appended.
1655
+ * @example
1656
+ * // basic DoublyLinkedList creation and push operation
1657
+ * // Create a simple DoublyLinkedList with initial values
1658
+ * const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
1659
+ *
1660
+ * // Verify the list maintains insertion order
1661
+ * console.log([...list]); // [1, 2, 3, 4, 5];
1662
+ *
1663
+ * // Check length
1664
+ * console.log(list.length); // 5;
1665
+ *
1666
+ * // Push a new element to the end
1667
+ * list.push(6);
1668
+ * console.log(list.length); // 6;
1669
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
1670
+ */
2326
1671
  push(elementOrNode) {
2327
1672
  const newNode = this._ensureNode(elementOrNode);
2328
1673
  if (!this.head) {
@@ -2338,67 +1683,25 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2338
1683
  return true;
2339
1684
  }
2340
1685
  /**
2341
- * Remove and return the tail element.
2342
- * @remarks Time O(1), Space O(1)
2343
- * @returns Removed element or undefined.
2344
-
2345
-
2346
-
2347
-
2348
-
2349
-
2350
-
2351
-
2352
-
2353
-
2354
-
2355
-
2356
-
2357
-
2358
-
2359
-
2360
-
2361
-
2362
-
2363
-
2364
-
2365
-
2366
-
2367
-
2368
-
2369
-
2370
-
2371
-
2372
-
2373
-
2374
-
2375
-
2376
-
2377
-
2378
-
2379
-
2380
-
2381
-
2382
-
2383
-
2384
-
2385
-
2386
- * @example
2387
- * // DoublyLinkedList pop and shift operations
2388
- * const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
2389
- *
2390
- * // Pop removes from the end
2391
- * const last = list.pop();
2392
- * console.log(last); // 50;
2393
- *
2394
- * // Shift removes from the beginning
2395
- * const first = list.shift();
2396
- * console.log(first); // 10;
2397
- *
2398
- * // Verify remaining elements
2399
- * console.log([...list]); // [20, 30, 40];
2400
- * console.log(list.length); // 3;
2401
- */
1686
+ * Remove and return the tail element.
1687
+ * @remarks Time O(1), Space O(1)
1688
+ * @returns Removed element or undefined.
1689
+ * @example
1690
+ * // DoublyLinkedList pop and shift operations
1691
+ * const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
1692
+ *
1693
+ * // Pop removes from the end
1694
+ * const last = list.pop();
1695
+ * console.log(last); // 50;
1696
+ *
1697
+ * // Shift removes from the beginning
1698
+ * const first = list.shift();
1699
+ * console.log(first); // 10;
1700
+ *
1701
+ * // Verify remaining elements
1702
+ * console.log([...list]); // [20, 30, 40];
1703
+ * console.log(list.length); // 3;
1704
+ */
2402
1705
  pop() {
2403
1706
  if (!this.tail) return void 0;
2404
1707
  const removed = this.tail;
@@ -2413,57 +1716,15 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2413
1716
  return removed.value;
2414
1717
  }
2415
1718
  /**
2416
- * Remove and return the head element.
2417
- * @remarks Time O(1), Space O(1)
2418
- * @returns Removed element or undefined.
2419
-
2420
-
2421
-
2422
-
2423
-
2424
-
2425
-
2426
-
2427
-
2428
-
2429
-
2430
-
2431
-
2432
-
2433
-
2434
-
2435
-
2436
-
2437
-
2438
-
2439
-
2440
-
2441
-
2442
-
2443
-
2444
-
2445
-
2446
-
2447
-
2448
-
2449
-
2450
-
2451
-
2452
-
2453
-
2454
-
2455
-
2456
-
2457
-
2458
-
2459
-
2460
-
2461
- * @example
2462
- * // Remove from the front
2463
- * const list = new DoublyLinkedList<number>([10, 20, 30]);
2464
- * console.log(list.shift()); // 10;
2465
- * console.log(list.first); // 20;
2466
- */
1719
+ * Remove and return the head element.
1720
+ * @remarks Time O(1), Space O(1)
1721
+ * @returns Removed element or undefined.
1722
+ * @example
1723
+ * // Remove from the front
1724
+ * const list = new DoublyLinkedList<number>([10, 20, 30]);
1725
+ * console.log(list.shift()); // 10;
1726
+ * console.log(list.first); // 20;
1727
+ */
2467
1728
  shift() {
2468
1729
  if (!this.head) return void 0;
2469
1730
  const removed = this.head;
@@ -2478,58 +1739,16 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2478
1739
  return removed.value;
2479
1740
  }
2480
1741
  /**
2481
- * Prepend an element/node to the head.
2482
- * @remarks Time O(1), Space O(1)
2483
- * @param elementOrNode - Element or node to prepend.
2484
- * @returns True when prepended.
2485
-
2486
-
2487
-
2488
-
2489
-
2490
-
2491
-
2492
-
2493
-
2494
-
2495
-
2496
-
2497
-
2498
-
2499
-
2500
-
2501
-
2502
-
2503
-
2504
-
2505
-
2506
-
2507
-
2508
-
2509
-
2510
-
2511
-
2512
-
2513
-
2514
-
2515
-
2516
-
2517
-
2518
-
2519
-
2520
-
2521
-
2522
-
2523
-
2524
-
2525
-
2526
-
2527
- * @example
2528
- * // Add to the front
2529
- * const list = new DoublyLinkedList<number>([2, 3]);
2530
- * list.unshift(1);
2531
- * console.log([...list]); // [1, 2, 3];
2532
- */
1742
+ * Prepend an element/node to the head.
1743
+ * @remarks Time O(1), Space O(1)
1744
+ * @param elementOrNode - Element or node to prepend.
1745
+ * @returns True when prepended.
1746
+ * @example
1747
+ * // Add to the front
1748
+ * const list = new DoublyLinkedList<number>([2, 3]);
1749
+ * list.unshift(1);
1750
+ * console.log([...list]); // [1, 2, 3];
1751
+ */
2533
1752
  unshift(elementOrNode) {
2534
1753
  const newNode = this._ensureNode(elementOrNode);
2535
1754
  if (!this.head) {
@@ -2573,58 +1792,16 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2573
1792
  return ans;
2574
1793
  }
2575
1794
  /**
2576
- * Get the element at a given index.
2577
- * @remarks Time O(N), Space O(1)
2578
- * @param index - Zero-based index.
2579
- * @returns Element or undefined.
2580
-
2581
-
2582
-
2583
-
2584
-
2585
-
2586
-
2587
-
2588
-
2589
-
2590
-
2591
-
2592
-
2593
-
2594
-
2595
-
2596
-
2597
-
2598
-
2599
-
2600
-
2601
-
2602
-
2603
-
2604
-
2605
-
2606
-
2607
-
2608
-
2609
-
2610
-
2611
-
2612
-
2613
-
2614
-
2615
-
2616
-
2617
-
2618
-
2619
-
2620
-
2621
-
2622
- * @example
2623
- * // Access by index
2624
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2625
- * console.log(list.at(1)); // 'b';
2626
- * console.log(list.at(2)); // 'c';
2627
- */
1795
+ * Get the element at a given index.
1796
+ * @remarks Time O(N), Space O(1)
1797
+ * @param index - Zero-based index.
1798
+ * @returns Element or undefined.
1799
+ * @example
1800
+ * // Access by index
1801
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1802
+ * console.log(list.at(1)); // 'b';
1803
+ * console.log(list.at(2)); // 'c';
1804
+ */
2628
1805
  at(index) {
2629
1806
  if (index < 0 || index >= this._length) return void 0;
2630
1807
  let current = this.head;
@@ -2632,54 +1809,15 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2632
1809
  return current?.value;
2633
1810
  }
2634
1811
  /**
2635
- * Get the node reference at a given index.
2636
- * @remarks Time O(N), Space O(1)
2637
- * @param index - Zero-based index.
2638
- * @returns Node or undefined.
2639
-
2640
-
2641
-
2642
-
2643
-
2644
-
2645
-
2646
-
2647
-
2648
-
2649
-
2650
-
2651
-
2652
-
2653
-
2654
-
2655
-
2656
-
2657
-
2658
-
2659
-
2660
-
2661
-
2662
-
2663
-
2664
-
2665
-
2666
-
2667
-
2668
-
2669
-
2670
-
2671
-
2672
-
2673
-
2674
-
2675
-
2676
-
2677
-
2678
- * @example
2679
- * // Get node at index
2680
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2681
- * console.log(list.getNodeAt(1)?.value); // 'b';
2682
- */
1812
+ * Get the node reference at a given index.
1813
+ * @remarks Time O(N), Space O(1)
1814
+ * @param index - Zero-based index.
1815
+ * @returns Node or undefined.
1816
+ * @example
1817
+ * // Get node at index
1818
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1819
+ * console.log(list.getNodeAt(1)?.value); // 'b';
1820
+ */
2683
1821
  getNodeAt(index) {
2684
1822
  if (index < 0 || index >= this._length) return void 0;
2685
1823
  let current = this.head;
@@ -2718,56 +1856,17 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2718
1856
  return void 0;
2719
1857
  }
2720
1858
  /**
2721
- * Insert a new element/node at an index, shifting following nodes.
2722
- * @remarks Time O(N), Space O(1)
2723
- * @param index - Zero-based index.
2724
- * @param newElementOrNode - Element or node to insert.
2725
- * @returns True if inserted.
2726
-
2727
-
2728
-
2729
-
2730
-
2731
-
2732
-
2733
-
2734
-
2735
-
2736
-
2737
-
2738
-
2739
-
2740
-
2741
-
2742
-
2743
-
2744
-
2745
-
2746
-
2747
-
2748
-
2749
-
2750
-
2751
-
2752
-
2753
-
2754
-
2755
-
2756
-
2757
-
2758
-
2759
-
2760
-
2761
-
2762
-
2763
-
2764
-
2765
- * @example
2766
- * // Insert at position
2767
- * const list = new DoublyLinkedList<number>([1, 3]);
2768
- * list.addAt(1, 2);
2769
- * console.log(list.toArray()); // [1, 2, 3];
2770
- */
1859
+ * Insert a new element/node at an index, shifting following nodes.
1860
+ * @remarks Time O(N), Space O(1)
1861
+ * @param index - Zero-based index.
1862
+ * @param newElementOrNode - Element or node to insert.
1863
+ * @returns True if inserted.
1864
+ * @example
1865
+ * // Insert at position
1866
+ * const list = new DoublyLinkedList<number>([1, 3]);
1867
+ * list.addAt(1, 2);
1868
+ * console.log(list.toArray()); // [1, 2, 3];
1869
+ */
2771
1870
  addAt(index, newElementOrNode) {
2772
1871
  if (index < 0 || index > this._length) return false;
2773
1872
  if (index === 0) return this.unshift(newElementOrNode);
@@ -2834,55 +1933,16 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2834
1933
  return true;
2835
1934
  }
2836
1935
  /**
2837
- * Delete the element at an index.
2838
- * @remarks Time O(N), Space O(1)
2839
- * @param index - Zero-based index.
2840
- * @returns Removed element or undefined.
2841
-
2842
-
2843
-
2844
-
2845
-
2846
-
2847
-
2848
-
2849
-
2850
-
2851
-
2852
-
2853
-
2854
-
2855
-
2856
-
2857
-
2858
-
2859
-
2860
-
2861
-
2862
-
2863
-
2864
-
2865
-
2866
-
2867
-
2868
-
2869
-
2870
-
2871
-
2872
-
2873
-
2874
-
2875
-
2876
-
2877
-
2878
-
2879
-
2880
- * @example
2881
- * // Remove by index
2882
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2883
- * list.deleteAt(1);
2884
- * console.log(list.toArray()); // ['a', 'c'];
2885
- */
1936
+ * Delete the element at an index.
1937
+ * @remarks Time O(N), Space O(1)
1938
+ * @param index - Zero-based index.
1939
+ * @returns Removed element or undefined.
1940
+ * @example
1941
+ * // Remove by index
1942
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1943
+ * list.deleteAt(1);
1944
+ * console.log(list.toArray()); // ['a', 'c'];
1945
+ */
2886
1946
  deleteAt(index) {
2887
1947
  if (index < 0 || index >= this._length) return;
2888
1948
  if (index === 0) return this.shift();
@@ -2896,55 +1956,16 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2896
1956
  return removedNode.value;
2897
1957
  }
2898
1958
  /**
2899
- * Delete the first match by value/node.
2900
- * @remarks Time O(N), Space O(1)
2901
- * @param [elementOrNode] - Element or node to remove.
2902
- * @returns True if removed.
2903
-
2904
-
2905
-
2906
-
2907
-
2908
-
2909
-
2910
-
2911
-
2912
-
2913
-
2914
-
2915
-
2916
-
2917
-
2918
-
2919
-
2920
-
2921
-
2922
-
2923
-
2924
-
2925
-
2926
-
2927
-
2928
-
2929
-
2930
-
2931
-
2932
-
2933
-
2934
-
2935
-
2936
-
2937
-
2938
-
2939
-
2940
-
2941
-
2942
- * @example
2943
- * // Remove first occurrence
2944
- * const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
2945
- * list.delete(2);
2946
- * console.log(list.toArray()); // [1, 3, 2];
2947
- */
1959
+ * Delete the first match by value/node.
1960
+ * @remarks Time O(N), Space O(1)
1961
+ * @param [elementOrNode] - Element or node to remove.
1962
+ * @returns True if removed.
1963
+ * @example
1964
+ * // Remove first occurrence
1965
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
1966
+ * list.delete(2);
1967
+ * console.log(list.toArray()); // [1, 3, 2];
1968
+ */
2948
1969
  delete(elementOrNode) {
2949
1970
  const node = this.getNode(elementOrNode);
2950
1971
  if (!node) return false;
@@ -2960,161 +1981,42 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2960
1981
  return true;
2961
1982
  }
2962
1983
  /**
2963
- * Check whether the list is empty.
2964
- * @remarks Time O(1), Space O(1)
2965
- * @returns True if length is 0.
2966
-
2967
-
2968
-
2969
-
2970
-
2971
-
2972
-
2973
-
2974
-
2975
-
2976
-
2977
-
2978
-
2979
-
2980
-
2981
-
2982
-
2983
-
2984
-
2985
-
2986
-
2987
-
2988
-
2989
-
2990
-
2991
-
2992
-
2993
-
2994
-
2995
-
2996
-
2997
-
2998
-
2999
-
3000
-
3001
-
3002
-
3003
-
3004
-
3005
-
3006
- * @example
3007
- * // Check empty
3008
- * console.log(new DoublyLinkedList().isEmpty()); // true;
3009
- */
1984
+ * Check whether the list is empty.
1985
+ * @remarks Time O(1), Space O(1)
1986
+ * @returns True if length is 0.
1987
+ * @example
1988
+ * // Check empty
1989
+ * console.log(new DoublyLinkedList().isEmpty()); // true;
1990
+ */
3010
1991
  isEmpty() {
3011
1992
  return this._length === 0;
3012
1993
  }
3013
1994
  /**
3014
- * Remove all nodes and reset length.
3015
- * @remarks Time O(N), Space O(1)
3016
- * @returns void
3017
-
3018
-
3019
-
3020
-
3021
-
3022
-
3023
-
3024
-
3025
-
3026
-
3027
-
3028
-
3029
-
3030
-
3031
-
3032
-
3033
-
3034
-
3035
-
3036
-
3037
-
3038
-
3039
-
3040
-
3041
-
3042
-
3043
-
3044
-
3045
-
3046
-
3047
-
3048
-
3049
-
3050
-
3051
-
3052
-
3053
-
3054
-
3055
-
3056
-
3057
- * @example
3058
- * // Remove all
3059
- * const list = new DoublyLinkedList<number>([1, 2]);
3060
- * list.clear();
3061
- * console.log(list.isEmpty()); // true;
3062
- */
1995
+ * Remove all nodes and reset length.
1996
+ * @remarks Time O(N), Space O(1)
1997
+ * @returns void
1998
+ * @example
1999
+ * // Remove all
2000
+ * const list = new DoublyLinkedList<number>([1, 2]);
2001
+ * list.clear();
2002
+ * console.log(list.isEmpty()); // true;
2003
+ */
3063
2004
  clear() {
3064
2005
  this._head = void 0;
3065
2006
  this._tail = void 0;
3066
2007
  this._length = 0;
3067
2008
  }
3068
2009
  /**
3069
- * Find the first value matching a predicate scanning forward.
3070
- * @remarks Time O(N), Space O(1)
3071
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3072
- * @returns Matched value or undefined.
3073
-
3074
-
3075
-
3076
-
3077
-
3078
-
3079
-
3080
-
3081
-
3082
-
3083
-
3084
-
3085
-
3086
-
3087
-
3088
-
3089
-
3090
-
3091
-
3092
-
3093
-
3094
-
3095
-
3096
-
3097
-
3098
-
3099
-
3100
-
3101
-
3102
-
3103
-
3104
-
3105
-
3106
-
3107
-
3108
-
3109
-
3110
-
3111
-
3112
- * @example
3113
- * // Search with predicate
3114
- * const list = new DoublyLinkedList<number>([10, 20, 30]);
3115
- * const found = list.search(node => node.value > 15);
3116
- * console.log(found); // 20;
3117
- */
2010
+ * Find the first value matching a predicate scanning forward.
2011
+ * @remarks Time O(N), Space O(1)
2012
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2013
+ * @returns Matched value or undefined.
2014
+ * @example
2015
+ * // Search with predicate
2016
+ * const list = new DoublyLinkedList<number>([10, 20, 30]);
2017
+ * const found = list.search(node => node.value > 15);
2018
+ * console.log(found); // 20;
2019
+ */
3118
2020
  search(elementNodeOrPredicate) {
3119
2021
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
3120
2022
  let current = this.head;
@@ -3125,53 +2027,17 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3125
2027
  return void 0;
3126
2028
  }
3127
2029
  /**
3128
- * Find the first value matching a predicate scanning backward.
3129
- * @remarks Time O(N), Space O(1)
3130
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3131
- * @returns Matched value or undefined.
3132
-
3133
-
3134
-
3135
-
3136
-
3137
-
3138
-
3139
-
3140
-
3141
-
3142
-
3143
-
3144
-
3145
-
3146
-
3147
-
3148
-
3149
-
3150
-
3151
-
3152
-
3153
-
3154
-
3155
-
3156
-
3157
-
3158
-
3159
-
3160
-
3161
-
3162
-
3163
-
3164
-
3165
-
3166
-
3167
-
3168
- * @example
3169
- * // Find value scanning from tail
3170
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3171
- * // findLast scans from tail to head, returns first match
3172
- * const found = list.findLast(node => node.value < 4);
3173
- * console.log(found); // 3;
3174
- */
2030
+ * Find the first value matching a predicate scanning backward.
2031
+ * @remarks Time O(N), Space O(1)
2032
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2033
+ * @returns Matched value or undefined.
2034
+ * @example
2035
+ * // Find value scanning from tail
2036
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2037
+ * // findLast scans from tail to head, returns first match
2038
+ * const found = list.findLast(node => node.value < 4);
2039
+ * console.log(found); // 3;
2040
+ */
3175
2041
  /**
3176
2042
  * @deprecated Use `findLast` instead. Will be removed in a future major version.
3177
2043
  */
@@ -3179,19 +2045,17 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3179
2045
  return this.findLast(elementNodeOrPredicate);
3180
2046
  }
3181
2047
  /**
3182
- * Find the first value matching a predicate scanning backward (tail → head).
3183
- * @remarks Time O(N), Space O(1)
3184
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3185
- * @returns Matching value or undefined.
3186
-
3187
-
3188
- * @example
3189
- * // Find value scanning from tail
3190
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3191
- * // findLast scans from tail to head, returns first match
3192
- * const found = list.findLast(node => node.value < 4);
3193
- * console.log(found); // 3;
3194
- */
2048
+ * Find the first value matching a predicate scanning backward (tail → head).
2049
+ * @remarks Time O(N), Space O(1)
2050
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2051
+ * @returns Matching value or undefined.
2052
+ * @example
2053
+ * // Find value scanning from tail
2054
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2055
+ * // findLast scans from tail to head, returns first match
2056
+ * const found = list.findLast(node => node.value < 4);
2057
+ * console.log(found); // 3;
2058
+ */
3195
2059
  findLast(elementNodeOrPredicate) {
3196
2060
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
3197
2061
  let current = this.tail;
@@ -3218,57 +2082,15 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3218
2082
  return -1;
3219
2083
  }
3220
2084
  /**
3221
- * Reverse the list in place.
3222
- * @remarks Time O(N), Space O(1)
3223
- * @returns This list.
3224
-
3225
-
3226
-
3227
-
3228
-
3229
-
3230
-
3231
-
3232
-
3233
-
3234
-
3235
-
3236
-
3237
-
3238
-
3239
-
3240
-
3241
-
3242
-
3243
-
3244
-
3245
-
3246
-
3247
-
3248
-
3249
-
3250
-
3251
-
3252
-
3253
-
3254
-
3255
-
3256
-
3257
-
3258
-
3259
-
3260
-
3261
-
3262
-
3263
-
3264
-
3265
-
3266
- * @example
3267
- * // Reverse in-place
3268
- * const list = new DoublyLinkedList<number>([1, 2, 3]);
3269
- * list.reverse();
3270
- * console.log([...list]); // [3, 2, 1];
3271
- */
2085
+ * Reverse the list in place.
2086
+ * @remarks Time O(N), Space O(1)
2087
+ * @returns This list.
2088
+ * @example
2089
+ * // Reverse in-place
2090
+ * const list = new DoublyLinkedList<number>([1, 2, 3]);
2091
+ * list.reverse();
2092
+ * console.log([...list]); // [3, 2, 1];
2093
+ */
3272
2094
  reverse() {
3273
2095
  let current = this.head;
3274
2096
  [this._head, this._tail] = [this.tail, this.head];
@@ -3309,115 +2131,33 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3309
2131
  return this;
3310
2132
  }
3311
2133
  /**
3312
- * Deep clone this list (values are copied by reference).
3313
- * @remarks Time O(N), Space O(N)
3314
- * @returns A new list with the same element sequence.
3315
-
3316
-
3317
-
3318
-
3319
-
3320
-
3321
-
3322
-
3323
-
3324
-
3325
-
3326
-
3327
-
3328
-
3329
-
3330
-
3331
-
3332
-
3333
-
3334
-
3335
-
3336
-
3337
-
3338
-
3339
-
3340
-
3341
-
3342
-
3343
-
3344
-
3345
-
3346
-
3347
-
3348
-
3349
-
3350
-
3351
-
3352
-
3353
-
3354
-
3355
- * @example
3356
- * // Deep copy
3357
- * const list = new DoublyLinkedList<number>([1, 2, 3]);
3358
- * const copy = list.clone();
3359
- * copy.pop();
3360
- * console.log(list.length); // 3;
3361
- */
2134
+ * Deep clone this list (values are copied by reference).
2135
+ * @remarks Time O(N), Space O(N)
2136
+ * @returns A new list with the same element sequence.
2137
+ * @example
2138
+ * // Deep copy
2139
+ * const list = new DoublyLinkedList<number>([1, 2, 3]);
2140
+ * const copy = list.clone();
2141
+ * copy.pop();
2142
+ * console.log(list.length); // 3;
2143
+ */
3362
2144
  clone() {
3363
2145
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
3364
2146
  for (const v of this) out.push(v);
3365
2147
  return out;
3366
2148
  }
3367
2149
  /**
3368
- * Filter values into a new list of the same class.
3369
- * @remarks Time O(N), Space O(N)
3370
- * @param callback - Predicate (value, index, list) → boolean to keep value.
3371
- * @param [thisArg] - Value for `this` inside the callback.
3372
- * @returns A new list with kept values.
3373
-
3374
-
3375
-
3376
-
3377
-
3378
-
3379
-
3380
-
3381
-
3382
-
3383
-
3384
-
3385
-
3386
-
3387
-
3388
-
3389
-
3390
-
3391
-
3392
-
3393
-
3394
-
3395
-
3396
-
3397
-
3398
-
3399
-
3400
-
3401
-
3402
-
3403
-
3404
-
3405
-
3406
-
3407
-
3408
-
3409
-
3410
-
3411
-
3412
-
3413
-
3414
-
3415
- * @example
3416
- * // Filter elements
3417
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
3418
- * const evens = list.filter(n => n % 2 === 0);
3419
- * console.log([...evens]); // [2, 4];
3420
- */
2150
+ * Filter values into a new list of the same class.
2151
+ * @remarks Time O(N), Space O(N)
2152
+ * @param callback - Predicate (value, index, list) → boolean to keep value.
2153
+ * @param [thisArg] - Value for `this` inside the callback.
2154
+ * @returns A new list with kept values.
2155
+ * @example
2156
+ * // Filter elements
2157
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
2158
+ * const evens = list.filter(n => n % 2 === 0);
2159
+ * console.log([...evens]); // [2, 4];
2160
+ */
3421
2161
  filter(callback, thisArg) {
3422
2162
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
3423
2163
  let index = 0;
@@ -3441,77 +2181,36 @@ var DoublyLinkedList = class extends LinearLinkedBase {
3441
2181
  return out;
3442
2182
  }
3443
2183
  /**
3444
- * Map values into a new list (possibly different element type).
3445
- * @remarks Time O(N), Space O(N)
3446
- * @template EM
3447
- * @template RM
3448
- * @param callback - Mapping function (value, index, list) → newElement.
3449
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
3450
- * @param [thisArg] - Value for `this` inside the callback.
3451
- * @returns A new DoublyLinkedList with mapped values.
3452
-
3453
-
3454
-
3455
-
3456
-
3457
-
3458
-
3459
-
3460
-
3461
-
3462
-
3463
-
3464
-
3465
-
3466
-
3467
-
3468
-
3469
-
3470
-
3471
-
3472
-
3473
-
3474
-
3475
-
3476
-
3477
-
3478
-
3479
-
3480
-
3481
-
3482
-
3483
-
3484
-
3485
-
3486
-
3487
-
3488
-
3489
-
3490
-
3491
-
3492
-
3493
-
3494
- * @example
3495
- * // DoublyLinkedList for...of iteration and map operation
3496
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
3497
- *
3498
- * // Iterate through list
3499
- * const doubled = list.map(value => value * 2);
3500
- * console.log(doubled.length); // 5;
3501
- *
3502
- * // Use for...of loop
3503
- * const result: number[] = [];
3504
- * for (const item of list) {
3505
- * result.push(item);
3506
- * }
3507
- * console.log(result); // [1, 2, 3, 4, 5];
3508
- */
2184
+ * Map values into a new list (possibly different element type).
2185
+ * @remarks Time O(N), Space O(N)
2186
+ * @template EM
2187
+ * @template RM
2188
+ * @param callback - Mapping function (value, index, list) → newElement.
2189
+ * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
2190
+ * @param [thisArg] - Value for `this` inside the callback.
2191
+ * @returns A new DoublyLinkedList with mapped values.
2192
+ * @example
2193
+ * // DoublyLinkedList for...of iteration and map operation
2194
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
2195
+ *
2196
+ * // Iterate through list
2197
+ * const doubled = list.map(value => value * 2);
2198
+ * console.log(doubled.length); // 5;
2199
+ *
2200
+ * // Use for...of loop
2201
+ * const result: number[] = [];
2202
+ * for (const item of list) {
2203
+ * result.push(item);
2204
+ * }
2205
+ * console.log(result); // [1, 2, 3, 4, 5];
2206
+ */
3509
2207
  map(callback, options, thisArg) {
3510
2208
  const out = this._createLike([], { ...options ?? {}, maxLen: this._maxLen });
3511
2209
  let index = 0;
3512
2210
  for (const v of this) out.push(callback.call(thisArg, v, index++, this));
3513
2211
  return out;
3514
2212
  }
2213
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
3515
2214
  /**
3516
2215
  * (Protected) Create or return a node for the given input (node or raw element).
3517
2216
  * @remarks Time O(1), Space O(1)
@@ -3794,6 +2493,9 @@ var SkipList = class _SkipList extends IterableEntryBase {
3794
2493
  static {
3795
2494
  __name(this, "SkipList");
3796
2495
  }
2496
+ // ─── Internal state ──────────────────────────────────────────
2497
+ _head;
2498
+ _level = 0;
3797
2499
  #comparator;
3798
2500
  #isDefaultComparator;
3799
2501
  constructor(entries = [], options = {}) {
@@ -3818,6 +2520,22 @@ var SkipList = class _SkipList extends IterableEntryBase {
3818
2520
  this.set(k, v);
3819
2521
  }
3820
2522
  }
2523
+ _size = 0;
2524
+ // ─── Size & lifecycle ────────────────────────────────────────
2525
+ get size() {
2526
+ return this._size;
2527
+ }
2528
+ _maxLevel = 16;
2529
+ get maxLevel() {
2530
+ return this._maxLevel;
2531
+ }
2532
+ _probability = 0.5;
2533
+ get probability() {
2534
+ return this._probability;
2535
+ }
2536
+ get comparator() {
2537
+ return this.#comparator;
2538
+ }
3821
2539
  /**
3822
2540
  * Creates a default comparator supporting number, string, Date, and bigint.
3823
2541
  */
@@ -3841,174 +2559,44 @@ var SkipList = class _SkipList extends IterableEntryBase {
3841
2559
  raise(TypeError, ERR.comparatorRequired("SkipList"));
3842
2560
  };
3843
2561
  }
3844
- // ─── Internal state ──────────────────────────────────────────
3845
- _head;
3846
- _level = 0;
3847
- _size = 0;
3848
- _maxLevel = 16;
3849
- _probability = 0.5;
3850
- // ─── Size & lifecycle ────────────────────────────────────────
3851
- get size() {
3852
- return this._size;
3853
- }
3854
- get maxLevel() {
3855
- return this._maxLevel;
3856
- }
3857
- get probability() {
3858
- return this._probability;
3859
- }
3860
- get comparator() {
3861
- return this.#comparator;
3862
- }
3863
2562
  /**
3864
- * Check if empty
3865
-
3866
-
3867
-
3868
-
3869
-
3870
-
3871
-
3872
-
3873
-
3874
-
3875
-
3876
-
3877
-
3878
-
3879
-
3880
-
3881
-
3882
-
3883
-
3884
-
3885
-
3886
-
3887
-
3888
-
3889
-
3890
-
3891
-
3892
-
3893
-
3894
-
3895
-
3896
-
3897
-
3898
-
3899
-
3900
-
3901
-
3902
-
3903
-
3904
- * @example
3905
- * // Check if empty
3906
- * const sl = new SkipList<number, string>();
3907
- * console.log(sl.isEmpty()); // true;
3908
- */
2563
+ * Check if empty
2564
+ * @example
2565
+ * // Check if empty
2566
+ * const sl = new SkipList<number, string>();
2567
+ * console.log(sl.isEmpty()); // true;
2568
+ */
3909
2569
  isEmpty() {
3910
2570
  return this._size === 0;
3911
2571
  }
3912
2572
  /**
3913
- * Remove all entries
3914
-
3915
-
3916
-
3917
-
3918
-
3919
-
3920
-
3921
-
3922
-
3923
-
3924
-
3925
-
3926
-
3927
-
3928
-
3929
-
3930
-
3931
-
3932
-
3933
-
3934
-
3935
-
3936
-
3937
-
3938
-
3939
-
3940
-
3941
-
3942
-
3943
-
3944
-
3945
-
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
- * @example
3954
- * // Remove all entries
3955
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
3956
- * sl.clear();
3957
- * console.log(sl.isEmpty()); // true;
3958
- */
2573
+ * Remove all entries
2574
+ * @example
2575
+ * // Remove all entries
2576
+ * const sl = new SkipList<number, string>([
2577
+ * [1, 'a'],
2578
+ * [2, 'b']
2579
+ * ]);
2580
+ * sl.clear();
2581
+ * console.log(sl.isEmpty()); // true;
2582
+ */
3959
2583
  clear() {
3960
2584
  this._head = new SkipListNode(void 0, void 0, this._maxLevel);
3961
2585
  this._level = 0;
3962
2586
  this._size = 0;
3963
2587
  }
3964
2588
  /**
3965
- * Create independent copy
3966
-
3967
-
3968
-
3969
-
3970
-
3971
-
3972
-
3973
-
3974
-
3975
-
3976
-
3977
-
3978
-
3979
-
3980
-
3981
-
3982
-
3983
-
3984
-
3985
-
3986
-
3987
-
3988
-
3989
-
3990
-
3991
-
3992
-
3993
-
3994
-
3995
-
3996
-
3997
-
3998
-
3999
-
4000
-
4001
-
4002
-
4003
-
4004
-
4005
- * @example
4006
- * // Create independent copy
4007
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
4008
- * const copy = sl.clone();
4009
- * copy.delete(1);
4010
- * console.log(sl.has(1)); // true;
4011
- */
2589
+ * Create independent copy
2590
+ * @example
2591
+ * // Create independent copy
2592
+ * const sl = new SkipList<number, string>([
2593
+ * [1, 'a'],
2594
+ * [2, 'b']
2595
+ * ]);
2596
+ * const copy = sl.clone();
2597
+ * copy.delete(1);
2598
+ * console.log(sl.has(1)); // true;
2599
+ */
4012
2600
  clone() {
4013
2601
  return new _SkipList(this, {
4014
2602
  comparator: this.#isDefaultComparator ? void 0 : this.#comparator,
@@ -4018,67 +2606,25 @@ var SkipList = class _SkipList extends IterableEntryBase {
4018
2606
  }
4019
2607
  // ─── Core CRUD ───────────────────────────────────────────────
4020
2608
  /**
4021
- * Insert or update a key-value pair. Returns `this` for chaining.
4022
- * Unique keys only — if key exists, value is updated in place.
4023
-
4024
-
4025
-
4026
-
4027
-
4028
-
4029
-
4030
-
4031
-
4032
-
4033
-
4034
-
4035
-
4036
-
4037
-
4038
-
4039
-
4040
-
4041
-
4042
-
4043
-
4044
-
4045
-
4046
-
4047
-
4048
-
4049
-
4050
-
4051
-
4052
-
4053
-
4054
-
4055
-
4056
-
4057
-
4058
-
4059
-
4060
-
4061
-
4062
-
4063
-
4064
-
4065
- * @example
4066
- * // In-memory sorted key-value store
4067
- * const store = new SkipList<number, string>();
4068
- *
4069
- * store.set(3, 'three');
4070
- * store.set(1, 'one');
4071
- * store.set(5, 'five');
4072
- * store.set(2, 'two');
4073
- *
4074
- * console.log(store.get(3)); // 'three';
4075
- * console.log(store.get(1)); // 'one';
4076
- * console.log(store.get(5)); // 'five';
4077
- *
4078
- * // Update existing key
4079
- * store.set(3, 'THREE');
4080
- * console.log(store.get(3)); // 'THREE';
4081
- */
2609
+ * Insert or update a key-value pair. Returns `this` for chaining.
2610
+ * Unique keys only — if key exists, value is updated in place.
2611
+ * @example
2612
+ * // In-memory sorted key-value store
2613
+ * const store = new SkipList<number, string>();
2614
+ *
2615
+ * store.set(3, 'three');
2616
+ * store.set(1, 'one');
2617
+ * store.set(5, 'five');
2618
+ * store.set(2, 'two');
2619
+ *
2620
+ * console.log(store.get(3)); // 'three';
2621
+ * console.log(store.get(1)); // 'one';
2622
+ * console.log(store.get(5)); // 'five';
2623
+ *
2624
+ * // Update existing key
2625
+ * store.set(3, 'THREE');
2626
+ * console.log(store.get(3)); // 'THREE';
2627
+ */
4082
2628
  set(key, value) {
4083
2629
  const cmp = this.#comparator;
4084
2630
  const update = this._findUpdate(key);
@@ -4103,186 +2649,64 @@ var SkipList = class _SkipList extends IterableEntryBase {
4103
2649
  return this;
4104
2650
  }
4105
2651
  /**
4106
- * Get the value for a key, or `undefined` if not found.
4107
- * Overrides base O(n) with O(log n) skip-list search.
4108
-
4109
-
4110
-
4111
-
4112
-
4113
-
4114
-
4115
-
4116
-
4117
-
4118
-
4119
-
4120
-
4121
-
4122
-
4123
-
4124
-
4125
-
4126
-
4127
-
4128
-
4129
-
4130
-
4131
-
4132
-
4133
-
4134
-
4135
-
4136
-
4137
-
4138
-
4139
-
4140
-
4141
-
4142
-
4143
-
4144
-
4145
-
4146
-
4147
-
4148
-
4149
-
4150
- * @example
4151
- * // Building a sorted index
4152
- * type Product = { id: number; name: string; price: number };
4153
- * const products: Product[] = [
4154
- * { id: 1, name: 'Widget', price: 25 },
4155
- * { id: 2, name: 'Gadget', price: 50 },
4156
- * { id: 3, name: 'Doohickey', price: 15 }
4157
- * ];
4158
- *
4159
- * const index = new SkipList<number, Product, Product>(products, {
4160
- * toEntryFn: (p: Product) => [p.price, p]
4161
- * });
4162
- *
4163
- * // Iterate in sorted order by price
4164
- * const names = [...index.values()].map(p => p!.name);
4165
- * console.log(names); // ['Doohickey', 'Widget', 'Gadget'];
4166
- *
4167
- * // Range search: products between $20 and $60
4168
- * const range = index.rangeSearch([20, 60]);
4169
- * console.log(range.map(([, p]) => p!.name)); // ['Widget', 'Gadget'];
4170
- */
2652
+ * Get the value for a key, or `undefined` if not found.
2653
+ * Overrides base O(n) with O(log n) skip-list search.
2654
+ * @example
2655
+ * // Building a sorted index
2656
+ * type Product = { id: number; name: string; price: number };
2657
+ * const products: Product[] = [
2658
+ * { id: 1, name: 'Widget', price: 25 },
2659
+ * { id: 2, name: 'Gadget', price: 50 },
2660
+ * { id: 3, name: 'Doohickey', price: 15 }
2661
+ * ];
2662
+ *
2663
+ * const index = new SkipList<number, Product, Product>(products, {
2664
+ * toEntryFn: (p: Product) => [p.price, p]
2665
+ * });
2666
+ *
2667
+ * // Iterate in sorted order by price
2668
+ * const names = [...index.values()].map(p => p!.name);
2669
+ * console.log(names); // ['Doohickey', 'Widget', 'Gadget'];
2670
+ *
2671
+ * // Range search: products between $20 and $60
2672
+ * const range = index.rangeSearch([20, 60]);
2673
+ * console.log(range.map(([, p]) => p!.name)); // ['Widget', 'Gadget'];
2674
+ */
4171
2675
  get(key) {
4172
2676
  const node = this._findNode(key);
4173
2677
  return node ? node.value : void 0;
4174
2678
  }
4175
2679
  /**
4176
- * Check if a key exists.
4177
- * Overrides base O(n) with O(log n) skip-list search.
4178
-
4179
-
4180
-
4181
-
4182
-
4183
-
4184
-
4185
-
4186
-
4187
-
4188
-
4189
-
4190
-
4191
-
4192
-
4193
-
4194
-
4195
-
4196
-
4197
-
4198
-
4199
-
4200
-
4201
-
4202
-
4203
-
4204
-
4205
-
4206
-
4207
-
4208
-
4209
-
4210
-
4211
-
4212
-
4213
-
4214
-
4215
-
4216
-
4217
-
4218
-
4219
-
4220
- * @example
4221
- * // Check key existence
4222
- * const sl = new SkipList<number, string>([[1, 'a'], [3, 'c'], [5, 'e']]);
4223
- * console.log(sl.has(3)); // true;
4224
- * console.log(sl.has(4)); // false;
4225
- */
2680
+ * Check if a key exists.
2681
+ * Overrides base O(n) with O(log n) skip-list search.
2682
+ * @example
2683
+ * // Check key existence
2684
+ * const sl = new SkipList<number, string>([
2685
+ * [1, 'a'],
2686
+ * [3, 'c'],
2687
+ * [5, 'e']
2688
+ * ]);
2689
+ * console.log(sl.has(3)); // true;
2690
+ * console.log(sl.has(4)); // false;
2691
+ */
4226
2692
  has(key) {
4227
2693
  return this._findNode(key) !== void 0;
4228
2694
  }
4229
2695
  /**
4230
- * Delete a key. Returns `true` if the key was found and removed.
4231
-
4232
-
4233
-
4234
-
4235
-
4236
-
4237
-
4238
-
4239
-
4240
-
4241
-
4242
-
4243
-
4244
-
4245
-
4246
-
4247
-
4248
-
4249
-
4250
-
4251
-
4252
-
4253
-
4254
-
4255
-
4256
-
4257
-
4258
-
4259
-
4260
-
4261
-
4262
-
4263
-
4264
-
4265
-
4266
-
4267
-
4268
-
4269
-
4270
-
4271
-
4272
-
4273
- * @example
4274
- * // Fast lookup with deletion
4275
- * const cache = new SkipList<string, number>();
4276
- *
4277
- * cache.set('alpha', 1);
4278
- * cache.set('beta', 2);
4279
- * cache.set('gamma', 3);
4280
- *
4281
- * console.log(cache.has('beta')); // true;
4282
- * cache.delete('beta');
4283
- * console.log(cache.has('beta')); // false;
4284
- * console.log(cache.size); // 2;
4285
- */
2696
+ * Delete a key. Returns `true` if the key was found and removed.
2697
+ * @example
2698
+ * // Fast lookup with deletion
2699
+ * const cache = new SkipList<string, number>();
2700
+ *
2701
+ * cache.set('alpha', 1);
2702
+ * cache.set('beta', 2);
2703
+ * cache.set('gamma', 3);
2704
+ *
2705
+ * console.log(cache.has('beta')); // true;
2706
+ * cache.delete('beta');
2707
+ * console.log(cache.has('beta')); // false;
2708
+ * console.log(cache.size); // 2;
2709
+ */
4286
2710
  delete(key) {
4287
2711
  const cmp = this.#comparator;
4288
2712
  const update = this._findUpdate(key);
@@ -4300,107 +2724,31 @@ var SkipList = class _SkipList extends IterableEntryBase {
4300
2724
  }
4301
2725
  // ─── Navigation ──────────────────────────────────────────────
4302
2726
  /**
4303
- * Returns the first (smallest key) entry, or `undefined` if empty.
4304
-
4305
-
4306
-
4307
-
4308
-
4309
-
4310
-
4311
-
4312
-
4313
-
4314
-
4315
-
4316
-
4317
-
4318
-
4319
-
4320
-
4321
-
4322
-
4323
-
4324
-
4325
-
4326
-
4327
-
4328
-
4329
-
4330
-
4331
-
4332
-
4333
-
4334
-
4335
-
4336
-
4337
-
4338
-
4339
-
4340
-
4341
-
4342
-
4343
-
4344
-
4345
-
4346
- * @example
4347
- * // Access the minimum entry
4348
- * const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
4349
- * console.log(sl.first()); // [1, 'a'];
4350
- */
2727
+ * Returns the first (smallest key) entry, or `undefined` if empty.
2728
+ * @example
2729
+ * // Access the minimum entry
2730
+ * const sl = new SkipList<number, string>([
2731
+ * [5, 'e'],
2732
+ * [1, 'a'],
2733
+ * [3, 'c']
2734
+ * ]);
2735
+ * console.log(sl.first()); // [1, 'a'];
2736
+ */
4351
2737
  first() {
4352
2738
  const node = this._head.forward[0];
4353
2739
  return node ? [node.key, node.value] : void 0;
4354
2740
  }
4355
2741
  /**
4356
- * Returns the last (largest key) entry, or `undefined` if empty.
4357
-
4358
-
4359
-
4360
-
4361
-
4362
-
4363
-
4364
-
4365
-
4366
-
4367
-
4368
-
4369
-
4370
-
4371
-
4372
-
4373
-
4374
-
4375
-
4376
-
4377
-
4378
-
4379
-
4380
-
4381
-
4382
-
4383
-
4384
-
4385
-
4386
-
4387
-
4388
-
4389
-
4390
-
4391
-
4392
-
4393
-
4394
-
4395
-
4396
-
4397
-
4398
-
4399
- * @example
4400
- * // Access the maximum entry
4401
- * const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
4402
- * console.log(sl.last()); // [5, 'e'];
4403
- */
2742
+ * Returns the last (largest key) entry, or `undefined` if empty.
2743
+ * @example
2744
+ * // Access the maximum entry
2745
+ * const sl = new SkipList<number, string>([
2746
+ * [5, 'e'],
2747
+ * [1, 'a'],
2748
+ * [3, 'c']
2749
+ * ]);
2750
+ * console.log(sl.last()); // [5, 'e'];
2751
+ */
4404
2752
  last() {
4405
2753
  let current = this._head;
4406
2754
  for (let i = this._level - 1; i >= 0; i--) {
@@ -4411,52 +2759,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4411
2759
  return current === this._head ? void 0 : [current.key, current.value];
4412
2760
  }
4413
2761
  /**
4414
- * Remove and return the first (smallest key) entry.
4415
-
4416
-
4417
-
4418
-
4419
-
4420
-
4421
-
4422
-
4423
-
4424
-
4425
-
4426
-
4427
-
4428
-
4429
-
4430
-
4431
-
4432
-
4433
-
4434
-
4435
-
4436
-
4437
-
4438
-
4439
-
4440
-
4441
-
4442
-
4443
-
4444
-
4445
-
4446
-
4447
-
4448
-
4449
-
4450
-
4451
-
4452
-
4453
-
4454
- * @example
4455
- * // Remove and return smallest
4456
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
4457
- * console.log(sl.pollFirst()); // [1, 'a'];
4458
- * console.log(sl.size); // 2;
4459
- */
2762
+ * Remove and return the first (smallest key) entry.
2763
+ * @example
2764
+ * // Remove and return smallest
2765
+ * const sl = new SkipList<number, string>([
2766
+ * [1, 'a'],
2767
+ * [2, 'b'],
2768
+ * [3, 'c']
2769
+ * ]);
2770
+ * console.log(sl.pollFirst()); // [1, 'a'];
2771
+ * console.log(sl.size); // 2;
2772
+ */
4460
2773
  pollFirst() {
4461
2774
  const entry = this.first();
4462
2775
  if (!entry) return void 0;
@@ -4464,52 +2777,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4464
2777
  return entry;
4465
2778
  }
4466
2779
  /**
4467
- * Remove and return the last (largest key) entry.
4468
-
4469
-
4470
-
4471
-
4472
-
4473
-
4474
-
4475
-
4476
-
4477
-
4478
-
4479
-
4480
-
4481
-
4482
-
4483
-
4484
-
4485
-
4486
-
4487
-
4488
-
4489
-
4490
-
4491
-
4492
-
4493
-
4494
-
4495
-
4496
-
4497
-
4498
-
4499
-
4500
-
4501
-
4502
-
4503
-
4504
-
4505
-
4506
-
4507
- * @example
4508
- * // Remove and return largest
4509
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
4510
- * console.log(sl.pollLast()); // [3, 'c'];
4511
- * console.log(sl.size); // 2;
4512
- */
2780
+ * Remove and return the last (largest key) entry.
2781
+ * @example
2782
+ * // Remove and return largest
2783
+ * const sl = new SkipList<number, string>([
2784
+ * [1, 'a'],
2785
+ * [2, 'b'],
2786
+ * [3, 'c']
2787
+ * ]);
2788
+ * console.log(sl.pollLast()); // [3, 'c'];
2789
+ * console.log(sl.size); // 2;
2790
+ */
4513
2791
  pollLast() {
4514
2792
  const entry = this.last();
4515
2793
  if (!entry) return void 0;
@@ -4517,55 +2795,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4517
2795
  return entry;
4518
2796
  }
4519
2797
  /**
4520
- * Least entry ≥ key, or `undefined`.
4521
-
4522
-
4523
-
4524
-
4525
-
4526
-
4527
-
4528
-
4529
-
4530
-
4531
-
4532
-
4533
-
4534
-
4535
-
4536
-
4537
-
4538
-
4539
-
4540
-
4541
-
4542
-
4543
-
4544
-
4545
-
4546
-
4547
-
4548
-
4549
-
4550
-
4551
-
4552
-
4553
-
4554
-
4555
-
4556
-
4557
-
4558
-
4559
-
4560
-
4561
-
4562
-
4563
- * @example
4564
- * // Least entry ≥ key
4565
- * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
4566
- * console.log(sl.ceiling(15)); // [20, 'b'];
4567
- * console.log(sl.ceiling(20)); // [20, 'b'];
4568
- */
2798
+ * Least entry ≥ key, or `undefined`.
2799
+ * @example
2800
+ * // Least entry ≥ key
2801
+ * const sl = new SkipList<number, string>([
2802
+ * [10, 'a'],
2803
+ * [20, 'b'],
2804
+ * [30, 'c']
2805
+ * ]);
2806
+ * console.log(sl.ceiling(15)); // [20, 'b'];
2807
+ * console.log(sl.ceiling(20)); // [20, 'b'];
2808
+ */
4569
2809
  ceiling(key) {
4570
2810
  const cmp = this.#comparator;
4571
2811
  let current = this._head;
@@ -4578,55 +2818,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4578
2818
  return node ? [node.key, node.value] : void 0;
4579
2819
  }
4580
2820
  /**
4581
- * Greatest entry ≤ key, or `undefined`.
4582
-
4583
-
4584
-
4585
-
4586
-
4587
-
4588
-
4589
-
4590
-
4591
-
4592
-
4593
-
4594
-
4595
-
4596
-
4597
-
4598
-
4599
-
4600
-
4601
-
4602
-
4603
-
4604
-
4605
-
4606
-
4607
-
4608
-
4609
-
4610
-
4611
-
4612
-
4613
-
4614
-
4615
-
4616
-
4617
-
4618
-
4619
-
4620
-
4621
-
4622
-
4623
-
4624
- * @example
4625
- * // Greatest entry ≤ key
4626
- * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
4627
- * console.log(sl.floor(25)); // [20, 'b'];
4628
- * console.log(sl.floor(5)); // undefined;
4629
- */
2821
+ * Greatest entry ≤ key, or `undefined`.
2822
+ * @example
2823
+ * // Greatest entry ≤ key
2824
+ * const sl = new SkipList<number, string>([
2825
+ * [10, 'a'],
2826
+ * [20, 'b'],
2827
+ * [30, 'c']
2828
+ * ]);
2829
+ * console.log(sl.floor(25)); // [20, 'b'];
2830
+ * console.log(sl.floor(5)); // undefined;
2831
+ */
4630
2832
  floor(key) {
4631
2833
  const cmp = this.#comparator;
4632
2834
  let current = this._head;
@@ -4640,52 +2842,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4640
2842
  return void 0;
4641
2843
  }
4642
2844
  /**
4643
- * Least entry strictly > key, or `undefined`.
4644
-
4645
-
4646
-
4647
-
4648
-
4649
-
4650
-
4651
-
4652
-
4653
-
4654
-
4655
-
4656
-
4657
-
4658
-
4659
-
4660
-
4661
-
4662
-
4663
-
4664
-
4665
-
4666
-
4667
-
4668
-
4669
-
4670
-
4671
-
4672
-
4673
-
4674
-
4675
-
4676
-
4677
-
4678
-
4679
-
4680
-
4681
-
4682
-
4683
- * @example
4684
- * // Strictly greater entry
4685
- * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
4686
- * console.log(sl.higher(15)); // [20, 'b'];
4687
- * console.log(sl.higher(30)); // undefined;
4688
- */
2845
+ * Least entry strictly > key, or `undefined`.
2846
+ * @example
2847
+ * // Strictly greater entry
2848
+ * const sl = new SkipList<number, string>([
2849
+ * [10, 'a'],
2850
+ * [20, 'b'],
2851
+ * [30, 'c']
2852
+ * ]);
2853
+ * console.log(sl.higher(15)); // [20, 'b'];
2854
+ * console.log(sl.higher(30)); // undefined;
2855
+ */
4689
2856
  higher(key) {
4690
2857
  const cmp = this.#comparator;
4691
2858
  let current = this._head;
@@ -4698,52 +2865,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4698
2865
  return node ? [node.key, node.value] : void 0;
4699
2866
  }
4700
2867
  /**
4701
- * Greatest entry strictly < key, or `undefined`.
4702
-
4703
-
4704
-
4705
-
4706
-
4707
-
4708
-
4709
-
4710
-
4711
-
4712
-
4713
-
4714
-
4715
-
4716
-
4717
-
4718
-
4719
-
4720
-
4721
-
4722
-
4723
-
4724
-
4725
-
4726
-
4727
-
4728
-
4729
-
4730
-
4731
-
4732
-
4733
-
4734
-
4735
-
4736
-
4737
-
4738
-
4739
-
4740
-
4741
- * @example
4742
- * // Strictly less entry
4743
- * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
4744
- * console.log(sl.lower(25)); // [20, 'b'];
4745
- * console.log(sl.lower(10)); // undefined;
4746
- */
2868
+ * Greatest entry strictly < key, or `undefined`.
2869
+ * @example
2870
+ * // Strictly less entry
2871
+ * const sl = new SkipList<number, string>([
2872
+ * [10, 'a'],
2873
+ * [20, 'b'],
2874
+ * [30, 'c']
2875
+ * ]);
2876
+ * console.log(sl.lower(25)); // [20, 'b'];
2877
+ * console.log(sl.lower(10)); // undefined;
2878
+ */
4747
2879
  lower(key) {
4748
2880
  const cmp = this.#comparator;
4749
2881
  let current = this._head;
@@ -4759,55 +2891,23 @@ var SkipList = class _SkipList extends IterableEntryBase {
4759
2891
  return result ? [result.key, result.value] : void 0;
4760
2892
  }
4761
2893
  /**
4762
- * Returns entries within the given key range.
4763
-
4764
-
4765
-
4766
-
4767
-
4768
-
4769
-
4770
-
4771
-
4772
-
4773
-
4774
-
4775
-
4776
-
4777
-
4778
-
4779
-
4780
-
4781
-
4782
-
4783
-
4784
-
4785
-
4786
-
4787
-
4788
-
4789
-
4790
-
4791
-
4792
-
4793
-
4794
-
4795
-
4796
-
4797
-
4798
-
4799
-
4800
-
4801
-
4802
-
4803
-
4804
-
4805
- * @example
4806
- * // Find entries in a range
4807
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e']]);
4808
- * const result = sl.rangeSearch([2, 4]);
4809
- * console.log(result); // [[2, 'b'], [3, 'c'], [4, 'd']];
4810
- */
2894
+ * Returns entries within the given key range.
2895
+ * @example
2896
+ * // Find entries in a range
2897
+ * const sl = new SkipList<number, string>([
2898
+ * [1, 'a'],
2899
+ * [2, 'b'],
2900
+ * [3, 'c'],
2901
+ * [4, 'd'],
2902
+ * [5, 'e']
2903
+ * ]);
2904
+ * const result = sl.rangeSearch([2, 4]);
2905
+ * console.log(result); // [
2906
+ * // [2, 'b'],
2907
+ * // [3, 'c'],
2908
+ * // [4, 'd']
2909
+ * // ];
2910
+ */
4811
2911
  rangeSearch(range, options = {}) {
4812
2912
  const { lowInclusive = true, highInclusive = true } = options;
4813
2913
  const [low, high] = range;
@@ -4834,52 +2934,16 @@ var SkipList = class _SkipList extends IterableEntryBase {
4834
2934
  }
4835
2935
  // ─── Functional (overrides) ──────────────────────────────────
4836
2936
  /**
4837
- * Creates a new SkipList with entries transformed by callback.
4838
-
4839
-
4840
-
4841
-
4842
-
4843
-
4844
-
4845
-
4846
-
4847
-
4848
-
4849
-
4850
-
4851
-
4852
-
4853
-
4854
-
4855
-
4856
-
4857
-
4858
-
4859
-
4860
-
4861
-
4862
-
4863
-
4864
-
4865
-
4866
-
4867
-
4868
-
4869
-
4870
-
4871
-
4872
-
4873
-
4874
-
4875
-
4876
-
4877
- * @example
4878
- * // Transform entries
4879
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
4880
- * const mapped = sl.map((v, k) => [k, v?.toUpperCase()] as [number, string]);
4881
- * console.log([...mapped.values()]); // ['A', 'B'];
4882
- */
2937
+ * Creates a new SkipList with entries transformed by callback.
2938
+ * @example
2939
+ * // Transform entries
2940
+ * const sl = new SkipList<number, string>([
2941
+ * [1, 'a'],
2942
+ * [2, 'b']
2943
+ * ]);
2944
+ * const mapped = sl.map((v, k) => [k, v?.toUpperCase()] as [number, string]);
2945
+ * console.log([...mapped.values()]); // ['A', 'B'];
2946
+ */
4883
2947
  map(callback, options) {
4884
2948
  const out = new _SkipList([], options ?? {});
4885
2949
  let i = 0;
@@ -4890,52 +2954,17 @@ var SkipList = class _SkipList extends IterableEntryBase {
4890
2954
  return out;
4891
2955
  }
4892
2956
  /**
4893
- * Creates a new SkipList with entries that pass the predicate.
4894
-
4895
-
4896
-
4897
-
4898
-
4899
-
4900
-
4901
-
4902
-
4903
-
4904
-
4905
-
4906
-
4907
-
4908
-
4909
-
4910
-
4911
-
4912
-
4913
-
4914
-
4915
-
4916
-
4917
-
4918
-
4919
-
4920
-
4921
-
4922
-
4923
-
4924
-
4925
-
4926
-
4927
-
4928
-
4929
-
4930
-
4931
-
4932
-
4933
- * @example
4934
- * // Filter entries
4935
- * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
4936
- * const result = sl.filter((v, k) => k > 1);
4937
- * console.log(result.size); // 2;
4938
- */
2957
+ * Creates a new SkipList with entries that pass the predicate.
2958
+ * @example
2959
+ * // Filter entries
2960
+ * const sl = new SkipList<number, string>([
2961
+ * [1, 'a'],
2962
+ * [2, 'b'],
2963
+ * [3, 'c']
2964
+ * ]);
2965
+ * const result = sl.filter((v, k) => k > 1);
2966
+ * console.log(result.size); // 2;
2967
+ */
4939
2968
  filter(callbackfn, thisArg) {
4940
2969
  const out = new _SkipList([], {
4941
2970
  comparator: this.#isDefaultComparator ? void 0 : this.#comparator,