data-structure-typed 1.49.0 → 1.49.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.
- package/CHANGELOG.md +1 -1
- package/README.md +16 -16
- package/README_zh-CN.md +2 -2
- package/benchmark/report.html +46 -1
- package/benchmark/report.json +457 -22
- package/dist/cjs/data-structures/base/iterable-base.d.ts +11 -0
- package/dist/cjs/data-structures/base/iterable-base.js +21 -0
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +10 -12
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +3 -4
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +58 -58
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +15 -15
- package/dist/cjs/data-structures/binary-tree/bst.js +3 -3
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +11 -11
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +5 -6
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +14 -14
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +3 -3
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +9 -3
- package/dist/cjs/data-structures/graph/abstract-graph.js +27 -31
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +8 -1
- package/dist/cjs/data-structures/graph/directed-graph.js +1 -8
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.d.ts +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +8 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js +1 -8
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +22 -10
- package/dist/cjs/data-structures/hash/hash-map.js +28 -16
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-table.d.ts +2 -2
- package/dist/cjs/data-structures/hash/hash-table.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +20 -38
- package/dist/cjs/data-structures/heap/heap.js +22 -42
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +11 -1
- package/dist/cjs/data-structures/heap/max-heap.js +10 -7
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +11 -1
- package/dist/cjs/data-structures/heap/min-heap.js +10 -7
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +95 -95
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +132 -136
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +18 -23
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +42 -49
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +0 -7
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +0 -7
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +9 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -7
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +76 -80
- package/dist/cjs/data-structures/queue/deque.js +106 -122
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +30 -16
- package/dist/cjs/data-structures/queue/queue.js +31 -24
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +17 -8
- package/dist/cjs/data-structures/stack/stack.js +9 -9
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +14 -5
- package/dist/cjs/data-structures/trie/trie.js +13 -13
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +4 -4
- package/dist/cjs/types/common.d.ts +32 -8
- package/dist/cjs/types/common.js +22 -1
- package/dist/cjs/types/common.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -24
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -22
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
- package/dist/mjs/data-structures/base/iterable-base.d.ts +11 -0
- package/dist/mjs/data-structures/base/iterable-base.js +21 -0
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +10 -12
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +3 -4
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +58 -58
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +6 -6
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +15 -15
- package/dist/mjs/data-structures/binary-tree/bst.js +3 -3
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +11 -11
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +5 -6
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +14 -14
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +3 -3
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +9 -3
- package/dist/mjs/data-structures/graph/abstract-graph.js +27 -31
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +8 -1
- package/dist/mjs/data-structures/graph/directed-graph.js +1 -8
- package/dist/mjs/data-structures/graph/map-graph.d.ts +1 -1
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +8 -1
- package/dist/mjs/data-structures/graph/undirected-graph.js +1 -8
- package/dist/mjs/data-structures/hash/hash-map.d.ts +22 -10
- package/dist/mjs/data-structures/hash/hash-map.js +27 -15
- package/dist/mjs/data-structures/hash/hash-table.d.ts +2 -2
- package/dist/mjs/data-structures/heap/heap.d.ts +20 -38
- package/dist/mjs/data-structures/heap/heap.js +23 -43
- package/dist/mjs/data-structures/heap/max-heap.d.ts +11 -1
- package/dist/mjs/data-structures/heap/max-heap.js +9 -6
- package/dist/mjs/data-structures/heap/min-heap.d.ts +11 -1
- package/dist/mjs/data-structures/heap/min-heap.js +9 -6
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +95 -95
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +132 -136
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +18 -23
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +43 -50
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +1 -1
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +0 -7
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +1 -1
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +0 -7
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +9 -1
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +7 -6
- package/dist/mjs/data-structures/queue/deque.d.ts +76 -80
- package/dist/mjs/data-structures/queue/deque.js +106 -122
- package/dist/mjs/data-structures/queue/queue.d.ts +30 -16
- package/dist/mjs/data-structures/queue/queue.js +31 -24
- package/dist/mjs/data-structures/stack/stack.d.ts +17 -8
- package/dist/mjs/data-structures/stack/stack.js +10 -10
- package/dist/mjs/data-structures/trie/trie.d.ts +14 -5
- package/dist/mjs/data-structures/trie/trie.js +14 -14
- package/dist/mjs/interfaces/binary-tree.d.ts +4 -4
- package/dist/mjs/types/common.d.ts +32 -8
- package/dist/mjs/types/common.js +21 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -24
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +1 -21
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
- package/dist/mjs/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +533 -558
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/base/iterable-base.ts +24 -0
- package/src/data-structures/binary-tree/avl-tree.ts +14 -14
- package/src/data-structures/binary-tree/binary-tree.ts +74 -77
- package/src/data-structures/binary-tree/bst.ts +18 -17
- package/src/data-structures/binary-tree/rb-tree.ts +17 -18
- package/src/data-structures/binary-tree/tree-multimap.ts +22 -20
- package/src/data-structures/graph/abstract-graph.ts +35 -25
- package/src/data-structures/graph/directed-graph.ts +2 -2
- package/src/data-structures/graph/map-graph.ts +1 -1
- package/src/data-structures/graph/undirected-graph.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +40 -24
- package/src/data-structures/hash/hash-table.ts +3 -3
- package/src/data-structures/heap/heap.ts +33 -60
- package/src/data-structures/heap/max-heap.ts +11 -2
- package/src/data-structures/heap/min-heap.ts +11 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +147 -145
- package/src/data-structures/linked-list/singly-linked-list.ts +52 -52
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
- package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
- package/src/data-structures/priority-queue/priority-queue.ts +9 -2
- package/src/data-structures/queue/deque.ts +129 -144
- package/src/data-structures/queue/queue.ts +37 -26
- package/src/data-structures/stack/stack.ts +20 -14
- package/src/data-structures/trie/trie.ts +18 -13
- package/src/interfaces/binary-tree.ts +5 -5
- package/src/types/common.ts +37 -12
- package/src/types/data-structures/binary-tree/avl-tree.ts +0 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -26
- package/src/types/data-structures/binary-tree/bst.ts +0 -1
- package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/tree-multimap.ts +1 -1
- package/test/performance/data-structures/comparison/comparison.test.ts +6 -6
- package/test/performance/data-structures/heap/heap.test.ts +2 -2
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +2 -2
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +2 -2
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +2 -2
- package/test/unit/data-structures/graph/directed-graph.test.ts +21 -1
- package/test/unit/data-structures/graph/undirected-graph.test.ts +39 -1
- package/test/unit/data-structures/hash/hash-map.test.ts +2 -2
- package/test/unit/data-structures/heap/heap.test.ts +1 -1
- package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +30 -30
- package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +21 -21
- package/test/unit/data-structures/linked-list/skip-list.test.ts +2 -2
- package/test/unit/data-structures/queue/deque.test.ts +5 -5
- package/test/unit/data-structures/queue/queue.test.ts +4 -4
- package/test/unit/data-structures/trie/trie.test.ts +1 -1
package/benchmark/report.json
CHANGED
|
@@ -1,55 +1,490 @@
|
|
|
1
1
|
{
|
|
2
|
+
"avl-tree": {
|
|
3
|
+
"benchmarks": [
|
|
4
|
+
{
|
|
5
|
+
"test name": "10,000 add randomly",
|
|
6
|
+
"time taken (ms)": "50.74",
|
|
7
|
+
"executions per sec": "19.71",
|
|
8
|
+
"sample deviation": "0.00"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"test name": "10,000 add & delete randomly",
|
|
12
|
+
"time taken (ms)": "127.76",
|
|
13
|
+
"executions per sec": "7.83",
|
|
14
|
+
"sample deviation": "0.02"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"test name": "10,000 addMany",
|
|
18
|
+
"time taken (ms)": "57.14",
|
|
19
|
+
"executions per sec": "17.50",
|
|
20
|
+
"sample deviation": "0.00"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"test name": "10,000 get",
|
|
24
|
+
"time taken (ms)": "52.22",
|
|
25
|
+
"executions per sec": "19.15",
|
|
26
|
+
"sample deviation": "0.01"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"testName": "avl-tree"
|
|
30
|
+
},
|
|
2
31
|
"binary-tree": {
|
|
3
32
|
"benchmarks": [
|
|
4
33
|
{
|
|
5
34
|
"test name": "1,000 add randomly",
|
|
6
|
-
"time taken (ms)": "
|
|
7
|
-
"executions per sec": "
|
|
8
|
-
"sample deviation": "
|
|
35
|
+
"time taken (ms)": "18.32",
|
|
36
|
+
"executions per sec": "54.59",
|
|
37
|
+
"sample deviation": "0.00"
|
|
9
38
|
},
|
|
10
39
|
{
|
|
11
40
|
"test name": "1,000 add & delete randomly",
|
|
12
|
-
"time taken (ms)": "
|
|
13
|
-
"executions per sec": "
|
|
14
|
-
"sample deviation": "0.
|
|
41
|
+
"time taken (ms)": "26.54",
|
|
42
|
+
"executions per sec": "37.69",
|
|
43
|
+
"sample deviation": "0.01"
|
|
15
44
|
},
|
|
16
45
|
{
|
|
17
46
|
"test name": "1,000 addMany",
|
|
18
|
-
"time taken (ms)": "
|
|
19
|
-
"executions per sec": "
|
|
47
|
+
"time taken (ms)": "18.79",
|
|
48
|
+
"executions per sec": "53.22",
|
|
20
49
|
"sample deviation": "0.00"
|
|
21
50
|
},
|
|
22
51
|
{
|
|
23
52
|
"test name": "1,000 get",
|
|
24
|
-
"time taken (ms)": "
|
|
25
|
-
"executions per sec": "
|
|
53
|
+
"time taken (ms)": "18.95",
|
|
54
|
+
"executions per sec": "52.78",
|
|
26
55
|
"sample deviation": "0.00"
|
|
27
56
|
},
|
|
28
57
|
{
|
|
29
58
|
"test name": "1,000 has",
|
|
30
|
-
"time taken (ms)": "
|
|
31
|
-
"executions per sec": "
|
|
32
|
-
"sample deviation": "
|
|
59
|
+
"time taken (ms)": "19.76",
|
|
60
|
+
"executions per sec": "50.60",
|
|
61
|
+
"sample deviation": "0.01"
|
|
33
62
|
},
|
|
34
63
|
{
|
|
35
64
|
"test name": "1,000 dfs",
|
|
36
|
-
"time taken (ms)": "
|
|
37
|
-
"executions per sec": "6.
|
|
38
|
-
"sample deviation": "0.
|
|
65
|
+
"time taken (ms)": "159.96",
|
|
66
|
+
"executions per sec": "6.25",
|
|
67
|
+
"sample deviation": "0.01"
|
|
39
68
|
},
|
|
40
69
|
{
|
|
41
70
|
"test name": "1,000 bfs",
|
|
42
|
-
"time taken (ms)": "
|
|
43
|
-
"executions per sec": "
|
|
44
|
-
"sample deviation": "0.
|
|
71
|
+
"time taken (ms)": "73.63",
|
|
72
|
+
"executions per sec": "13.58",
|
|
73
|
+
"sample deviation": "0.08"
|
|
45
74
|
},
|
|
46
75
|
{
|
|
47
76
|
"test name": "1,000 morris",
|
|
48
|
-
"time taken (ms)": "
|
|
49
|
-
"executions per sec": "
|
|
50
|
-
"sample deviation": "0.
|
|
77
|
+
"time taken (ms)": "225.93",
|
|
78
|
+
"executions per sec": "4.43",
|
|
79
|
+
"sample deviation": "0.05"
|
|
51
80
|
}
|
|
52
81
|
],
|
|
53
82
|
"testName": "binary-tree"
|
|
83
|
+
},
|
|
84
|
+
"bst": {
|
|
85
|
+
"benchmarks": [
|
|
86
|
+
{
|
|
87
|
+
"test name": "10,000 add randomly",
|
|
88
|
+
"time taken (ms)": "48.80",
|
|
89
|
+
"executions per sec": "20.49",
|
|
90
|
+
"sample deviation": "2.79e-4"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"test name": "10,000 add & delete randomly",
|
|
94
|
+
"time taken (ms)": "110.72",
|
|
95
|
+
"executions per sec": "9.03",
|
|
96
|
+
"sample deviation": "0.00"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"test name": "10,000 addMany",
|
|
100
|
+
"time taken (ms)": "46.19",
|
|
101
|
+
"executions per sec": "21.65",
|
|
102
|
+
"sample deviation": "0.00"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"test name": "10,000 get",
|
|
106
|
+
"time taken (ms)": "49.28",
|
|
107
|
+
"executions per sec": "20.29",
|
|
108
|
+
"sample deviation": "7.92e-4"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"testName": "bst"
|
|
112
|
+
},
|
|
113
|
+
"rb-tree": {
|
|
114
|
+
"benchmarks": [
|
|
115
|
+
{
|
|
116
|
+
"test name": "100,000 add",
|
|
117
|
+
"time taken (ms)": "80.84",
|
|
118
|
+
"executions per sec": "12.37",
|
|
119
|
+
"sample deviation": "0.00"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"test name": "100,000 add & delete randomly",
|
|
123
|
+
"time taken (ms)": "206.65",
|
|
124
|
+
"executions per sec": "4.84",
|
|
125
|
+
"sample deviation": "0.01"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"test name": "100,000 getNode",
|
|
129
|
+
"time taken (ms)": "57.42",
|
|
130
|
+
"executions per sec": "17.42",
|
|
131
|
+
"sample deviation": "0.00"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"test name": "100,000 add & iterator",
|
|
135
|
+
"time taken (ms)": "109.59",
|
|
136
|
+
"executions per sec": "9.12",
|
|
137
|
+
"sample deviation": "0.00"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"testName": "rb-tree"
|
|
141
|
+
},
|
|
142
|
+
"comparison": {
|
|
143
|
+
"benchmarks": [
|
|
144
|
+
{
|
|
145
|
+
"test name": "SRC PQ 10,000 add",
|
|
146
|
+
"time taken (ms)": "0.14",
|
|
147
|
+
"executions per sec": "6917.74",
|
|
148
|
+
"sample deviation": "1.81e-6"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"test name": "CJS PQ 10,000 add",
|
|
152
|
+
"time taken (ms)": "0.15",
|
|
153
|
+
"executions per sec": "6883.53",
|
|
154
|
+
"sample deviation": "3.84e-6"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"test name": "MJS PQ 10,000 add",
|
|
158
|
+
"time taken (ms)": "0.57",
|
|
159
|
+
"executions per sec": "1761.70",
|
|
160
|
+
"sample deviation": "5.07e-6"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"test name": "SRC PQ 10,000 add & poll",
|
|
164
|
+
"time taken (ms)": "3.45",
|
|
165
|
+
"executions per sec": "289.74",
|
|
166
|
+
"sample deviation": "3.63e-4"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"test name": "CJS PQ 10,000 add & poll",
|
|
170
|
+
"time taken (ms)": "3.53",
|
|
171
|
+
"executions per sec": "283.14",
|
|
172
|
+
"sample deviation": "4.73e-5"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"test name": "MJS PQ 10,000 add & poll",
|
|
176
|
+
"time taken (ms)": "3.31",
|
|
177
|
+
"executions per sec": "302.38",
|
|
178
|
+
"sample deviation": "3.64e-5"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"testName": "comparison"
|
|
182
|
+
},
|
|
183
|
+
"directed-graph": {
|
|
184
|
+
"benchmarks": [
|
|
185
|
+
{
|
|
186
|
+
"test name": "1,000 addVertex",
|
|
187
|
+
"time taken (ms)": "0.10",
|
|
188
|
+
"executions per sec": "9860.53",
|
|
189
|
+
"sample deviation": "9.32e-7"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"test name": "1,000 addEdge",
|
|
193
|
+
"time taken (ms)": "6.34",
|
|
194
|
+
"executions per sec": "157.71",
|
|
195
|
+
"sample deviation": "8.55e-4"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"test name": "1,000 getVertex",
|
|
199
|
+
"time taken (ms)": "0.05",
|
|
200
|
+
"executions per sec": "2.16e+4",
|
|
201
|
+
"sample deviation": "4.61e-7"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"test name": "1,000 getEdge",
|
|
205
|
+
"time taken (ms)": "22.67",
|
|
206
|
+
"executions per sec": "44.12",
|
|
207
|
+
"sample deviation": "0.00"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"test name": "tarjan",
|
|
211
|
+
"time taken (ms)": "217.59",
|
|
212
|
+
"executions per sec": "4.60",
|
|
213
|
+
"sample deviation": "0.01"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"test name": "tarjan all",
|
|
217
|
+
"time taken (ms)": "6489.86",
|
|
218
|
+
"executions per sec": "0.15",
|
|
219
|
+
"sample deviation": "0.09"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"test name": "topologicalSort",
|
|
223
|
+
"time taken (ms)": "179.22",
|
|
224
|
+
"executions per sec": "5.58",
|
|
225
|
+
"sample deviation": "0.00"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"testName": "directed-graph"
|
|
229
|
+
},
|
|
230
|
+
"hash-map": {
|
|
231
|
+
"benchmarks": [
|
|
232
|
+
{
|
|
233
|
+
"test name": "1,000,000 set",
|
|
234
|
+
"time taken (ms)": "108.75",
|
|
235
|
+
"executions per sec": "9.20",
|
|
236
|
+
"sample deviation": "0.04"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"test name": "Native Map 1,000,000 set",
|
|
240
|
+
"time taken (ms)": "217.55",
|
|
241
|
+
"executions per sec": "4.60",
|
|
242
|
+
"sample deviation": "0.02"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"test name": "Native Set 1,000,000 add",
|
|
246
|
+
"time taken (ms)": "179.67",
|
|
247
|
+
"executions per sec": "5.57",
|
|
248
|
+
"sample deviation": "0.03"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"test name": "1,000,000 set & get",
|
|
252
|
+
"time taken (ms)": "122.66",
|
|
253
|
+
"executions per sec": "8.15",
|
|
254
|
+
"sample deviation": "0.03"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"test name": "Native Map 1,000,000 set & get",
|
|
258
|
+
"time taken (ms)": "282.47",
|
|
259
|
+
"executions per sec": "3.54",
|
|
260
|
+
"sample deviation": "0.04"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"test name": "Native Set 1,000,000 add & has",
|
|
264
|
+
"time taken (ms)": "174.48",
|
|
265
|
+
"executions per sec": "5.73",
|
|
266
|
+
"sample deviation": "0.02"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"test name": "1,000,000 ObjKey set & get",
|
|
270
|
+
"time taken (ms)": "336.83",
|
|
271
|
+
"executions per sec": "2.97",
|
|
272
|
+
"sample deviation": "0.06"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"test name": "Native Map 1,000,000 ObjKey set & get",
|
|
276
|
+
"time taken (ms)": "314.00",
|
|
277
|
+
"executions per sec": "3.18",
|
|
278
|
+
"sample deviation": "0.06"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"test name": "Native Set 1,000,000 ObjKey add & has",
|
|
282
|
+
"time taken (ms)": "267.84",
|
|
283
|
+
"executions per sec": "3.73",
|
|
284
|
+
"sample deviation": "0.03"
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"testName": "hash-map"
|
|
288
|
+
},
|
|
289
|
+
"heap": {
|
|
290
|
+
"benchmarks": [
|
|
291
|
+
{
|
|
292
|
+
"test name": "100,000 add & poll",
|
|
293
|
+
"time taken (ms)": "80.49",
|
|
294
|
+
"executions per sec": "12.42",
|
|
295
|
+
"sample deviation": "0.00"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"test name": "100,000 add & dfs",
|
|
299
|
+
"time taken (ms)": "34.01",
|
|
300
|
+
"executions per sec": "29.40",
|
|
301
|
+
"sample deviation": "3.88e-4"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"test name": "10,000 fib add & pop",
|
|
305
|
+
"time taken (ms)": "359.70",
|
|
306
|
+
"executions per sec": "2.78",
|
|
307
|
+
"sample deviation": "0.00"
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
"testName": "heap"
|
|
311
|
+
},
|
|
312
|
+
"doubly-linked-list": {
|
|
313
|
+
"benchmarks": [
|
|
314
|
+
{
|
|
315
|
+
"test name": "1,000,000 push",
|
|
316
|
+
"time taken (ms)": "229.17",
|
|
317
|
+
"executions per sec": "4.36",
|
|
318
|
+
"sample deviation": "0.06"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"test name": "1,000,000 unshift",
|
|
322
|
+
"time taken (ms)": "220.53",
|
|
323
|
+
"executions per sec": "4.53",
|
|
324
|
+
"sample deviation": "0.06"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"test name": "1,000,000 unshift & shift",
|
|
328
|
+
"time taken (ms)": "172.12",
|
|
329
|
+
"executions per sec": "5.81",
|
|
330
|
+
"sample deviation": "0.03"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"test name": "1,000,000 addBefore",
|
|
334
|
+
"time taken (ms)": "309.58",
|
|
335
|
+
"executions per sec": "3.23",
|
|
336
|
+
"sample deviation": "0.06"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
"testName": "doubly-linked-list"
|
|
340
|
+
},
|
|
341
|
+
"singly-linked-list": {
|
|
342
|
+
"benchmarks": [
|
|
343
|
+
{
|
|
344
|
+
"test name": "1,000,000 push & shift",
|
|
345
|
+
"time taken (ms)": "211.62",
|
|
346
|
+
"executions per sec": "4.73",
|
|
347
|
+
"sample deviation": "0.06"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"test name": "10,000 push & pop",
|
|
351
|
+
"time taken (ms)": "219.72",
|
|
352
|
+
"executions per sec": "4.55",
|
|
353
|
+
"sample deviation": "0.03"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"test name": "10,000 addBefore",
|
|
357
|
+
"time taken (ms)": "249.09",
|
|
358
|
+
"executions per sec": "4.01",
|
|
359
|
+
"sample deviation": "0.01"
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"testName": "singly-linked-list"
|
|
363
|
+
},
|
|
364
|
+
"max-priority-queue": {
|
|
365
|
+
"benchmarks": [
|
|
366
|
+
{
|
|
367
|
+
"test name": "10,000 refill & poll",
|
|
368
|
+
"time taken (ms)": "8.96",
|
|
369
|
+
"executions per sec": "111.61",
|
|
370
|
+
"sample deviation": "1.80e-4"
|
|
371
|
+
}
|
|
372
|
+
],
|
|
373
|
+
"testName": "max-priority-queue"
|
|
374
|
+
},
|
|
375
|
+
"priority-queue": {
|
|
376
|
+
"benchmarks": [
|
|
377
|
+
{
|
|
378
|
+
"test name": "100,000 add & poll",
|
|
379
|
+
"time taken (ms)": "106.14",
|
|
380
|
+
"executions per sec": "9.42",
|
|
381
|
+
"sample deviation": "0.00"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
"testName": "priority-queue"
|
|
385
|
+
},
|
|
386
|
+
"deque": {
|
|
387
|
+
"benchmarks": [
|
|
388
|
+
{
|
|
389
|
+
"test name": "1,000,000 push",
|
|
390
|
+
"time taken (ms)": "13.91",
|
|
391
|
+
"executions per sec": "71.89",
|
|
392
|
+
"sample deviation": "4.15e-4"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"test name": "1,000,000 push & pop",
|
|
396
|
+
"time taken (ms)": "22.82",
|
|
397
|
+
"executions per sec": "43.83",
|
|
398
|
+
"sample deviation": "2.45e-4"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"test name": "100,000 push & shift",
|
|
402
|
+
"time taken (ms)": "2.38",
|
|
403
|
+
"executions per sec": "420.49",
|
|
404
|
+
"sample deviation": "3.61e-5"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"test name": "Native Array 100,000 push & shift",
|
|
408
|
+
"time taken (ms)": "2718.62",
|
|
409
|
+
"executions per sec": "0.37",
|
|
410
|
+
"sample deviation": "0.35"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"test name": "100,000 unshift & shift",
|
|
414
|
+
"time taken (ms)": "2.28",
|
|
415
|
+
"executions per sec": "438.78",
|
|
416
|
+
"sample deviation": "4.18e-4"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"test name": "Native Array 100,000 unshift & shift",
|
|
420
|
+
"time taken (ms)": "4065.01",
|
|
421
|
+
"executions per sec": "0.25",
|
|
422
|
+
"sample deviation": "0.21"
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
"testName": "deque"
|
|
426
|
+
},
|
|
427
|
+
"queue": {
|
|
428
|
+
"benchmarks": [
|
|
429
|
+
{
|
|
430
|
+
"test name": "1,000,000 push",
|
|
431
|
+
"time taken (ms)": "44.46",
|
|
432
|
+
"executions per sec": "22.49",
|
|
433
|
+
"sample deviation": "0.01"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"test name": "100,000 push & shift",
|
|
437
|
+
"time taken (ms)": "5.16",
|
|
438
|
+
"executions per sec": "193.83",
|
|
439
|
+
"sample deviation": "0.00"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
"test name": "Native Array 100,000 push & shift",
|
|
443
|
+
"time taken (ms)": "2195.56",
|
|
444
|
+
"executions per sec": "0.46",
|
|
445
|
+
"sample deviation": "0.29"
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"test name": "Native Array 100,000 push & pop",
|
|
449
|
+
"time taken (ms)": "4.40",
|
|
450
|
+
"executions per sec": "227.04",
|
|
451
|
+
"sample deviation": "0.00"
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
"testName": "queue"
|
|
455
|
+
},
|
|
456
|
+
"stack": {
|
|
457
|
+
"benchmarks": [
|
|
458
|
+
{
|
|
459
|
+
"test name": "1,000,000 push",
|
|
460
|
+
"time taken (ms)": "44.05",
|
|
461
|
+
"executions per sec": "22.70",
|
|
462
|
+
"sample deviation": "0.01"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"test name": "1,000,000 push & pop",
|
|
466
|
+
"time taken (ms)": "49.72",
|
|
467
|
+
"executions per sec": "20.11",
|
|
468
|
+
"sample deviation": "0.01"
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
"testName": "stack"
|
|
472
|
+
},
|
|
473
|
+
"trie": {
|
|
474
|
+
"benchmarks": [
|
|
475
|
+
{
|
|
476
|
+
"test name": "100,000 push",
|
|
477
|
+
"time taken (ms)": "44.33",
|
|
478
|
+
"executions per sec": "22.56",
|
|
479
|
+
"sample deviation": "0.00"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"test name": "100,000 getWords",
|
|
483
|
+
"time taken (ms)": "88.47",
|
|
484
|
+
"executions per sec": "11.30",
|
|
485
|
+
"sample deviation": "0.01"
|
|
486
|
+
}
|
|
487
|
+
],
|
|
488
|
+
"testName": "trie"
|
|
54
489
|
}
|
|
55
490
|
}
|
|
@@ -126,6 +126,12 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
|
|
|
126
126
|
* all the elements in the collection.
|
|
127
127
|
*/
|
|
128
128
|
reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U;
|
|
129
|
+
hasValue(value: V): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Time Complexity: O(n)
|
|
132
|
+
* Space Complexity: O(n)
|
|
133
|
+
*/
|
|
134
|
+
print(): void;
|
|
129
135
|
protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
|
|
130
136
|
}
|
|
131
137
|
export declare abstract class IterableElementBase<V> {
|
|
@@ -228,5 +234,10 @@ export declare abstract class IterableElementBase<V> {
|
|
|
228
234
|
* all the elements in the array and applying the callback function to each element.
|
|
229
235
|
*/
|
|
230
236
|
reduce<U>(callbackfn: ReduceElementCallback<V, U>, initialValue: U): U;
|
|
237
|
+
/**
|
|
238
|
+
* Time Complexity: O(n)
|
|
239
|
+
* Space Complexity: O(n)
|
|
240
|
+
*/
|
|
241
|
+
print(): void;
|
|
231
242
|
protected abstract _getIterator(...args: any[]): IterableIterator<V>;
|
|
232
243
|
}
|
|
@@ -172,6 +172,20 @@ class IterableEntryBase {
|
|
|
172
172
|
}
|
|
173
173
|
return accumulator;
|
|
174
174
|
}
|
|
175
|
+
hasValue(value) {
|
|
176
|
+
for (const [, elementValue] of this) {
|
|
177
|
+
if (elementValue === value)
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Time Complexity: O(n)
|
|
184
|
+
* Space Complexity: O(n)
|
|
185
|
+
*/
|
|
186
|
+
print() {
|
|
187
|
+
console.log([...this]);
|
|
188
|
+
}
|
|
175
189
|
}
|
|
176
190
|
exports.IterableEntryBase = IterableEntryBase;
|
|
177
191
|
class IterableElementBase {
|
|
@@ -308,6 +322,13 @@ class IterableElementBase {
|
|
|
308
322
|
}
|
|
309
323
|
return accumulator;
|
|
310
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Time Complexity: O(n)
|
|
327
|
+
* Space Complexity: O(n)
|
|
328
|
+
*/
|
|
329
|
+
print() {
|
|
330
|
+
console.log([...this]);
|
|
331
|
+
}
|
|
311
332
|
}
|
|
312
333
|
exports.IterableElementBase = IterableElementBase;
|
|
313
334
|
//# sourceMappingURL=iterable-base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterable-base.js","sourceRoot":"","sources":["../../../../src/data-structures/base/iterable-base.ts"],"names":[],"mappings":";;;AAEA,MAAsB,iBAAiB;IAErC;;;OAGG;IAEH;;;;;;;;OAQG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAW;QAChC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH;;;;;;OAMG;IACH,CAAE,OAAO;QACP,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;OAKG;IACH,CAAE,IAAI;QACJ,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;OAKG;IACH,CAAE,MAAM;QACN,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAAuC,EAAE,OAAa;QAC1D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;Y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C1B,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;QAClE,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;CAGF;
|
|
1
|
+
{"version":3,"file":"iterable-base.js","sourceRoot":"","sources":["../../../../src/data-structures/base/iterable-base.ts"],"names":[],"mappings":";;;AAEA,MAAsB,iBAAiB;IAErC;;;OAGG;IAEH;;;;;;;;OAQG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAW;QAChC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH;;;;;;OAMG;IACH,CAAE,OAAO;QACP,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC;QACb,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;OAKG;IACH,CAAE,IAAI;QACJ,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;OAKG;IACH,CAAE,MAAM;QACN,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,SAAuC,EAAE,OAAa;QAC1D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC9D,OAA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,CAAC;gBACtD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACH;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,UAAoC,EAAE,OAAa;QACzD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAS,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IAED;;;OAGG;IACH;;;;;;;;;;;;OAYG;IACH,MAAM,CAAI,UAAuC,EAAE,YAAe;QAChE,IAAI,WAAW,GAAG,YAAY,CAAC;QAC/B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,IAAS,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAGD;;;OAGG;IACH,KAAK;QACH,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACxB,CAAC;CAGF;AAvJD,kDAuJC"}
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { BST, BSTNode } from './bst';
|
|
9
|
-
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions,
|
|
10
|
-
import { BTNCallback, BTNodeKeyOrNode } from '../../types';
|
|
9
|
+
import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNExemplar, BTNKeyOrNode } from '../../types';
|
|
11
10
|
import { IBinaryTree } from '../../interfaces';
|
|
12
11
|
export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {
|
|
13
12
|
height: number;
|
|
@@ -21,19 +20,18 @@ export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N
|
|
|
21
20
|
* 5. Efficient Lookups: Offers O(log n) search time, where 'n' is the number of nodes, due to its balanced nature.
|
|
22
21
|
* 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
|
|
23
22
|
* 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
|
|
24
|
-
* 8. Memory Overhead: Stores balance factors (or heights) at each node, leading to slightly higher memory usage compared to a regular BST.
|
|
25
23
|
*/
|
|
26
24
|
export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNode<K, V, AVLTreeNodeNested<K, V>>, TREE extends AVLTree<K, V, N, TREE> = AVLTree<K, V, N, AVLTreeNested<K, V, N>>> extends BST<K, V, N, TREE> implements IBinaryTree<K, V, N, TREE> {
|
|
27
25
|
/**
|
|
28
26
|
* The constructor function initializes an AVLTree object with optional elements and options.
|
|
29
|
-
* @param [elements] - The `elements` parameter is an optional iterable of `
|
|
27
|
+
* @param [elements] - The `elements` parameter is an optional iterable of `BTNExemplar<K, V, N>`
|
|
30
28
|
* objects. It represents a collection of elements that will be added to the AVL tree during
|
|
31
29
|
* initialization.
|
|
32
30
|
* @param [options] - The `options` parameter is an optional object that allows you to customize the
|
|
33
31
|
* behavior of the AVL tree. It is of type `Partial<AVLTreeOptions>`, which means that you can
|
|
34
32
|
* provide only a subset of the properties defined in the `AVLTreeOptions` interface.
|
|
35
33
|
*/
|
|
36
|
-
constructor(elements?: Iterable<
|
|
34
|
+
constructor(elements?: Iterable<BTNExemplar<K, V, N>>, options?: Partial<AVLTreeOptions<K>>);
|
|
37
35
|
/**
|
|
38
36
|
* The function creates a new AVL tree node with the specified key and value.
|
|
39
37
|
* @param {K} key - The key parameter is the key value that will be associated with
|
|
@@ -54,17 +52,17 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
|
|
|
54
52
|
createTree(options?: AVLTreeOptions<K>): TREE;
|
|
55
53
|
/**
|
|
56
54
|
* The function checks if an exemplar is an instance of AVLTreeNode.
|
|
57
|
-
* @param exemplar - The `exemplar` parameter is of type `
|
|
55
|
+
* @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
|
|
58
56
|
* @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
|
|
59
57
|
*/
|
|
60
|
-
isNode(exemplar:
|
|
58
|
+
isNode(exemplar: BTNExemplar<K, V, N>): exemplar is N;
|
|
61
59
|
/**
|
|
62
60
|
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
63
61
|
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
64
62
|
* data type.
|
|
65
63
|
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
66
64
|
*/
|
|
67
|
-
isNotNodeInstance(potentialKey:
|
|
65
|
+
isNotNodeInstance(potentialKey: BTNKeyOrNode<K, N>): potentialKey is K;
|
|
68
66
|
/**
|
|
69
67
|
* 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.
|
|
70
68
|
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
@@ -81,7 +79,7 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
|
|
|
81
79
|
* being added to the binary tree.
|
|
82
80
|
* @returns The method is returning either the inserted node or undefined.
|
|
83
81
|
*/
|
|
84
|
-
add(keyOrNodeOrEntry:
|
|
82
|
+
add(keyOrNodeOrEntry: BTNExemplar<K, V, N>, value?: V): N | undefined;
|
|
85
83
|
/**
|
|
86
84
|
* 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.
|
|
87
85
|
* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
|
|
@@ -99,9 +97,9 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
|
|
|
99
97
|
* that is deleted from the binary tree. It is an optional parameter and if not provided, it will
|
|
100
98
|
* default to the `_defaultOneParamCallback` function. The `callback` function should have a single
|
|
101
99
|
* parameter of type `N
|
|
102
|
-
* @returns The method is returning an array of `
|
|
100
|
+
* @returns The method is returning an array of `BinaryTreeDeleteResult<N>`.
|
|
103
101
|
*/
|
|
104
|
-
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C):
|
|
102
|
+
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeleteResult<N>[];
|
|
105
103
|
/**
|
|
106
104
|
* The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary
|
|
107
105
|
* tree.
|
|
@@ -112,7 +110,7 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
|
|
|
112
110
|
* @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
|
|
113
111
|
* if either `srcNode` or `destNode` is undefined.
|
|
114
112
|
*/
|
|
115
|
-
protected _swapProperties(srcNode:
|
|
113
|
+
protected _swapProperties(srcNode: BSTNKeyOrNode<K, N>, destNode: BSTNKeyOrNode<K, N>): N | undefined;
|
|
116
114
|
/**
|
|
117
115
|
* Time Complexity: O(1) - constant time, as it performs a fixed number of operations.
|
|
118
116
|
* Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
|