data-structure-typed 2.6.1 → 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 (116) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/cjs/binary-tree.cjs +2927 -23688
  3. package/dist/cjs/graph.cjs +845 -2634
  4. package/dist/cjs/hash.cjs +185 -616
  5. package/dist/cjs/heap.cjs +266 -818
  6. package/dist/cjs/index.cjs +5116 -31358
  7. package/dist/cjs/linked-list.cjs +644 -2615
  8. package/dist/cjs/matrix.cjs +220 -535
  9. package/dist/cjs/priority-queue.cjs +266 -818
  10. package/dist/cjs/queue.cjs +637 -2343
  11. package/dist/cjs/stack.cjs +124 -530
  12. package/dist/cjs/trie.cjs +145 -592
  13. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  14. package/dist/cjs-legacy/graph.cjs +847 -2636
  15. package/dist/cjs-legacy/hash.cjs +181 -612
  16. package/dist/cjs-legacy/heap.cjs +266 -818
  17. package/dist/cjs-legacy/index.cjs +6657 -32899
  18. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  19. package/dist/cjs-legacy/matrix.cjs +220 -535
  20. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  21. package/dist/cjs-legacy/queue.cjs +634 -2340
  22. package/dist/cjs-legacy/stack.cjs +124 -530
  23. package/dist/cjs-legacy/trie.cjs +145 -592
  24. package/dist/esm/binary-tree.mjs +2927 -23688
  25. package/dist/esm/graph.mjs +845 -2634
  26. package/dist/esm/hash.mjs +185 -616
  27. package/dist/esm/heap.mjs +266 -818
  28. package/dist/esm/index.mjs +5116 -31358
  29. package/dist/esm/linked-list.mjs +644 -2615
  30. package/dist/esm/matrix.mjs +220 -535
  31. package/dist/esm/priority-queue.mjs +266 -818
  32. package/dist/esm/queue.mjs +637 -2343
  33. package/dist/esm/stack.mjs +124 -530
  34. package/dist/esm/trie.mjs +145 -592
  35. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  36. package/dist/esm-legacy/graph.mjs +847 -2636
  37. package/dist/esm-legacy/hash.mjs +181 -612
  38. package/dist/esm-legacy/heap.mjs +266 -818
  39. package/dist/esm-legacy/index.mjs +6657 -32899
  40. package/dist/esm-legacy/linked-list.mjs +640 -2611
  41. package/dist/esm-legacy/matrix.mjs +220 -535
  42. package/dist/esm-legacy/priority-queue.mjs +266 -818
  43. package/dist/esm-legacy/queue.mjs +634 -2340
  44. package/dist/esm-legacy/stack.mjs +124 -530
  45. package/dist/esm-legacy/trie.mjs +145 -592
  46. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  47. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  48. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  49. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  50. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  51. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  52. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  54. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  55. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  56. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  57. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  58. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  59. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  60. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  61. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  62. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  63. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  64. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  65. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  66. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  67. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  68. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  69. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  70. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  71. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  72. package/dist/umd/data-structure-typed.js +6580 -32822
  73. package/dist/umd/data-structure-typed.min.js +3 -3
  74. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  75. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  76. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  77. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  78. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  79. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  80. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  81. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  82. package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
  83. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  84. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
  85. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  86. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  88. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  89. package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
  90. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
  91. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
  92. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
  93. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  94. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
  95. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  96. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  97. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
  98. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
  99. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
  100. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
  101. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
  102. package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
  103. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  104. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  105. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
  113. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  114. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  115. package/package.json +1 -1
  116. package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
@@ -731,10 +731,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
731
731
  */
732
732
  constructor(elements = [], options) {
733
733
  super(options);
734
- __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
735
734
  __publicField(this, "_head");
736
735
  __publicField(this, "_tail");
737
736
  __publicField(this, "_length", 0);
737
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
738
738
  this.pushMany(elements);
739
739
  }
740
740
  /**
@@ -796,68 +796,26 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
796
796
  return list;
797
797
  }
798
798
  /**
799
- * Append an element/node to the tail.
800
- * @remarks Time O(1), Space O(1)
801
- * @param elementOrNode - Element or node to append.
802
- * @returns True when appended.
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
-
845
- * @example
846
- * // basic SinglyLinkedList creation and push operation
847
- * // Create a simple SinglyLinkedList with initial values
848
- * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
849
- *
850
- * // Verify the list maintains insertion order
851
- * console.log([...list]); // [1, 2, 3, 4, 5];
852
- *
853
- * // Check length
854
- * console.log(list.length); // 5;
855
- *
856
- * // Push a new element to the end
857
- * list.push(6);
858
- * console.log(list.length); // 6;
859
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
860
- */
799
+ * Append an element/node to the tail.
800
+ * @remarks Time O(1), Space O(1)
801
+ * @param elementOrNode - Element or node to append.
802
+ * @returns True when appended.
803
+ * @example
804
+ * // basic SinglyLinkedList creation and push operation
805
+ * // Create a simple SinglyLinkedList with initial values
806
+ * const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
807
+ *
808
+ * // Verify the list maintains insertion order
809
+ * console.log([...list]); // [1, 2, 3, 4, 5];
810
+ *
811
+ * // Check length
812
+ * console.log(list.length); // 5;
813
+ *
814
+ * // Push a new element to the end
815
+ * list.push(6);
816
+ * console.log(list.length); // 6;
817
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
818
+ */
861
819
  push(elementOrNode) {
862
820
  const newNode = this._ensureNode(elementOrNode);
863
821
  if (!this.head) {
@@ -871,67 +829,25 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
871
829
  return true;
872
830
  }
873
831
  /**
874
- * Remove and return the tail element.
875
- * @remarks Time O(N), Space O(1)
876
- * @returns Removed element or undefined.
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
-
919
- * @example
920
- * // SinglyLinkedList pop and shift operations
921
- * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
922
- *
923
- * // Pop removes from the end
924
- * const last = list.pop();
925
- * console.log(last); // 50;
926
- *
927
- * // Shift removes from the beginning
928
- * const first = list.shift();
929
- * console.log(first); // 10;
930
- *
931
- * // Verify remaining elements
932
- * console.log([...list]); // [20, 30, 40];
933
- * console.log(list.length); // 3;
934
- */
832
+ * Remove and return the tail element.
833
+ * @remarks Time O(N), Space O(1)
834
+ * @returns Removed element or undefined.
835
+ * @example
836
+ * // SinglyLinkedList pop and shift operations
837
+ * const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
838
+ *
839
+ * // Pop removes from the end
840
+ * const last = list.pop();
841
+ * console.log(last); // 50;
842
+ *
843
+ * // Shift removes from the beginning
844
+ * const first = list.shift();
845
+ * console.log(first); // 10;
846
+ *
847
+ * // Verify remaining elements
848
+ * console.log([...list]); // [20, 30, 40];
849
+ * console.log(list.length); // 3;
850
+ */
935
851
  pop() {
936
852
  var _a;
937
853
  if (!this.head) return void 0;
@@ -951,57 +867,15 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
951
867
  return value;
952
868
  }
953
869
  /**
954
- * Remove and return the head element.
955
- * @remarks Time O(1), Space O(1)
956
- * @returns Removed element or undefined.
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
-
998
-
999
- * @example
1000
- * // Remove from the front
1001
- * const list = new SinglyLinkedList<number>([10, 20, 30]);
1002
- * console.log(list.shift()); // 10;
1003
- * console.log(list.length); // 2;
1004
- */
870
+ * Remove and return the head element.
871
+ * @remarks Time O(1), Space O(1)
872
+ * @returns Removed element or undefined.
873
+ * @example
874
+ * // Remove from the front
875
+ * const list = new SinglyLinkedList<number>([10, 20, 30]);
876
+ * console.log(list.shift()); // 10;
877
+ * console.log(list.length); // 2;
878
+ */
1005
879
  shift() {
1006
880
  if (!this.head) return void 0;
1007
881
  const removed = this.head;
@@ -1011,73 +885,31 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1011
885
  return removed.value;
1012
886
  }
1013
887
  /**
1014
- * Prepend an element/node to the head.
1015
- * @remarks Time O(1), Space O(1)
1016
- * @param elementOrNode - Element or node to prepend.
1017
- * @returns True when prepended.
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
-
1059
-
1060
- * @example
1061
- * // SinglyLinkedList unshift and forward traversal
1062
- * const list = new SinglyLinkedList<number>([20, 30, 40]);
1063
- *
1064
- * // Unshift adds to the beginning
1065
- * list.unshift(10);
1066
- * console.log([...list]); // [10, 20, 30, 40];
1067
- *
1068
- * // Access elements (forward traversal only for singly linked)
1069
- * const second = list.at(1);
1070
- * console.log(second); // 20;
1071
- *
1072
- * // SinglyLinkedList allows forward iteration only
1073
- * const elements: number[] = [];
1074
- * for (const item of list) {
1075
- * elements.push(item);
1076
- * }
1077
- * console.log(elements); // [10, 20, 30, 40];
1078
- *
1079
- * console.log(list.length); // 4;
1080
- */
888
+ * Prepend an element/node to the head.
889
+ * @remarks Time O(1), Space O(1)
890
+ * @param elementOrNode - Element or node to prepend.
891
+ * @returns True when prepended.
892
+ * @example
893
+ * // SinglyLinkedList unshift and forward traversal
894
+ * const list = new SinglyLinkedList<number>([20, 30, 40]);
895
+ *
896
+ * // Unshift adds to the beginning
897
+ * list.unshift(10);
898
+ * console.log([...list]); // [10, 20, 30, 40];
899
+ *
900
+ * // Access elements (forward traversal only for singly linked)
901
+ * const second = list.at(1);
902
+ * console.log(second); // 20;
903
+ *
904
+ * // SinglyLinkedList allows forward iteration only
905
+ * const elements: number[] = [];
906
+ * for (const item of list) {
907
+ * elements.push(item);
908
+ * }
909
+ * console.log(elements); // [10, 20, 30, 40];
910
+ *
911
+ * console.log(list.length); // 4;
912
+ */
1081
913
  unshift(elementOrNode) {
1082
914
  const newNode = this._ensureNode(elementOrNode);
1083
915
  if (!this.head) {
@@ -1133,59 +965,17 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1133
965
  return void 0;
1134
966
  }
1135
967
  /**
1136
- * Get the element at a given index.
1137
- * @remarks Time O(N), Space O(1)
1138
- * @param index - Zero-based index.
1139
- * @returns Element or undefined.
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
-
1181
-
1182
- * @example
1183
- * // Access element by index
1184
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
1185
- * console.log(list.at(0)); // 'a';
1186
- * console.log(list.at(2)); // 'c';
1187
- * console.log(list.at(3)); // 'd';
1188
- */
968
+ * Get the element at a given index.
969
+ * @remarks Time O(N), Space O(1)
970
+ * @param index - Zero-based index.
971
+ * @returns Element or undefined.
972
+ * @example
973
+ * // Access element by index
974
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
975
+ * console.log(list.at(0)); // 'a';
976
+ * console.log(list.at(2)); // 'c';
977
+ * console.log(list.at(3)); // 'd';
978
+ */
1189
979
  at(index) {
1190
980
  if (index < 0 || index >= this._length) return void 0;
1191
981
  let current = this.head;
@@ -1202,54 +992,15 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1202
992
  return elementNodeOrPredicate instanceof SinglyLinkedListNode;
1203
993
  }
1204
994
  /**
1205
- * Get the node reference at a given index.
1206
- * @remarks Time O(N), Space O(1)
1207
- * @param index - Zero-based index.
1208
- * @returns Node or undefined.
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
-
1247
-
1248
- * @example
1249
- * // Get node at index
1250
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1251
- * console.log(list.getNodeAt(1)?.value); // 'b';
1252
- */
995
+ * Get the node reference at a given index.
996
+ * @remarks Time O(N), Space O(1)
997
+ * @param index - Zero-based index.
998
+ * @returns Node or undefined.
999
+ * @example
1000
+ * // Get node at index
1001
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1002
+ * console.log(list.getNodeAt(1)?.value); // 'b';
1003
+ */
1253
1004
  getNodeAt(index) {
1254
1005
  if (index < 0 || index >= this._length) return void 0;
1255
1006
  let current = this.head;
@@ -1257,55 +1008,16 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1257
1008
  return current;
1258
1009
  }
1259
1010
  /**
1260
- * Delete the element at an index.
1261
- * @remarks Time O(N), Space O(1)
1262
- * @param index - Zero-based index.
1263
- * @returns Removed element or undefined.
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
-
1302
-
1303
- * @example
1304
- * // Remove by index
1305
- * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1306
- * list.deleteAt(1);
1307
- * console.log(list.toArray()); // ['a', 'c'];
1308
- */
1011
+ * Delete the element at an index.
1012
+ * @remarks Time O(N), Space O(1)
1013
+ * @param index - Zero-based index.
1014
+ * @returns Removed element or undefined.
1015
+ * @example
1016
+ * // Remove by index
1017
+ * const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
1018
+ * list.deleteAt(1);
1019
+ * console.log(list.toArray()); // ['a', 'c'];
1020
+ */
1309
1021
  deleteAt(index) {
1310
1022
  if (index < 0 || index >= this._length) return void 0;
1311
1023
  if (index === 0) return this.shift();
@@ -1318,55 +1030,16 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1318
1030
  return value;
1319
1031
  }
1320
1032
  /**
1321
- * Delete the first match by value/node.
1322
- * @remarks Time O(N), Space O(1)
1323
- * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
1324
- * @returns True if removed.
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
-
1363
-
1364
- * @example
1365
- * // Remove first occurrence
1366
- * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
1367
- * list.delete(2);
1368
- * console.log(list.toArray()); // [1, 3, 2];
1369
- */
1033
+ * Delete the first match by value/node.
1034
+ * @remarks Time O(N), Space O(1)
1035
+ * @param [elementOrNode] - Element or node to remove; if omitted/undefined, nothing happens.
1036
+ * @returns True if removed.
1037
+ * @example
1038
+ * // Remove first occurrence
1039
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
1040
+ * list.delete(2);
1041
+ * console.log(list.toArray()); // [1, 3, 2];
1042
+ */
1370
1043
  delete(elementOrNode) {
1371
1044
  if (elementOrNode === void 0 || !this.head) return false;
1372
1045
  const node = this.isNode(elementOrNode) ? elementOrNode : this.getNode(elementOrNode);
@@ -1383,56 +1056,17 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1383
1056
  return true;
1384
1057
  }
1385
1058
  /**
1386
- * Insert a new element/node at an index, shifting following nodes.
1387
- * @remarks Time O(N), Space O(1)
1388
- * @param index - Zero-based index.
1389
- * @param newElementOrNode - Element or node to insert.
1390
- * @returns True if inserted.
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
-
1429
-
1430
- * @example
1431
- * // Insert at index
1432
- * const list = new SinglyLinkedList<number>([1, 3]);
1433
- * list.addAt(1, 2);
1434
- * console.log(list.toArray()); // [1, 2, 3];
1435
- */
1059
+ * Insert a new element/node at an index, shifting following nodes.
1060
+ * @remarks Time O(N), Space O(1)
1061
+ * @param index - Zero-based index.
1062
+ * @param newElementOrNode - Element or node to insert.
1063
+ * @returns True if inserted.
1064
+ * @example
1065
+ * // Insert at index
1066
+ * const list = new SinglyLinkedList<number>([1, 3]);
1067
+ * list.addAt(1, 2);
1068
+ * console.log(list.toArray()); // [1, 2, 3];
1069
+ */
1436
1070
  addAt(index, newElementOrNode) {
1437
1071
  if (index < 0 || index > this._length) return false;
1438
1072
  if (index === 0) return this.unshift(newElementOrNode);
@@ -1458,163 +1092,41 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1458
1092
  return true;
1459
1093
  }
1460
1094
  /**
1461
- * Check whether the list is empty.
1462
- * @remarks Time O(1), Space O(1)
1463
- * @returns True if length is 0.
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
-
1503
-
1504
- * @example
1505
- * // Check empty
1506
- * console.log(new SinglyLinkedList().isEmpty()); // true;
1507
- */
1095
+ * Check whether the list is empty.
1096
+ * @remarks Time O(1), Space O(1)
1097
+ * @returns True if length is 0.
1098
+ * @example
1099
+ * // Check empty
1100
+ * console.log(new SinglyLinkedList().isEmpty()); // true;
1101
+ */
1508
1102
  isEmpty() {
1509
1103
  return this._length === 0;
1510
1104
  }
1511
1105
  /**
1512
- * Remove all nodes and reset length.
1513
- * @remarks Time O(N), Space O(1)
1514
- * @returns void
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
-
1554
-
1555
- * @example
1556
- * // Remove all
1557
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1558
- * list.clear();
1559
- * console.log(list.isEmpty()); // true;
1560
- */
1106
+ * Remove all nodes and reset length.
1107
+ * @remarks Time O(N), Space O(1)
1108
+ * @returns void
1109
+ * @example
1110
+ * // Remove all
1111
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1112
+ * list.clear();
1113
+ * console.log(list.isEmpty()); // true;
1114
+ */
1561
1115
  clear() {
1562
1116
  this._head = void 0;
1563
1117
  this._tail = void 0;
1564
1118
  this._length = 0;
1565
1119
  }
1566
1120
  /**
1567
- * Reverse the list in place.
1568
- * @remarks Time O(N), Space O(1)
1569
- * @returns This list.
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
-
1611
-
1612
- * @example
1613
- * // Reverse the list in-place
1614
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
1615
- * list.reverse();
1616
- * console.log([...list]); // [4, 3, 2, 1];
1617
- */
1121
+ * Reverse the list in place.
1122
+ * @remarks Time O(N), Space O(1)
1123
+ * @returns This list.
1124
+ * @example
1125
+ * // Reverse the list in-place
1126
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
1127
+ * list.reverse();
1128
+ * console.log([...list]); // [4, 3, 2, 1];
1129
+ */
1618
1130
  reverse() {
1619
1131
  if (!this.head || this.head === this.tail) return this;
1620
1132
  let prev;
@@ -1789,126 +1301,44 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1789
1301
  return false;
1790
1302
  }
1791
1303
  /**
1792
- * Deep clone this list (values are copied by reference).
1793
- * @remarks Time O(N), Space O(N)
1794
- * @returns A new list with the same element sequence.
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
-
1834
-
1835
- * @example
1836
- * // Deep copy
1837
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1838
- * const copy = list.clone();
1839
- * copy.pop();
1840
- * console.log(list.length); // 3;
1841
- * console.log(copy.length); // 2;
1842
- */
1304
+ * Deep clone this list (values are copied by reference).
1305
+ * @remarks Time O(N), Space O(N)
1306
+ * @returns A new list with the same element sequence.
1307
+ * @example
1308
+ * // Deep copy
1309
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1310
+ * const copy = list.clone();
1311
+ * copy.pop();
1312
+ * console.log(list.length); // 3;
1313
+ * console.log(copy.length); // 2;
1314
+ */
1843
1315
  clone() {
1844
1316
  const out = this._createInstance();
1845
1317
  for (const v of this) out.push(v);
1846
1318
  return out;
1847
1319
  }
1848
1320
  /**
1849
- * Filter values into a new list of the same class.
1850
- * @remarks Time O(N), Space O(N)
1851
- * @param callback - Predicate (value, index, list) → boolean to keep value.
1852
- * @param [thisArg] - Value for `this` inside the callback.
1853
- * @returns A new list with kept values.
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
-
1895
-
1896
- * @example
1897
- * // SinglyLinkedList filter and map operations
1898
- * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
1899
- *
1900
- * // Filter even numbers
1901
- * const filtered = list.filter(value => value % 2 === 0);
1902
- * console.log(filtered.length); // 2;
1903
- *
1904
- * // Map to double values
1905
- * const doubled = list.map(value => value * 2);
1906
- * console.log(doubled.length); // 5;
1907
- *
1908
- * // Use reduce to sum
1909
- * const sum = list.reduce((acc, value) => acc + value, 0);
1910
- * console.log(sum); // 15;
1911
- */
1321
+ * Filter values into a new list of the same class.
1322
+ * @remarks Time O(N), Space O(N)
1323
+ * @param callback - Predicate (value, index, list) → boolean to keep value.
1324
+ * @param [thisArg] - Value for `this` inside the callback.
1325
+ * @returns A new list with kept values.
1326
+ * @example
1327
+ * // SinglyLinkedList filter and map operations
1328
+ * const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
1329
+ *
1330
+ * // Filter even numbers
1331
+ * const filtered = list.filter(value => value % 2 === 0);
1332
+ * console.log(filtered.length); // 2;
1333
+ *
1334
+ * // Map to double values
1335
+ * const doubled = list.map(value => value * 2);
1336
+ * console.log(doubled.length); // 5;
1337
+ *
1338
+ * // Use reduce to sum
1339
+ * const sum = list.reduce((acc, value) => acc + value, 0);
1340
+ * console.log(sum); // 15;
1341
+ */
1912
1342
  filter(callback, thisArg) {
1913
1343
  const out = this._createInstance();
1914
1344
  let index = 0;
@@ -1932,62 +1362,20 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1932
1362
  return out;
1933
1363
  }
1934
1364
  /**
1935
- * Map values into a new list (possibly different element type).
1936
- * @remarks Time O(N), Space O(N)
1937
- * @template EM
1938
- * @template RM
1939
- * @param callback - Mapping function (value, index, list) → newElement.
1940
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1941
- * @param [thisArg] - Value for `this` inside the callback.
1942
- * @returns A new SinglyLinkedList with mapped values.
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
-
1984
-
1985
- * @example
1986
- * // Transform elements
1987
- * const list = new SinglyLinkedList<number>([1, 2, 3]);
1988
- * const doubled = list.map(n => n * 2);
1989
- * console.log([...doubled]); // [2, 4, 6];
1990
- */
1365
+ * Map values into a new list (possibly different element type).
1366
+ * @remarks Time O(N), Space O(N)
1367
+ * @template EM
1368
+ * @template RM
1369
+ * @param callback - Mapping function (value, index, list) → newElement.
1370
+ * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
1371
+ * @param [thisArg] - Value for `this` inside the callback.
1372
+ * @returns A new SinglyLinkedList with mapped values.
1373
+ * @example
1374
+ * // Transform elements
1375
+ * const list = new SinglyLinkedList<number>([1, 2, 3]);
1376
+ * const doubled = list.map(n => n * 2);
1377
+ * console.log([...doubled]); // [2, 4, 6];
1378
+ */
1991
1379
  map(callback, options, thisArg) {
1992
1380
  const out = this._createLike([], { ...options != null ? options : {}, maxLen: this._maxLen });
1993
1381
  let index = 0;
@@ -2187,10 +1575,10 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2187
1575
  */
2188
1576
  constructor(elements = [], options) {
2189
1577
  super(options);
2190
- __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2191
1578
  __publicField(this, "_head");
2192
1579
  __publicField(this, "_tail");
2193
1580
  __publicField(this, "_length", 0);
1581
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2194
1582
  this._head = void 0;
2195
1583
  this._tail = void 0;
2196
1584
  this._length = 0;
@@ -2263,68 +1651,26 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2263
1651
  return elementNodeOrPredicate instanceof DoublyLinkedListNode;
2264
1652
  }
2265
1653
  /**
2266
- * Append an element/node to the tail.
2267
- * @remarks Time O(1), Space O(1)
2268
- * @param elementOrNode - Element or node to append.
2269
- * @returns True when appended.
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
-
2311
-
2312
- * @example
2313
- * // basic DoublyLinkedList creation and push operation
2314
- * // Create a simple DoublyLinkedList with initial values
2315
- * const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
2316
- *
2317
- * // Verify the list maintains insertion order
2318
- * console.log([...list]); // [1, 2, 3, 4, 5];
2319
- *
2320
- * // Check length
2321
- * console.log(list.length); // 5;
2322
- *
2323
- * // Push a new element to the end
2324
- * list.push(6);
2325
- * console.log(list.length); // 6;
2326
- * console.log([...list]); // [1, 2, 3, 4, 5, 6];
2327
- */
1654
+ * Append an element/node to the tail.
1655
+ * @remarks Time O(1), Space O(1)
1656
+ * @param elementOrNode - Element or node to append.
1657
+ * @returns True when appended.
1658
+ * @example
1659
+ * // basic DoublyLinkedList creation and push operation
1660
+ * // Create a simple DoublyLinkedList with initial values
1661
+ * const list = new DoublyLinkedList([1, 2, 3, 4, 5]);
1662
+ *
1663
+ * // Verify the list maintains insertion order
1664
+ * console.log([...list]); // [1, 2, 3, 4, 5];
1665
+ *
1666
+ * // Check length
1667
+ * console.log(list.length); // 5;
1668
+ *
1669
+ * // Push a new element to the end
1670
+ * list.push(6);
1671
+ * console.log(list.length); // 6;
1672
+ * console.log([...list]); // [1, 2, 3, 4, 5, 6];
1673
+ */
2328
1674
  push(elementOrNode) {
2329
1675
  const newNode = this._ensureNode(elementOrNode);
2330
1676
  if (!this.head) {
@@ -2340,67 +1686,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2340
1686
  return true;
2341
1687
  }
2342
1688
  /**
2343
- * Remove and return the tail element.
2344
- * @remarks Time O(1), Space O(1)
2345
- * @returns Removed element or undefined.
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
-
2387
-
2388
- * @example
2389
- * // DoublyLinkedList pop and shift operations
2390
- * const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
2391
- *
2392
- * // Pop removes from the end
2393
- * const last = list.pop();
2394
- * console.log(last); // 50;
2395
- *
2396
- * // Shift removes from the beginning
2397
- * const first = list.shift();
2398
- * console.log(first); // 10;
2399
- *
2400
- * // Verify remaining elements
2401
- * console.log([...list]); // [20, 30, 40];
2402
- * console.log(list.length); // 3;
2403
- */
1689
+ * Remove and return the tail element.
1690
+ * @remarks Time O(1), Space O(1)
1691
+ * @returns Removed element or undefined.
1692
+ * @example
1693
+ * // DoublyLinkedList pop and shift operations
1694
+ * const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
1695
+ *
1696
+ * // Pop removes from the end
1697
+ * const last = list.pop();
1698
+ * console.log(last); // 50;
1699
+ *
1700
+ * // Shift removes from the beginning
1701
+ * const first = list.shift();
1702
+ * console.log(first); // 10;
1703
+ *
1704
+ * // Verify remaining elements
1705
+ * console.log([...list]); // [20, 30, 40];
1706
+ * console.log(list.length); // 3;
1707
+ */
2404
1708
  pop() {
2405
1709
  if (!this.tail) return void 0;
2406
1710
  const removed = this.tail;
@@ -2415,57 +1719,15 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2415
1719
  return removed.value;
2416
1720
  }
2417
1721
  /**
2418
- * Remove and return the head element.
2419
- * @remarks Time O(1), Space O(1)
2420
- * @returns Removed element or undefined.
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
-
2462
-
2463
- * @example
2464
- * // Remove from the front
2465
- * const list = new DoublyLinkedList<number>([10, 20, 30]);
2466
- * console.log(list.shift()); // 10;
2467
- * console.log(list.first); // 20;
2468
- */
1722
+ * Remove and return the head element.
1723
+ * @remarks Time O(1), Space O(1)
1724
+ * @returns Removed element or undefined.
1725
+ * @example
1726
+ * // Remove from the front
1727
+ * const list = new DoublyLinkedList<number>([10, 20, 30]);
1728
+ * console.log(list.shift()); // 10;
1729
+ * console.log(list.first); // 20;
1730
+ */
2469
1731
  shift() {
2470
1732
  if (!this.head) return void 0;
2471
1733
  const removed = this.head;
@@ -2480,58 +1742,16 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2480
1742
  return removed.value;
2481
1743
  }
2482
1744
  /**
2483
- * Prepend an element/node to the head.
2484
- * @remarks Time O(1), Space O(1)
2485
- * @param elementOrNode - Element or node to prepend.
2486
- * @returns True when prepended.
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
-
2528
-
2529
- * @example
2530
- * // Add to the front
2531
- * const list = new DoublyLinkedList<number>([2, 3]);
2532
- * list.unshift(1);
2533
- * console.log([...list]); // [1, 2, 3];
2534
- */
1745
+ * Prepend an element/node to the head.
1746
+ * @remarks Time O(1), Space O(1)
1747
+ * @param elementOrNode - Element or node to prepend.
1748
+ * @returns True when prepended.
1749
+ * @example
1750
+ * // Add to the front
1751
+ * const list = new DoublyLinkedList<number>([2, 3]);
1752
+ * list.unshift(1);
1753
+ * console.log([...list]); // [1, 2, 3];
1754
+ */
2535
1755
  unshift(elementOrNode) {
2536
1756
  const newNode = this._ensureNode(elementOrNode);
2537
1757
  if (!this.head) {
@@ -2575,58 +1795,16 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2575
1795
  return ans;
2576
1796
  }
2577
1797
  /**
2578
- * Get the element at a given index.
2579
- * @remarks Time O(N), Space O(1)
2580
- * @param index - Zero-based index.
2581
- * @returns Element or undefined.
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
-
2623
-
2624
- * @example
2625
- * // Access by index
2626
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2627
- * console.log(list.at(1)); // 'b';
2628
- * console.log(list.at(2)); // 'c';
2629
- */
1798
+ * Get the element at a given index.
1799
+ * @remarks Time O(N), Space O(1)
1800
+ * @param index - Zero-based index.
1801
+ * @returns Element or undefined.
1802
+ * @example
1803
+ * // Access by index
1804
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1805
+ * console.log(list.at(1)); // 'b';
1806
+ * console.log(list.at(2)); // 'c';
1807
+ */
2630
1808
  at(index) {
2631
1809
  if (index < 0 || index >= this._length) return void 0;
2632
1810
  let current = this.head;
@@ -2634,54 +1812,15 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2634
1812
  return current == null ? void 0 : current.value;
2635
1813
  }
2636
1814
  /**
2637
- * Get the node reference at a given index.
2638
- * @remarks Time O(N), Space O(1)
2639
- * @param index - Zero-based index.
2640
- * @returns Node or undefined.
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
-
2679
-
2680
- * @example
2681
- * // Get node at index
2682
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2683
- * console.log(list.getNodeAt(1)?.value); // 'b';
2684
- */
1815
+ * Get the node reference at a given index.
1816
+ * @remarks Time O(N), Space O(1)
1817
+ * @param index - Zero-based index.
1818
+ * @returns Node or undefined.
1819
+ * @example
1820
+ * // Get node at index
1821
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1822
+ * console.log(list.getNodeAt(1)?.value); // 'b';
1823
+ */
2685
1824
  getNodeAt(index) {
2686
1825
  if (index < 0 || index >= this._length) return void 0;
2687
1826
  let current = this.head;
@@ -2720,56 +1859,17 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2720
1859
  return void 0;
2721
1860
  }
2722
1861
  /**
2723
- * Insert a new element/node at an index, shifting following nodes.
2724
- * @remarks Time O(N), Space O(1)
2725
- * @param index - Zero-based index.
2726
- * @param newElementOrNode - Element or node to insert.
2727
- * @returns True if inserted.
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
-
2766
-
2767
- * @example
2768
- * // Insert at position
2769
- * const list = new DoublyLinkedList<number>([1, 3]);
2770
- * list.addAt(1, 2);
2771
- * console.log(list.toArray()); // [1, 2, 3];
2772
- */
1862
+ * Insert a new element/node at an index, shifting following nodes.
1863
+ * @remarks Time O(N), Space O(1)
1864
+ * @param index - Zero-based index.
1865
+ * @param newElementOrNode - Element or node to insert.
1866
+ * @returns True if inserted.
1867
+ * @example
1868
+ * // Insert at position
1869
+ * const list = new DoublyLinkedList<number>([1, 3]);
1870
+ * list.addAt(1, 2);
1871
+ * console.log(list.toArray()); // [1, 2, 3];
1872
+ */
2773
1873
  addAt(index, newElementOrNode) {
2774
1874
  if (index < 0 || index > this._length) return false;
2775
1875
  if (index === 0) return this.unshift(newElementOrNode);
@@ -2836,55 +1936,16 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2836
1936
  return true;
2837
1937
  }
2838
1938
  /**
2839
- * Delete the element at an index.
2840
- * @remarks Time O(N), Space O(1)
2841
- * @param index - Zero-based index.
2842
- * @returns Removed element or undefined.
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
-
2881
-
2882
- * @example
2883
- * // Remove by index
2884
- * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
2885
- * list.deleteAt(1);
2886
- * console.log(list.toArray()); // ['a', 'c'];
2887
- */
1939
+ * Delete the element at an index.
1940
+ * @remarks Time O(N), Space O(1)
1941
+ * @param index - Zero-based index.
1942
+ * @returns Removed element or undefined.
1943
+ * @example
1944
+ * // Remove by index
1945
+ * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
1946
+ * list.deleteAt(1);
1947
+ * console.log(list.toArray()); // ['a', 'c'];
1948
+ */
2888
1949
  deleteAt(index) {
2889
1950
  if (index < 0 || index >= this._length) return;
2890
1951
  if (index === 0) return this.shift();
@@ -2898,55 +1959,16 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2898
1959
  return removedNode.value;
2899
1960
  }
2900
1961
  /**
2901
- * Delete the first match by value/node.
2902
- * @remarks Time O(N), Space O(1)
2903
- * @param [elementOrNode] - Element or node to remove.
2904
- * @returns True if removed.
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
-
2943
-
2944
- * @example
2945
- * // Remove first occurrence
2946
- * const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
2947
- * list.delete(2);
2948
- * console.log(list.toArray()); // [1, 3, 2];
2949
- */
1962
+ * Delete the first match by value/node.
1963
+ * @remarks Time O(N), Space O(1)
1964
+ * @param [elementOrNode] - Element or node to remove.
1965
+ * @returns True if removed.
1966
+ * @example
1967
+ * // Remove first occurrence
1968
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
1969
+ * list.delete(2);
1970
+ * console.log(list.toArray()); // [1, 3, 2];
1971
+ */
2950
1972
  delete(elementOrNode) {
2951
1973
  const node = this.getNode(elementOrNode);
2952
1974
  if (!node) return false;
@@ -2962,161 +1984,42 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2962
1984
  return true;
2963
1985
  }
2964
1986
  /**
2965
- * Check whether the list is empty.
2966
- * @remarks Time O(1), Space O(1)
2967
- * @returns True if length is 0.
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
-
3007
-
3008
- * @example
3009
- * // Check empty
3010
- * console.log(new DoublyLinkedList().isEmpty()); // true;
3011
- */
1987
+ * Check whether the list is empty.
1988
+ * @remarks Time O(1), Space O(1)
1989
+ * @returns True if length is 0.
1990
+ * @example
1991
+ * // Check empty
1992
+ * console.log(new DoublyLinkedList().isEmpty()); // true;
1993
+ */
3012
1994
  isEmpty() {
3013
1995
  return this._length === 0;
3014
1996
  }
3015
1997
  /**
3016
- * Remove all nodes and reset length.
3017
- * @remarks Time O(N), Space O(1)
3018
- * @returns void
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
-
3058
-
3059
- * @example
3060
- * // Remove all
3061
- * const list = new DoublyLinkedList<number>([1, 2]);
3062
- * list.clear();
3063
- * console.log(list.isEmpty()); // true;
3064
- */
1998
+ * Remove all nodes and reset length.
1999
+ * @remarks Time O(N), Space O(1)
2000
+ * @returns void
2001
+ * @example
2002
+ * // Remove all
2003
+ * const list = new DoublyLinkedList<number>([1, 2]);
2004
+ * list.clear();
2005
+ * console.log(list.isEmpty()); // true;
2006
+ */
3065
2007
  clear() {
3066
2008
  this._head = void 0;
3067
2009
  this._tail = void 0;
3068
2010
  this._length = 0;
3069
2011
  }
3070
2012
  /**
3071
- * Find the first value matching a predicate scanning forward.
3072
- * @remarks Time O(N), Space O(1)
3073
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3074
- * @returns Matched value or undefined.
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
-
3113
-
3114
- * @example
3115
- * // Search with predicate
3116
- * const list = new DoublyLinkedList<number>([10, 20, 30]);
3117
- * const found = list.search(node => node.value > 15);
3118
- * console.log(found); // 20;
3119
- */
2013
+ * Find the first value matching a predicate scanning forward.
2014
+ * @remarks Time O(N), Space O(1)
2015
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2016
+ * @returns Matched value or undefined.
2017
+ * @example
2018
+ * // Search with predicate
2019
+ * const list = new DoublyLinkedList<number>([10, 20, 30]);
2020
+ * const found = list.search(node => node.value > 15);
2021
+ * console.log(found); // 20;
2022
+ */
3120
2023
  search(elementNodeOrPredicate) {
3121
2024
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
3122
2025
  let current = this.head;
@@ -3127,53 +2030,17 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3127
2030
  return void 0;
3128
2031
  }
3129
2032
  /**
3130
- * Find the first value matching a predicate scanning backward.
3131
- * @remarks Time O(N), Space O(1)
3132
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3133
- * @returns Matched value or undefined.
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
-
3169
-
3170
- * @example
3171
- * // Find value scanning from tail
3172
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3173
- * // findLast scans from tail to head, returns first match
3174
- * const found = list.findLast(node => node.value < 4);
3175
- * console.log(found); // 3;
3176
- */
2033
+ * Find the first value matching a predicate scanning backward.
2034
+ * @remarks Time O(N), Space O(1)
2035
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2036
+ * @returns Matched value or undefined.
2037
+ * @example
2038
+ * // Find value scanning from tail
2039
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2040
+ * // findLast scans from tail to head, returns first match
2041
+ * const found = list.findLast(node => node.value < 4);
2042
+ * console.log(found); // 3;
2043
+ */
3177
2044
  /**
3178
2045
  * @deprecated Use `findLast` instead. Will be removed in a future major version.
3179
2046
  */
@@ -3181,19 +2048,17 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3181
2048
  return this.findLast(elementNodeOrPredicate);
3182
2049
  }
3183
2050
  /**
3184
- * Find the first value matching a predicate scanning backward (tail → head).
3185
- * @remarks Time O(N), Space O(1)
3186
- * @param elementNodeOrPredicate - Element, node, or predicate to match.
3187
- * @returns Matching value or undefined.
3188
-
3189
-
3190
- * @example
3191
- * // Find value scanning from tail
3192
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3193
- * // findLast scans from tail to head, returns first match
3194
- * const found = list.findLast(node => node.value < 4);
3195
- * console.log(found); // 3;
3196
- */
2051
+ * Find the first value matching a predicate scanning backward (tail → head).
2052
+ * @remarks Time O(N), Space O(1)
2053
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
2054
+ * @returns Matching value or undefined.
2055
+ * @example
2056
+ * // Find value scanning from tail
2057
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2058
+ * // findLast scans from tail to head, returns first match
2059
+ * const found = list.findLast(node => node.value < 4);
2060
+ * console.log(found); // 3;
2061
+ */
3197
2062
  findLast(elementNodeOrPredicate) {
3198
2063
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
3199
2064
  let current = this.tail;
@@ -3220,57 +2085,15 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3220
2085
  return -1;
3221
2086
  }
3222
2087
  /**
3223
- * Reverse the list in place.
3224
- * @remarks Time O(N), Space O(1)
3225
- * @returns This list.
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
-
3267
-
3268
- * @example
3269
- * // Reverse in-place
3270
- * const list = new DoublyLinkedList<number>([1, 2, 3]);
3271
- * list.reverse();
3272
- * console.log([...list]); // [3, 2, 1];
3273
- */
2088
+ * Reverse the list in place.
2089
+ * @remarks Time O(N), Space O(1)
2090
+ * @returns This list.
2091
+ * @example
2092
+ * // Reverse in-place
2093
+ * const list = new DoublyLinkedList<number>([1, 2, 3]);
2094
+ * list.reverse();
2095
+ * console.log([...list]); // [3, 2, 1];
2096
+ */
3274
2097
  reverse() {
3275
2098
  let current = this.head;
3276
2099
  [this._head, this._tail] = [this.tail, this.head];
@@ -3311,115 +2134,33 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3311
2134
  return this;
3312
2135
  }
3313
2136
  /**
3314
- * Deep clone this list (values are copied by reference).
3315
- * @remarks Time O(N), Space O(N)
3316
- * @returns A new list with the same element sequence.
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
-
3356
-
3357
- * @example
3358
- * // Deep copy
3359
- * const list = new DoublyLinkedList<number>([1, 2, 3]);
3360
- * const copy = list.clone();
3361
- * copy.pop();
3362
- * console.log(list.length); // 3;
3363
- */
2137
+ * Deep clone this list (values are copied by reference).
2138
+ * @remarks Time O(N), Space O(N)
2139
+ * @returns A new list with the same element sequence.
2140
+ * @example
2141
+ * // Deep copy
2142
+ * const list = new DoublyLinkedList<number>([1, 2, 3]);
2143
+ * const copy = list.clone();
2144
+ * copy.pop();
2145
+ * console.log(list.length); // 3;
2146
+ */
3364
2147
  clone() {
3365
2148
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
3366
2149
  for (const v of this) out.push(v);
3367
2150
  return out;
3368
2151
  }
3369
2152
  /**
3370
- * Filter values into a new list of the same class.
3371
- * @remarks Time O(N), Space O(N)
3372
- * @param callback - Predicate (value, index, list) → boolean to keep value.
3373
- * @param [thisArg] - Value for `this` inside the callback.
3374
- * @returns A new list with kept values.
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
-
3416
-
3417
- * @example
3418
- * // Filter elements
3419
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
3420
- * const evens = list.filter(n => n % 2 === 0);
3421
- * console.log([...evens]); // [2, 4];
3422
- */
2153
+ * Filter values into a new list of the same class.
2154
+ * @remarks Time O(N), Space O(N)
2155
+ * @param callback - Predicate (value, index, list) → boolean to keep value.
2156
+ * @param [thisArg] - Value for `this` inside the callback.
2157
+ * @returns A new list with kept values.
2158
+ * @example
2159
+ * // Filter elements
2160
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
2161
+ * const evens = list.filter(n => n % 2 === 0);
2162
+ * console.log([...evens]); // [2, 4];
2163
+ */
3423
2164
  filter(callback, thisArg) {
3424
2165
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
3425
2166
  let index = 0;
@@ -3443,71 +2184,29 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3443
2184
  return out;
3444
2185
  }
3445
2186
  /**
3446
- * Map values into a new list (possibly different element type).
3447
- * @remarks Time O(N), Space O(N)
3448
- * @template EM
3449
- * @template RM
3450
- * @param callback - Mapping function (value, index, list) → newElement.
3451
- * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
3452
- * @param [thisArg] - Value for `this` inside the callback.
3453
- * @returns A new DoublyLinkedList with mapped values.
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
-
3495
-
3496
- * @example
3497
- * // DoublyLinkedList for...of iteration and map operation
3498
- * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
3499
- *
3500
- * // Iterate through list
3501
- * const doubled = list.map(value => value * 2);
3502
- * console.log(doubled.length); // 5;
3503
- *
3504
- * // Use for...of loop
3505
- * const result: number[] = [];
3506
- * for (const item of list) {
3507
- * result.push(item);
3508
- * }
3509
- * console.log(result); // [1, 2, 3, 4, 5];
3510
- */
2187
+ * Map values into a new list (possibly different element type).
2188
+ * @remarks Time O(N), Space O(N)
2189
+ * @template EM
2190
+ * @template RM
2191
+ * @param callback - Mapping function (value, index, list) → newElement.
2192
+ * @param [options] - Options for the output list (e.g., maxLen, toElementFn).
2193
+ * @param [thisArg] - Value for `this` inside the callback.
2194
+ * @returns A new DoublyLinkedList with mapped values.
2195
+ * @example
2196
+ * // DoublyLinkedList for...of iteration and map operation
2197
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
2198
+ *
2199
+ * // Iterate through list
2200
+ * const doubled = list.map(value => value * 2);
2201
+ * console.log(doubled.length); // 5;
2202
+ *
2203
+ * // Use for...of loop
2204
+ * const result: number[] = [];
2205
+ * for (const item of list) {
2206
+ * result.push(item);
2207
+ * }
2208
+ * console.log(result); // [1, 2, 3, 4, 5];
2209
+ */
3511
2210
  map(callback, options, thisArg) {
3512
2211
  const out = this._createLike([], { ...options != null ? options : {}, maxLen: this._maxLen });
3513
2212
  let index = 0;
@@ -3796,11 +2495,11 @@ var _comparator, _isDefaultComparator;
3796
2495
  var _SkipList = class _SkipList extends IterableEntryBase {
3797
2496
  constructor(entries = [], options = {}) {
3798
2497
  super();
3799
- __privateAdd(this, _comparator);
3800
- __privateAdd(this, _isDefaultComparator);
3801
2498
  // ─── Internal state ──────────────────────────────────────────
3802
2499
  __publicField(this, "_head");
3803
2500
  __publicField(this, "_level", 0);
2501
+ __privateAdd(this, _comparator);
2502
+ __privateAdd(this, _isDefaultComparator);
3804
2503
  __publicField(this, "_size", 0);
3805
2504
  __publicField(this, "_maxLevel", 16);
3806
2505
  __publicField(this, "_probability", 0.5);
@@ -3824,6 +2523,19 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3824
2523
  this.set(k, v);
3825
2524
  }
3826
2525
  }
2526
+ // ─── Size & lifecycle ────────────────────────────────────────
2527
+ get size() {
2528
+ return this._size;
2529
+ }
2530
+ get maxLevel() {
2531
+ return this._maxLevel;
2532
+ }
2533
+ get probability() {
2534
+ return this._probability;
2535
+ }
2536
+ get comparator() {
2537
+ return __privateGet(this, _comparator);
2538
+ }
3827
2539
  /**
3828
2540
  * Creates a default comparator supporting number, string, Date, and bigint.
3829
2541
  */
@@ -3847,168 +2559,44 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3847
2559
  raise(TypeError, ERR.comparatorRequired("SkipList"));
3848
2560
  };
3849
2561
  }
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 __privateGet(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: __privateGet(this, _isDefaultComparator) ? void 0 : __privateGet(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 = __privateGet(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 = __privateGet(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 = __privateGet(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 = __privateGet(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 = __privateGet(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 = __privateGet(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 != null ? 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: __privateGet(this, _isDefaultComparator) ? void 0 : __privateGet(this, _comparator),