stack-typed 1.48.8 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  * @license MIT License
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ObjectDeque = exports.Deque = void 0;
10
+ exports.Deque = void 0;
11
11
  const utils_1 = require("../../utils");
12
12
  const base_1 = require("../base");
13
13
  /**
@@ -792,174 +792,3 @@ class Deque extends base_1.IterableElementBase {
792
792
  }
793
793
  }
794
794
  exports.Deque = Deque;
795
- // O(1) time complexity of obtaining the element
796
- // O(n) time complexity of adding at the beginning and the end
797
- // todo tested slowest one
798
- class ObjectDeque {
799
- constructor(capacity) {
800
- this._nodes = {};
801
- this._capacity = Number.MAX_SAFE_INTEGER;
802
- this._first = -1;
803
- this._last = -1;
804
- this._size = 0;
805
- if (capacity !== undefined)
806
- this._capacity = capacity;
807
- }
808
- get nodes() {
809
- return this._nodes;
810
- }
811
- get capacity() {
812
- return this._capacity;
813
- }
814
- get first() {
815
- return this._first;
816
- }
817
- get last() {
818
- return this._last;
819
- }
820
- get size() {
821
- return this._size;
822
- }
823
- /**
824
- * Time Complexity: O(1)
825
- * Space Complexity: O(1)
826
- */
827
- /**
828
- * Time Complexity: O(1)
829
- * Space Complexity: O(1)
830
- *
831
- * The "addFirst" function adds an element to the beginning of an array-like data structure.
832
- * @param {E} element - The `element` parameter represents the element that you want to add to the beginning of the data
833
- * structure.
834
- */
835
- addFirst(element) {
836
- if (this.size === 0) {
837
- const mid = Math.floor(this.capacity / 2);
838
- this._first = mid;
839
- this._last = mid;
840
- }
841
- else {
842
- this._first--;
843
- }
844
- this.nodes[this.first] = element;
845
- this._size++;
846
- }
847
- /**
848
- * Time Complexity: O(1)
849
- * Space Complexity: O(1)
850
- */
851
- /**
852
- * Time Complexity: O(1)
853
- * Space Complexity: O(1)
854
- *
855
- * The addLast function adds an element to the end of an array-like data structure.
856
- * @param {E} element - The `element` parameter represents the element that you want to add to the end of the data structure.
857
- */
858
- addLast(element) {
859
- if (this.size === 0) {
860
- const mid = Math.floor(this.capacity / 2);
861
- this._first = mid;
862
- this._last = mid;
863
- }
864
- else {
865
- this._last++;
866
- }
867
- this.nodes[this.last] = element;
868
- this._size++;
869
- }
870
- /**
871
- * Time Complexity: O(1)
872
- * Space Complexity: O(1)
873
- */
874
- /**
875
- * Time Complexity: O(1)
876
- * Space Complexity: O(1)
877
- *
878
- * The function `pollFirst()` removes and returns the first element in a data structure.
879
- * @returns The element of the first element in the data structure.
880
- */
881
- pollFirst() {
882
- if (!this.size)
883
- return;
884
- const element = this.getFirst();
885
- delete this.nodes[this.first];
886
- this._first++;
887
- this._size--;
888
- return element;
889
- }
890
- /**
891
- * Time Complexity: O(1)
892
- * Space Complexity: O(1)
893
- */
894
- /**
895
- * Time Complexity: O(1)
896
- * Space Complexity: O(1)
897
- *
898
- * The `getFirst` function returns the first element in an array-like data structure if it exists.
899
- * @returns The element at the first position of the `_nodes` array.
900
- */
901
- getFirst() {
902
- if (this.size)
903
- return this.nodes[this.first];
904
- }
905
- /**
906
- * Time Complexity: O(1)
907
- * Space Complexity: O(1)
908
- */
909
- /**
910
- * Time Complexity: O(1)
911
- * Space Complexity: O(1)
912
- *
913
- * The `pollLast()` function removes and returns the last element in a data structure.
914
- * @returns The element that was removed from the data structure.
915
- */
916
- pollLast() {
917
- if (!this.size)
918
- return;
919
- const element = this.getLast();
920
- delete this.nodes[this.last];
921
- this._last--;
922
- this._size--;
923
- return element;
924
- }
925
- /**
926
- * Time Complexity: O(1)
927
- * Space Complexity: O(1)
928
- */
929
- /**
930
- * Time Complexity: O(1)
931
- * Space Complexity: O(1)
932
- *
933
- * The `getLast()` function returns the last element in an array-like data structure.
934
- * @returns The last element in the array "_nodes" is being returned.
935
- */
936
- getLast() {
937
- if (this.size)
938
- return this.nodes[this.last];
939
- }
940
- /**
941
- * Time Complexity: O(1)
942
- * Space Complexity: O(1)
943
- */
944
- /**
945
- * Time Complexity: O(1)
946
- * Space Complexity: O(1)
947
- *
948
- * The get function returns the element at the specified index in an array-like data structure.
949
- * @param {number} index - The index parameter is a number that represents the position of the element you want to
950
- * retrieve from the array.
951
- * @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that
952
- * index, `undefined` is returned.
953
- */
954
- get(index) {
955
- return this.nodes[this.first + index] || undefined;
956
- }
957
- /**
958
- * The function checks if the size of a data structure is less than or equal to zero.
959
- * @returns The method is returning a boolean element indicating whether the size of the object is less than or equal to 0.
960
- */
961
- isEmpty() {
962
- return this.size <= 0;
963
- }
964
- }
965
- exports.ObjectDeque = ObjectDeque;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stack-typed",
3
- "version": "1.48.8",
3
+ "version": "1.49.0",
4
4
  "description": "Stack. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -65,6 +65,6 @@
65
65
  "typescript": "^4.9.5"
66
66
  },
67
67
  "dependencies": {
68
- "data-structure-typed": "^1.48.8"
68
+ "data-structure-typed": "^1.48.9"
69
69
  }
70
70
  }
@@ -14,7 +14,7 @@ import type {
14
14
  BSTNodeKeyOrNode,
15
15
  BTNodeExemplar
16
16
  } from '../../types';
17
- import { BTNCallback } from '../../types';
17
+ import { BTNCallback, BTNodeKeyOrNode } from '../../types';
18
18
  import { IBinaryTree } from '../../interfaces';
19
19
 
20
20
  export class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {
@@ -90,6 +90,16 @@ export class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeN
90
90
  return exemplar instanceof AVLTreeNode;
91
91
  }
92
92
 
93
+ /**
94
+ * The function "isNotNodeInstance" checks if a potential key is a K.
95
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
96
+ * data type.
97
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
98
+ */
99
+ override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
100
+ return !(potentialKey instanceof AVLTreeNode)
101
+ }
102
+
93
103
  /**
94
104
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
95
105
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -98,10 +98,6 @@ export class BinaryTreeNode<K = any, V = any, N extends BinaryTreeNode<K, V, N>
98
98
  * 3. Depth and Height: Depth is the number of edges from the root to a node; height is the maximum depth in the tree.
99
99
  * 4. Subtrees: Each child of a node forms the root of a subtree.
100
100
  * 5. Leaf Nodes: Nodes without children are leaves.
101
- * 6. Internal Nodes: Nodes with at least one child are internal.
102
- * 7. Balanced Trees: The heights of the left and right subtrees of any node differ by no more than one.
103
- * 8. Full Trees: Every node has either 0 or 2 children.
104
- * 9. Complete Trees: All levels are fully filled except possibly the last, filled from left to right.
105
101
  */
106
102
 
107
103
  export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTree<K, V, N, BinaryTreeNested<K, V, N>>> extends IterableEntryBase<K, V | undefined>
@@ -231,7 +227,6 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
231
227
  * Space Complexity O(1)
232
228
  */
233
229
 
234
-
235
230
  /**
236
231
  * Time Complexity O(log n) - O(n)
237
232
  * Space Complexity O(1)
@@ -243,50 +238,65 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
243
238
  * @returns The function `add` returns either a node (`N`), `null`, or `undefined`.
244
239
  */
245
240
  add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V): N | null | undefined {
246
-
247
- let inserted: N | null | undefined;
248
241
  const newNode = this.exemplarToNode(keyOrNodeOrEntry, value);
249
242
  if (newNode === undefined) return;
250
243
 
251
- // TODO There are still some problems with the way duplicate nodes are handled
252
- if (newNode !== null && this.has(newNode.key)) return undefined;
244
+ // If the tree is empty, directly set the new node as the root node
245
+ if (!this.root) {
246
+ this._root = newNode;
247
+ this._size = 1;
248
+ return newNode;
249
+ }
253
250
 
254
- const _bfs = (root: N, newNode: N | null): N | undefined | null => {
255
- const queue = new Queue<N>([root]);
256
- while (queue.size > 0) {
257
- const cur = queue.shift()!;
258
- if (newNode && cur.key === newNode.key) {
259
- this._replaceNode(cur, newNode);
260
- return newNode;
261
- }
262
- const inserted = this._addTo(newNode, cur);
263
- if (inserted !== undefined) return inserted;
264
- if (cur.left) queue.push(cur.left);
265
- if (cur.right) queue.push(cur.right);
251
+ const queue = new Queue<N>([this.root]);
252
+ let potentialParent: N | undefined; // Record the parent node of the potential insertion location
253
+
254
+ while (queue.size > 0) {
255
+ const cur = queue.shift();
256
+
257
+ if (!cur) continue;
258
+
259
+ // Check for duplicate keys when newNode is not null
260
+ if (newNode !== null && cur.key === newNode.key) {
261
+ this._replaceNode(cur, newNode);
262
+ return newNode; // If duplicate keys are found, no insertion is performed
266
263
  }
267
- };
268
264
 
269
- if (this.root) {
270
- inserted = _bfs(this.root, newNode);
271
- } else {
272
- this._setRoot(newNode);
273
- if (newNode) {
274
- this._size = 1;
275
- } else {
276
- this._size = 0;
265
+ // Record the first possible insertion location found
266
+ if (potentialParent === undefined && (cur.left === undefined || cur.right === undefined)) {
267
+ potentialParent = cur;
268
+ }
269
+
270
+ // Continue traversing the left and right subtrees
271
+ if (cur.left !== null) {
272
+ cur.left && queue.push(cur.left);
273
+ }
274
+ if (cur.right !== null) {
275
+ cur.right && queue.push(cur.right);
277
276
  }
278
- inserted = this.root;
279
277
  }
280
- return inserted;
278
+
279
+ // At the end of the traversal, if the insertion position is found, insert
280
+ if (potentialParent) {
281
+ if (potentialParent.left === undefined) {
282
+ potentialParent.left = newNode;
283
+ } else if (potentialParent.right === undefined) {
284
+ potentialParent.right = newNode;
285
+ }
286
+ this._size++;
287
+ return newNode;
288
+ }
289
+
290
+ return undefined; // If the insertion position cannot be found, return undefined
281
291
  }
282
292
 
293
+
283
294
  /**
284
295
  * Time Complexity: O(k log n) - O(k * n)
285
296
  * Space Complexity: O(1)
286
297
  * Comments: The time complexity for adding a node depends on the depth of the tree. In the best case (when the tree is empty), it's O(1). In the worst case (when the tree is a degenerate tree), it's O(n). The space complexity is constant.
287
298
  */
288
299
 
289
-
290
300
  /**
291
301
  * Time Complexity: O(k log n) - O(k * n)
292
302
  * Space Complexity: O(1)
@@ -1226,8 +1236,8 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
1226
1236
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
1227
1237
  * @returns a boolean value.
1228
1238
  */
1229
- isRealNode(node: any): node is N {
1230
- return node instanceof BinaryTreeNode && node.key.toString() !== 'NaN';
1239
+ isRealNode(node: BTNodeExemplar<K, V, N>): node is N {
1240
+ return node instanceof BinaryTreeNode && String(node.key) !== 'NaN';
1231
1241
  }
1232
1242
 
1233
1243
  /**
@@ -1235,8 +1245,8 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
1235
1245
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
1236
1246
  * @returns a boolean value.
1237
1247
  */
1238
- isNIL(node: any) {
1239
- return node instanceof BinaryTreeNode && node.key.toString() === 'NaN';
1248
+ isNIL(node: BTNodeExemplar<K, V, N>) {
1249
+ return node instanceof BinaryTreeNode && String(node.key) === 'NaN';
1240
1250
  }
1241
1251
 
1242
1252
  /**
@@ -1244,12 +1254,12 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
1244
1254
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
1245
1255
  * @returns a boolean value.
1246
1256
  */
1247
- isNodeOrNull(node: any): node is N | null {
1257
+ isNodeOrNull(node: BTNodeExemplar<K, V, N>): node is N | null {
1248
1258
  return this.isRealNode(node) || node === null;
1249
1259
  }
1250
1260
 
1251
1261
  /**
1252
- * The function "isNotNodeInstance" checks if a potential key is a number.
1262
+ * The function "isNotNodeInstance" checks if a potential key is a K.
1253
1263
  * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
1254
1264
  * data type.
1255
1265
  * @returns a boolean value indicating whether the potentialKey is of type number or not.
@@ -1596,26 +1606,24 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
1596
1606
  }
1597
1607
 
1598
1608
  /**
1599
- * Time complexity: O(n)
1600
- * Space complexity: O(n)
1609
+ * Time Complexity: O(log n)
1610
+ * Space Complexity: O(1)
1601
1611
  */
1602
1612
 
1603
- getPredecessor(node: N): N;
1604
-
1605
1613
  /**
1606
- * The function `getPredecessor` returns the predecessor node of a given node in a binary tree.
1607
- * @param {K | N | null | undefined} node - The `node` parameter can be of type `K`, `N`,
1608
- * `null`, or `undefined`.
1609
- * @returns The function `getPredecessor` returns a value of type `N | undefined`.
1614
+ * Time Complexity: O(log n)
1615
+ * Space Complexity: O(1)
1616
+ *
1617
+ * The function returns the predecessor of a given node in a tree.
1618
+ * @param {N} node - The parameter `node` is of type `RedBlackTreeNode`, which represents a node in a
1619
+ * tree.
1620
+ * @returns the predecessor of the given 'node'.
1610
1621
  */
1611
- getPredecessor(node: BTNodeKeyOrNode<K, N>): N | undefined {
1612
- node = this.ensureNode(node);
1613
- if (!this.isRealNode(node)) return undefined;
1614
-
1615
- if (node.left) {
1622
+ getPredecessor(node: N): N {
1623
+ if (this.isRealNode(node.left)) {
1616
1624
  let predecessor: N | null | undefined = node.left;
1617
1625
  while (!this.isRealNode(predecessor) || (this.isRealNode(predecessor.right) && predecessor.right !== node)) {
1618
- if (predecessor) {
1626
+ if (this.isRealNode(predecessor)) {
1619
1627
  predecessor = predecessor.right;
1620
1628
  }
1621
1629
  }
@@ -1632,15 +1640,16 @@ export class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = Bi
1632
1640
  * after the given node in the inorder traversal of the binary tree.
1633
1641
  */
1634
1642
  getSuccessor(x?: K | N | null): N | null | undefined {
1643
+
1635
1644
  x = this.ensureNode(x);
1636
- if (!x) return undefined;
1645
+ if (!this.isRealNode(x)) return undefined;
1637
1646
 
1638
- if (x.right) {
1647
+ if (this.isRealNode(x.right)) {
1639
1648
  return this.getLeftMost(x.right);
1640
1649
  }
1641
1650
 
1642
1651
  let y: N | null | undefined = x.parent;
1643
- while (y && y && x === y.right) {
1652
+ while (this.isRealNode(y) && x === y.right) {
1644
1653
  x = y;
1645
1654
  y = y.parent;
1646
1655
  }
@@ -14,7 +14,7 @@ import type {
14
14
  BTNodeExemplar,
15
15
  BTNodePureExemplar
16
16
  } from '../../types';
17
- import { BSTVariant, CP, IterationType } from '../../types';
17
+ import { BSTVariant, BTNodeKeyOrNode, CP, IterationType } from '../../types';
18
18
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
19
19
  import { IBinaryTree } from '../../interfaces';
20
20
  import { Queue } from '../queue';
@@ -442,6 +442,16 @@ export class BST<K = any, V = any, N extends BSTNode<K, V, N> = BSTNode<K, V, BS
442
442
  }
443
443
  }
444
444
 
445
+ /**
446
+ * The function "isNotNodeInstance" checks if a potential key is a K.
447
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
448
+ * data type.
449
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
450
+ */
451
+ override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
452
+ return !(potentialKey instanceof BSTNode)
453
+ }
454
+
445
455
  /**
446
456
  * Time Complexity: O(log n) - Average case for a balanced tree.
447
457
  * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.
@@ -11,6 +11,7 @@ import {
11
11
  BSTNodeKeyOrNode,
12
12
  BTNCallback,
13
13
  BTNodeExemplar,
14
+ BTNodeKeyOrNode,
14
15
  IterationType,
15
16
  RBTNColor,
16
17
  RBTreeOptions,
@@ -115,6 +116,16 @@ export class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K, V, N>
115
116
  return exemplar instanceof RedBlackTreeNode;
116
117
  }
117
118
 
119
+ /**
120
+ * The function "isNotNodeInstance" checks if a potential key is a K.
121
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
122
+ * data type.
123
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
124
+ */
125
+ override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
126
+ return !(potentialKey instanceof RedBlackTreeNode)
127
+ }
128
+
118
129
  /**
119
130
  * The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.
120
131
  * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:
@@ -300,7 +311,8 @@ export class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K, V, N>
300
311
  */
301
312
 
302
313
  override isRealNode(node: N | undefined): node is N {
303
- return node !== this.Sentinel && node !== undefined;
314
+ if (node === this.Sentinel || node === undefined) return false;
315
+ return node instanceof RedBlackTreeNode;
304
316
  }
305
317
 
306
318
  getNode<C extends BTNCallback<N, K>>(
@@ -362,38 +374,12 @@ export class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K, V, N>
362
374
  }
363
375
 
364
376
  /**
365
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
366
- * Space Complexity: O(1)
367
- */
368
-
369
- /**
370
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
371
- * Space Complexity: O(1)
372
- *
373
- * The function returns the successor of a given node in a red-black tree.
374
- * @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
375
- * @returns the successor of the given RedBlackTreeNode.
376
- */
377
- override getSuccessor(x: N): N | undefined {
378
- if (x.right !== this.Sentinel) {
379
- return this.getLeftMost(x.right) ?? undefined;
380
- }
381
-
382
- let y: N | undefined = x.parent;
383
- while (y !== this.Sentinel && y !== undefined && x === y.right) {
384
- x = y;
385
- y = y.parent;
386
- }
387
- return y;
388
- }
389
-
390
- /**
391
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
377
+ * Time Complexity: O(log n)
392
378
  * Space Complexity: O(1)
393
379
  */
394
380
 
395
381
  /**
396
- * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
382
+ * Time Complexity: O(log n)
397
383
  * Space Complexity: O(1)
398
384
  *
399
385
  * The function returns the predecessor of a given node in a red-black tree.
@@ -402,12 +388,12 @@ export class RedBlackTree<K = any, V = any, N extends RedBlackTreeNode<K, V, N>
402
388
  * @returns the predecessor of the given RedBlackTreeNode 'x'.
403
389
  */
404
390
  override getPredecessor(x: N): N {
405
- if (x.left !== this.Sentinel) {
406
- return this.getRightMost(x.left!)!;
391
+ if (this.isRealNode(x.left)) {
392
+ return this.getRightMost(x.left)!;
407
393
  }
408
394
 
409
395
  let y: N | undefined = x.parent;
410
- while (y !== this.Sentinel && x === y!.left) {
396
+ while (this.isRealNode(y) && x === y.left) {
411
397
  x = y!;
412
398
  y = y!.parent;
413
399
  }
@@ -6,7 +6,14 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
9
- import { BiTreeDeleteResult, BTNCallback, FamilyPosition, IterationType, TreeMultimapNested } from '../../types';
9
+ import {
10
+ BiTreeDeleteResult,
11
+ BTNCallback,
12
+ BTNodeKeyOrNode,
13
+ FamilyPosition,
14
+ IterationType,
15
+ TreeMultimapNested
16
+ } from '../../types';
10
17
  import { IBinaryTree } from '../../interfaces';
11
18
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
19
 
@@ -85,6 +92,15 @@ export class TreeMultimap<K = any, V = any, N extends TreeMultimapNode<K, V, N>
85
92
  return exemplar instanceof TreeMultimapNode;
86
93
  }
87
94
 
95
+ /**
96
+ * The function "isNotNodeInstance" checks if a potential key is a K.
97
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
98
+ * data type.
99
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
100
+ */
101
+ override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
102
+ return !(potentialKey instanceof TreeMultimapNode)
103
+ }
88
104
 
89
105
  /**
90
106
  * The function `exemplarToNode` converts an exemplar object into a node object.