data-structure-typed 1.51.8 → 1.51.9
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/CHANGELOG.md +1 -1
- package/README.md +13 -13
- package/benchmark/report.html +1 -37
- package/benchmark/report.json +13 -385
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +104 -66
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +80 -60
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +78 -59
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +316 -224
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +471 -361
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +198 -200
- package/dist/cjs/data-structures/binary-tree/bst.js +215 -249
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +71 -72
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +107 -98
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +90 -73
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -93
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +10 -15
- package/dist/cjs/data-structures/graph/abstract-graph.js +10 -15
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +31 -38
- package/dist/cjs/data-structures/hash/hash-map.js +40 -55
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +2 -3
- package/dist/cjs/data-structures/queue/deque.js +2 -3
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +1 -1
- package/dist/cjs/data-structures/trie/trie.js +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +6 -6
- package/dist/cjs/types/common.d.ts +1 -2
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -2
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -4
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -3
- package/dist/cjs/utils/utils.js +3 -5
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +104 -66
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +80 -60
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +78 -59
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +316 -224
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +472 -362
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +198 -200
- package/dist/mjs/data-structures/binary-tree/bst.js +219 -255
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +71 -72
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +107 -98
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +90 -73
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +105 -93
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +10 -15
- package/dist/mjs/data-structures/graph/abstract-graph.js +10 -15
- package/dist/mjs/data-structures/hash/hash-map.d.ts +31 -38
- package/dist/mjs/data-structures/hash/hash-map.js +41 -55
- package/dist/mjs/data-structures/queue/deque.d.ts +2 -3
- package/dist/mjs/data-structures/queue/deque.js +2 -3
- package/dist/mjs/data-structures/trie/trie.d.ts +1 -1
- package/dist/mjs/data-structures/trie/trie.js +1 -1
- package/dist/mjs/interfaces/binary-tree.d.ts +6 -6
- package/dist/mjs/types/common.d.ts +1 -2
- package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -2
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -4
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +4 -4
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -3
- package/dist/mjs/utils/utils.js +3 -5
- package/dist/umd/data-structure-typed.js +1340 -1181
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +6 -6
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +142 -92
- package/src/data-structures/binary-tree/avl-tree.ts +94 -66
- package/src/data-structures/binary-tree/binary-tree.ts +530 -398
- package/src/data-structures/binary-tree/bst.ts +251 -270
- package/src/data-structures/binary-tree/rb-tree.ts +121 -100
- package/src/data-structures/binary-tree/tree-multi-map.ts +125 -99
- package/src/data-structures/graph/abstract-graph.ts +10 -10
- package/src/data-structures/hash/hash-map.ts +42 -49
- package/src/data-structures/queue/deque.ts +2 -2
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/data-structures/trie/trie.ts +2 -2
- package/src/interfaces/binary-tree.ts +8 -7
- package/src/types/common.ts +1 -2
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -2
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +5 -4
- package/src/types/data-structures/binary-tree/bst.ts +4 -4
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -3
- package/src/utils/utils.ts +3 -3
- package/test/integration/avl-tree.test.ts +2 -2
- package/test/integration/bst.test.ts +3 -3
- package/test/integration/index.html +25 -11
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +68 -0
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -0
- package/test/unit/data-structures/graph/directed-graph.test.ts +2 -2
- package/test/utils/big-o.ts +12 -6
- package/tsconfig-base.json +1 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BST, BSTNode } from '../../../data-structures';
|
|
2
2
|
import type { BinaryTreeOptions } from './binary-tree';
|
|
3
|
-
import { Comparator } from
|
|
4
|
-
import { Comparable } from
|
|
3
|
+
import { Comparator } from '../../common';
|
|
4
|
+
import { Comparable } from '../../utils';
|
|
5
5
|
export type BSTNodeNested<K extends Comparable, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
|
-
export type BSTNested<K extends Comparable, V,
|
|
7
|
-
export type BSTOptions<K> = BinaryTreeOptions & {
|
|
6
|
+
export type BSTNested<K extends Comparable, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
7
|
+
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
|
|
8
8
|
comparator?: Comparator<K>;
|
|
9
9
|
};
|
|
@@ -3,5 +3,5 @@ import type { BSTOptions } from "./bst";
|
|
|
3
3
|
import { Comparable } from "../../utils";
|
|
4
4
|
export type RBTNColor = 'RED' | 'BLACK';
|
|
5
5
|
export type RedBlackTreeNodeNested<K extends Comparable, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
|
-
export type RedBlackTreeNested<K extends Comparable, V,
|
|
7
|
-
export type RBTreeOptions<K> = BSTOptions<K> & {};
|
|
6
|
+
export type RedBlackTreeNested<K extends Comparable, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
7
|
+
export type RBTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
|
|
2
2
|
import type { RBTreeOptions } from './rb-tree';
|
|
3
|
-
import { Comparable } from
|
|
3
|
+
import { Comparable } from '../../utils';
|
|
4
4
|
export type TreeMultiMapNodeNested<K extends Comparable, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
|
-
export type TreeMultiMapNested<K extends Comparable, V,
|
|
6
|
-
export type TreeMultiMapOptions<K> = RBTreeOptions<K> & {};
|
|
5
|
+
export type TreeMultiMapNested<K extends Comparable, V, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
|
+
export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {};
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -95,7 +95,7 @@ exports.roundFixed = roundFixed;
|
|
|
95
95
|
function isComparable(key) {
|
|
96
96
|
const keyType = typeof key;
|
|
97
97
|
if (keyType === 'number')
|
|
98
|
-
return isNaN(key);
|
|
98
|
+
return !isNaN(key);
|
|
99
99
|
if (keyType === 'string')
|
|
100
100
|
return true;
|
|
101
101
|
if (keyType === 'bigint')
|
|
@@ -111,10 +111,8 @@ function isComparable(key) {
|
|
|
111
111
|
if (keyType === 'object') {
|
|
112
112
|
if (key === null)
|
|
113
113
|
return true;
|
|
114
|
-
if (typeof key.valueOf === 'function')
|
|
115
|
-
|
|
116
|
-
if (typeof key.toString === 'function')
|
|
117
|
-
return isComparable(key.toString());
|
|
114
|
+
// if (typeof key.valueOf === 'function') return isComparable(key.valueOf()); // This will keep recursing because every object has a valueOf method.
|
|
115
|
+
// if (typeof key.toString === 'function') return isComparable(key.toString()); // This will also keep recursing because every string type has a toString method.
|
|
118
116
|
return false;
|
|
119
117
|
}
|
|
120
118
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AASO,MAAM,MAAM,GAAG;IACpB,OAAO,sCAAsC,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC;QACvE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAChC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QACrC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC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,6 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry } from '../../types';
|
|
9
|
+
import { BTNEntry } from '../../types';
|
|
9
10
|
import { IBinaryTree } from '../../interfaces';
|
|
10
11
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
11
12
|
export declare class AVLTreeMultiMapNode<K extends Comparable, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNodeNested<K, V>> extends AVLTreeNode<K, V, NODE> {
|
|
@@ -36,8 +37,16 @@ export declare class AVLTreeMultiMapNode<K extends Comparable, V = any, NODE ext
|
|
|
36
37
|
/**
|
|
37
38
|
* The only distinction between a AVLTreeMultiMap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
38
39
|
*/
|
|
39
|
-
export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, NODE, TREE> = AVLTreeMultiMap<K, V, NODE, AVLTreeMultiMapNested<K, V, NODE>>> extends AVLTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
|
|
40
|
-
|
|
40
|
+
export declare class AVLTreeMultiMap<K extends Comparable, V = any, R = BTNEntry<K, V>, NODE extends AVLTreeMultiMapNode<K, V, NODE> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNodeNested<K, V>>, TREE extends AVLTreeMultiMap<K, V, R, NODE, TREE> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMapNested<K, V, R, NODE>>> extends AVLTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
|
|
41
|
+
/**
|
|
42
|
+
* The constructor initializes a new AVLTreeMultiMap object with optional initial elements.
|
|
43
|
+
* @param keysOrNodesOrEntriesOrRawElements - The `keysOrNodesOrEntriesOrRawElements` parameter is an
|
|
44
|
+
* iterable object that can contain either keys, nodes, entries, or raw elements.
|
|
45
|
+
* @param [options] - The `options` parameter is an optional object that can be used to customize the
|
|
46
|
+
* behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
|
|
47
|
+
* `compareValues` functions to define custom comparison logic for keys and values, respectively.
|
|
48
|
+
*/
|
|
49
|
+
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
|
|
41
50
|
protected _count: number;
|
|
42
51
|
/**
|
|
43
52
|
* The function calculates the sum of the count property of all nodes in a tree using depth-first
|
|
@@ -59,35 +68,46 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
59
68
|
*/
|
|
60
69
|
getComputedCount(): number;
|
|
61
70
|
/**
|
|
62
|
-
* The function creates a new
|
|
63
|
-
* @param {K} key - The key parameter
|
|
64
|
-
*
|
|
65
|
-
* @param {
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
71
|
+
* The function creates a new AVLTreeMultiMapNode with the specified key, value, and count.
|
|
72
|
+
* @param {K} key - The key parameter represents the key of the node being created. It is of type K,
|
|
73
|
+
* which is a generic type that can be replaced with any specific type when using the function.
|
|
74
|
+
* @param {V} [value] - The `value` parameter is an optional parameter that represents the value
|
|
75
|
+
* associated with the key in the node. It is of type `V`, which can be any data type.
|
|
76
|
+
* @param {number} [count] - The `count` parameter represents the number of occurrences of a
|
|
77
|
+
* key-value pair in the AVLTreeMultiMapNode. It is an optional parameter, so it can be omitted when
|
|
78
|
+
* calling the `createNode` method. If provided, it specifies the initial count for the node.
|
|
79
|
+
* @returns a new instance of the AVLTreeMultiMapNode class, casted as NODE.
|
|
69
80
|
*/
|
|
70
81
|
createNode(key: K, value?: V, count?: number): NODE;
|
|
71
|
-
createTree(options?: AVLTreeMultiMapOptions<K>): TREE;
|
|
72
|
-
/**
|
|
73
|
-
* The function `keyValueOrEntryToNode` converts an keyOrNodeOrEntry object into a node object.
|
|
74
|
-
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, NODE>`, which means it
|
|
75
|
-
* can be one of the following:
|
|
76
|
-
* @param {V} [value] - The `value` parameter is an optional argument that represents the value
|
|
77
|
-
* associated with the node. It is of type `V`, which can be any data type. If no value is provided,
|
|
78
|
-
* it defaults to `undefined`.
|
|
79
|
-
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
|
|
80
|
-
* times the value should be added to the node. If not provided, it defaults to 1.
|
|
81
|
-
* @returns a node of type `NODE` or `undefined`.
|
|
82
|
-
*/
|
|
83
|
-
keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
|
|
84
82
|
/**
|
|
85
|
-
* The function
|
|
86
|
-
* @param
|
|
87
|
-
*
|
|
88
|
-
* class
|
|
83
|
+
* The function creates a new AVLTreeMultiMap object with the specified options and returns it.
|
|
84
|
+
* @param [options] - The `options` parameter is an optional object that contains additional
|
|
85
|
+
* configuration options for creating the AVLTreeMultiMap. It can have the following properties:
|
|
86
|
+
* @returns a new instance of the AVLTreeMultiMap class, with the specified options, as a TREE
|
|
87
|
+
* object.
|
|
88
|
+
*/
|
|
89
|
+
createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
|
|
90
|
+
/**
|
|
91
|
+
* The function checks if the input is an instance of AVLTreeMultiMapNode.
|
|
92
|
+
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
93
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
|
|
94
|
+
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
95
|
+
* an instance of the `AVLTreeMultiMapNode` class.
|
|
96
|
+
*/
|
|
97
|
+
isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
98
|
+
/**
|
|
99
|
+
* The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
|
|
100
|
+
* a node object.
|
|
101
|
+
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
102
|
+
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
|
|
103
|
+
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
104
|
+
* `override` function. It represents the value associated with the key in the data structure. If no
|
|
105
|
+
* value is provided, it will default to `undefined`.
|
|
106
|
+
* @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
|
|
107
|
+
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
|
|
108
|
+
* @returns either a NODE object or undefined.
|
|
89
109
|
*/
|
|
90
|
-
|
|
110
|
+
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
|
|
91
111
|
/**
|
|
92
112
|
* Time Complexity: O(log n)
|
|
93
113
|
* Space Complexity: O(1)
|
|
@@ -96,19 +116,20 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
96
116
|
* Time Complexity: O(log n)
|
|
97
117
|
* Space Complexity: O(1)
|
|
98
118
|
*
|
|
99
|
-
* The function overrides the add method of a
|
|
100
|
-
*
|
|
101
|
-
*
|
|
119
|
+
* The function overrides the add method of a TypeScript class to add a new node to a data structure
|
|
120
|
+
* and update the count.
|
|
121
|
+
* @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
122
|
+
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
|
|
123
|
+
* can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
|
|
124
|
+
* entry, or raw element
|
|
102
125
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
103
|
-
*
|
|
104
|
-
* method.
|
|
126
|
+
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
105
127
|
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
|
|
106
|
-
* be added to the
|
|
107
|
-
* added once. However, you can specify a different value for `count` if you want to add
|
|
108
|
-
* @returns
|
|
109
|
-
* was not successful.
|
|
128
|
+
* be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
|
|
129
|
+
* be added once. However, you can specify a different value for `count` if you want to add
|
|
130
|
+
* @returns a boolean value.
|
|
110
131
|
*/
|
|
111
|
-
add(
|
|
132
|
+
add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
112
133
|
/**
|
|
113
134
|
* Time Complexity: O(log n)
|
|
114
135
|
* Space Complexity: O(1)
|
|
@@ -117,19 +138,19 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
117
138
|
* Time Complexity: O(log n)
|
|
118
139
|
* Space Complexity: O(1)
|
|
119
140
|
*
|
|
120
|
-
* The `delete` function in
|
|
121
|
-
*
|
|
122
|
-
* @param identifier - The identifier is the value
|
|
123
|
-
*
|
|
141
|
+
* The `delete` function in a binary tree data structure deletes a node based on its identifier and
|
|
142
|
+
* returns the deleted node along with the parent node that needs to be balanced.
|
|
143
|
+
* @param identifier - The identifier parameter is the value used to identify the node that needs to
|
|
144
|
+
* be deleted from the binary tree. It can be of any type and is the return type of the callback
|
|
124
145
|
* function.
|
|
125
|
-
* @param {C} callback - The `callback` parameter is a function that is used to determine
|
|
126
|
-
*
|
|
127
|
-
* function takes
|
|
128
|
-
*
|
|
146
|
+
* @param {C} callback - The `callback` parameter is a function that is used to determine the
|
|
147
|
+
* equality of nodes in the binary tree. It is optional and has a default value of
|
|
148
|
+
* `this._DEFAULT_CALLBACK`. The `callback` function takes a single argument, which is the identifier
|
|
149
|
+
* of a node, and returns a value that
|
|
129
150
|
* @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
|
|
130
151
|
* being deleted. If set to true, the count of the node will not be considered and the node will be
|
|
131
|
-
* deleted regardless of its count. If set to false (default), the count of the node will be
|
|
132
|
-
*
|
|
152
|
+
* deleted regardless of its count. If set to false (default), the count of the node will be taken
|
|
153
|
+
* into account and the node
|
|
133
154
|
* @returns an array of `BinaryTreeDeleteResult<NODE>`.
|
|
134
155
|
*/
|
|
135
156
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
|
|
@@ -141,7 +162,8 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
141
162
|
* Time Complexity: O(1)
|
|
142
163
|
* Space Complexity: O(1)
|
|
143
164
|
*
|
|
144
|
-
* The clear
|
|
165
|
+
* The "clear" function overrides the parent class's "clear" function and also resets the count to
|
|
166
|
+
* zero.
|
|
145
167
|
*/
|
|
146
168
|
clear(): void;
|
|
147
169
|
/**
|
|
@@ -151,13 +173,14 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
151
173
|
/**
|
|
152
174
|
* Time Complexity: O(n log n)
|
|
153
175
|
* Space Complexity: O(log n)
|
|
154
|
-
*
|
|
155
176
|
* The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
|
|
156
177
|
* tree using either a recursive or iterative approach.
|
|
157
|
-
* @param iterationType - The `iterationType` parameter is an optional parameter that
|
|
158
|
-
* type of iteration to use when building the balanced binary search tree. It
|
|
159
|
-
*
|
|
160
|
-
*
|
|
178
|
+
* @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
|
|
179
|
+
* specifies the type of iteration to use when building the balanced binary search tree. It has a
|
|
180
|
+
* default value of `this.iterationType`, which means it will use the iteration type currently set in
|
|
181
|
+
* the object.
|
|
182
|
+
* @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
|
|
183
|
+
* balancing operation is successful, and `false` if there are no nodes to balance.
|
|
161
184
|
*/
|
|
162
185
|
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
163
186
|
/**
|
|
@@ -168,27 +191,42 @@ export declare class AVLTreeMultiMap<K extends Comparable, V = any, NODE extends
|
|
|
168
191
|
* Time complexity: O(n)
|
|
169
192
|
* Space complexity: O(n)
|
|
170
193
|
*
|
|
171
|
-
* The
|
|
194
|
+
* The function overrides the clone method to create a deep copy of a tree object.
|
|
172
195
|
* @returns The `clone()` method is returning a cloned instance of the `TREE` object.
|
|
173
196
|
*/
|
|
174
197
|
clone(): TREE;
|
|
175
198
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
199
|
+
* Time Complexity: O(1)
|
|
200
|
+
* Space Complexity: O(1)
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Time Complexity: O(1)
|
|
204
|
+
* Space Complexity: O(1)
|
|
205
|
+
*
|
|
206
|
+
* The `_swapProperties` function swaps the properties (key, value, count, height) between two nodes
|
|
207
|
+
* in a binary search tree.
|
|
208
|
+
* @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
|
|
209
|
+
* that will be swapped with the `destNode`.
|
|
210
|
+
* @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
|
|
211
|
+
* node where the properties will be swapped with the source node.
|
|
212
|
+
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
213
|
+
* If either `srcNode` or `destNode` is undefined, it returns `undefined`.
|
|
183
214
|
*/
|
|
184
|
-
protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
215
|
+
protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
185
216
|
/**
|
|
217
|
+
* Time Complexity: O(1)
|
|
218
|
+
* Space Complexity: O(1)
|
|
219
|
+
*/
|
|
220
|
+
/**
|
|
221
|
+
* Time Complexity: O(1)
|
|
222
|
+
* Space Complexity: O(1)
|
|
223
|
+
*
|
|
186
224
|
* The function replaces an old node with a new node and updates the count property of the new node.
|
|
187
|
-
* @param {NODE} oldNode - The
|
|
188
|
-
*
|
|
189
|
-
* @param {NODE} newNode - The `newNode` parameter is an
|
|
225
|
+
* @param {NODE} oldNode - The oldNode parameter represents the node that needs to be replaced in the
|
|
226
|
+
* data structure. It is of type NODE.
|
|
227
|
+
* @param {NODE} newNode - The `newNode` parameter is an instance of the `NODE` class.
|
|
190
228
|
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
191
|
-
* superclass,
|
|
229
|
+
* superclass, which is of type `NODE`.
|
|
192
230
|
*/
|
|
193
231
|
protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
|
|
194
232
|
}
|