min-priority-queue-typed 2.2.3 → 2.2.6
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.
- package/dist/cjs/index.cjs +0 -36
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +0 -36
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +0 -36
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +0 -36
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +14 -57
- package/dist/types/data-structures/binary-tree/bst.d.ts +151 -117
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +4 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -5
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +5 -5
- package/dist/umd/max-priority-queue-typed.js +0 -33
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/index.ts +2 -4
- package/src/data-structures/base/iterable-entry-base.ts +9 -0
- package/src/data-structures/binary-tree/avl-tree-counter.ts +1 -2
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +9 -8
- package/src/data-structures/binary-tree/avl-tree.ts +4 -5
- package/src/data-structures/binary-tree/binary-tree.ts +67 -0
- package/src/data-structures/binary-tree/bst.ts +724 -108
- package/src/data-structures/binary-tree/red-black-tree.ts +1 -2
- package/src/data-structures/binary-tree/tree-counter.ts +5 -7
- package/src/data-structures/binary-tree/tree-multi-map.ts +7 -8
- package/src/types/data-structures/binary-tree/bst.ts +5 -5
|
@@ -858,6 +858,31 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
858
858
|
return deletedResult;
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
+
search(
|
|
862
|
+
keyNodeEntryOrPredicate:
|
|
863
|
+
| K
|
|
864
|
+
| BinaryTreeNode<K, V>
|
|
865
|
+
| [K | null | undefined, V | undefined]
|
|
866
|
+
| null
|
|
867
|
+
| undefined
|
|
868
|
+
| NodePredicate<BinaryTreeNode<K, V> | null>,
|
|
869
|
+
onlyOne?: boolean
|
|
870
|
+
): (K | undefined)[];
|
|
871
|
+
|
|
872
|
+
search<C extends NodeCallback<BinaryTreeNode<K, V> | null>>(
|
|
873
|
+
keyNodeEntryOrPredicate:
|
|
874
|
+
| K
|
|
875
|
+
| BinaryTreeNode<K, V>
|
|
876
|
+
| [K | null | undefined, V | undefined]
|
|
877
|
+
| null
|
|
878
|
+
| undefined
|
|
879
|
+
| NodePredicate<BinaryTreeNode<K, V> | null>,
|
|
880
|
+
onlyOne: boolean,
|
|
881
|
+
callback: C,
|
|
882
|
+
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
883
|
+
iterationType?: IterationType
|
|
884
|
+
): ReturnType<C>[];
|
|
885
|
+
|
|
861
886
|
/**
|
|
862
887
|
* Searches the tree for nodes matching a predicate.
|
|
863
888
|
* @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Performs a full DFS (pre-order) scan of the tree. Time O(N), as it may visit every node. Space O(H) for the call stack (recursive) or explicit stack (iterative), where H is the tree height (O(N) worst-case).
|
|
@@ -1245,6 +1270,16 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1245
1270
|
}
|
|
1246
1271
|
}
|
|
1247
1272
|
|
|
1273
|
+
getPathToRoot(
|
|
1274
|
+
beginNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined
|
|
1275
|
+
): (K | undefined)[];
|
|
1276
|
+
|
|
1277
|
+
getPathToRoot<C extends NodeCallback<BinaryTreeNode<K, V> | undefined>>(
|
|
1278
|
+
beginNode: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
1279
|
+
callback: C,
|
|
1280
|
+
isReverse?: boolean
|
|
1281
|
+
): ReturnType<C>[];
|
|
1282
|
+
|
|
1248
1283
|
/**
|
|
1249
1284
|
* Gets the path from a given node up to the root.
|
|
1250
1285
|
* @remarks Time O(H), where H is the depth of the `beginNode`. O(N) worst-case. Space O(H) for the result array.
|
|
@@ -1273,6 +1308,14 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1273
1308
|
return isReverse ? result.reverse() : result;
|
|
1274
1309
|
}
|
|
1275
1310
|
|
|
1311
|
+
getLeftMost(): K | undefined;
|
|
1312
|
+
|
|
1313
|
+
getLeftMost<C extends NodeCallback<BinaryTreeNode<K, V> | undefined>>(
|
|
1314
|
+
callback: C,
|
|
1315
|
+
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
1316
|
+
iterationType?: IterationType
|
|
1317
|
+
): ReturnType<C>;
|
|
1318
|
+
|
|
1276
1319
|
/**
|
|
1277
1320
|
* Finds the leftmost node in a subtree (the node with the smallest key in a BST).
|
|
1278
1321
|
* @remarks Time O(H), where H is the height of the left spine. O(N) worst-case. Space O(H) for recursive/trampoline stack.
|
|
@@ -1312,6 +1355,14 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1312
1355
|
}
|
|
1313
1356
|
}
|
|
1314
1357
|
|
|
1358
|
+
getRightMost(): K | undefined;
|
|
1359
|
+
|
|
1360
|
+
getRightMost<C extends NodeCallback<BinaryTreeNode<K, V> | undefined>>(
|
|
1361
|
+
callback: C,
|
|
1362
|
+
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
1363
|
+
iterationType?: IterationType
|
|
1364
|
+
): ReturnType<C>;
|
|
1365
|
+
|
|
1315
1366
|
/**
|
|
1316
1367
|
* Finds the rightmost node in a subtree (the node with the largest key in a BST).
|
|
1317
1368
|
* @remarks Time O(H), where H is the height of the right spine. O(N) worst-case. Space O(H) for recursive/trampoline stack.
|
|
@@ -1394,6 +1445,8 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1394
1445
|
return y;
|
|
1395
1446
|
}
|
|
1396
1447
|
|
|
1448
|
+
dfs(): (K | undefined)[];
|
|
1449
|
+
|
|
1397
1450
|
dfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(
|
|
1398
1451
|
callback?: C,
|
|
1399
1452
|
pattern?: DFSOrderPattern,
|
|
@@ -1437,6 +1490,8 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1437
1490
|
return this._dfs(callback, pattern, onlyOne, startNode, iterationType, includeNull);
|
|
1438
1491
|
}
|
|
1439
1492
|
|
|
1493
|
+
bfs(): (K | undefined)[];
|
|
1494
|
+
|
|
1440
1495
|
bfs<C extends NodeCallback<BinaryTreeNode<K, V>>>(
|
|
1441
1496
|
callback?: C,
|
|
1442
1497
|
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
@@ -1519,6 +1574,14 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1519
1574
|
return ans;
|
|
1520
1575
|
}
|
|
1521
1576
|
|
|
1577
|
+
leaves(): (K | undefined)[];
|
|
1578
|
+
|
|
1579
|
+
leaves<C extends NodeCallback<BinaryTreeNode<K, V>>>(
|
|
1580
|
+
callback: C,
|
|
1581
|
+
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
1582
|
+
iterationType?: IterationType
|
|
1583
|
+
): ReturnType<C>[];
|
|
1584
|
+
|
|
1522
1585
|
/**
|
|
1523
1586
|
* Finds all leaf nodes in the tree.
|
|
1524
1587
|
* @remarks Time O(N), visits every node. Space O(H) for recursive stack or O(N) for iterative queue.
|
|
@@ -1570,6 +1633,8 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1570
1633
|
return leaves;
|
|
1571
1634
|
}
|
|
1572
1635
|
|
|
1636
|
+
listLevels(): (K | undefined)[][];
|
|
1637
|
+
|
|
1573
1638
|
listLevels<C extends NodeCallback<BinaryTreeNode<K, V>>>(
|
|
1574
1639
|
callback?: C,
|
|
1575
1640
|
startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined,
|
|
@@ -1645,6 +1710,8 @@ export class BinaryTree<K = any, V = any, R = any>
|
|
|
1645
1710
|
return levelsNodes;
|
|
1646
1711
|
}
|
|
1647
1712
|
|
|
1713
|
+
morris(): (K | undefined)[];
|
|
1714
|
+
|
|
1648
1715
|
morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(
|
|
1649
1716
|
callback?: C,
|
|
1650
1717
|
pattern?: DFSOrderPattern,
|