data-structure-typed 1.41.6 → 1.41.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +14 -11
  3. package/benchmark/report.html +14 -11
  4. package/benchmark/report.json +153 -202
  5. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +5 -2
  6. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +15 -2
  7. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  8. package/dist/cjs/src/data-structures/graph/abstract-graph.js +5 -5
  9. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  10. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +5 -2
  11. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +15 -2
  12. package/dist/mjs/src/data-structures/graph/abstract-graph.js +5 -5
  13. package/dist/umd/data-structure-typed.min.js +1 -1
  14. package/dist/umd/data-structure-typed.min.js.map +1 -1
  15. package/package.json +5 -5
  16. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  17. package/src/data-structures/binary-tree/bst.ts +1 -1
  18. package/src/data-structures/binary-tree/rb-tree.ts +18 -2
  19. package/src/data-structures/graph/abstract-graph.ts +6 -6
  20. package/test/config.ts +1 -0
  21. package/test/integration/avl-tree.test.ts +110 -0
  22. package/test/integration/bst.test.ts +385 -0
  23. package/test/integration/heap.test.js +16 -0
  24. package/test/integration/index.html +51 -0
  25. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +36 -0
  26. package/test/performance/data-structures/binary-tree/binary-index-tree.test.ts +0 -0
  27. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +45 -0
  28. package/test/performance/data-structures/binary-tree/bst.test.ts +36 -0
  29. package/test/performance/data-structures/binary-tree/overall.test.ts +0 -0
  30. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +32 -0
  31. package/test/performance/data-structures/binary-tree/segment-tree.test.ts +0 -0
  32. package/test/performance/data-structures/binary-tree/tree-multiset.test.ts +0 -0
  33. package/test/performance/data-structures/graph/abstract-graph.test.ts +0 -0
  34. package/test/performance/data-structures/graph/directed-graph.test.ts +49 -0
  35. package/test/performance/data-structures/graph/map-graph.test.ts +0 -0
  36. package/test/performance/data-structures/graph/overall.test.ts +0 -0
  37. package/test/performance/data-structures/graph/undirected-graph.test.ts +0 -0
  38. package/test/performance/data-structures/hash/coordinate-map.test.ts +0 -0
  39. package/test/performance/data-structures/hash/coordinate-set.test.ts +0 -0
  40. package/test/performance/data-structures/hash/hash-map.test.ts +0 -0
  41. package/test/performance/data-structures/hash/hash-table.test.ts +0 -0
  42. package/test/performance/data-structures/heap/heap.test.ts +30 -0
  43. package/test/performance/data-structures/heap/max-heap.test.ts +0 -0
  44. package/test/performance/data-structures/heap/min-heap.test.ts +0 -0
  45. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +40 -0
  46. package/test/performance/data-structures/linked-list/linked-list.test.ts +0 -0
  47. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +34 -0
  48. package/test/performance/data-structures/linked-list/skip-linked-list.test.ts +0 -0
  49. package/test/performance/data-structures/linked-list/skip-list.test.ts +0 -0
  50. package/test/performance/data-structures/matrix/matrix.test.ts +0 -0
  51. package/test/performance/data-structures/matrix/matrix2d.test.ts +0 -0
  52. package/test/performance/data-structures/matrix/navigator.test.ts +0 -0
  53. package/test/performance/data-structures/matrix/vector2d.test.ts +0 -0
  54. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +19 -0
  55. package/test/performance/data-structures/priority-queue/min-priority-queue.test.ts +0 -0
  56. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +0 -0
  57. package/test/performance/data-structures/queue/deque.test.ts +21 -0
  58. package/test/performance/data-structures/queue/queue.test.ts +25 -0
  59. package/test/performance/data-structures/stack/stack.test.ts +0 -0
  60. package/test/performance/data-structures/tree/tree.test.ts +0 -0
  61. package/test/performance/data-structures/trie/trie.test.ts +22 -0
  62. package/test/performance/reportor.ts +185 -0
  63. package/test/performance/types/index.ts +1 -0
  64. package/test/performance/types/reportor.ts +3 -0
  65. package/test/types/index.ts +1 -0
  66. package/test/types/utils/big-o.ts +1 -0
  67. package/test/types/utils/index.ts +2 -0
  68. package/test/types/utils/json2html.ts +1 -0
  69. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +269 -0
  70. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +320 -0
  71. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +486 -0
  72. package/test/unit/data-structures/binary-tree/bst.test.ts +840 -0
  73. package/test/unit/data-structures/binary-tree/overall.test.ts +66 -0
  74. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +435 -0
  75. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +50 -0
  76. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +542 -0
  77. package/test/unit/data-structures/graph/abstract-graph.test.ts +100 -0
  78. package/test/unit/data-structures/graph/directed-graph.test.ts +564 -0
  79. package/test/unit/data-structures/graph/map-graph.test.ts +126 -0
  80. package/test/unit/data-structures/graph/overall.test.ts +49 -0
  81. package/test/unit/data-structures/graph/salty-edges.json +1 -0
  82. package/test/unit/data-structures/graph/salty-vertexes.json +1 -0
  83. package/test/unit/data-structures/graph/undirected-graph.test.ts +167 -0
  84. package/test/unit/data-structures/hash/coordinate-map.test.ts +74 -0
  85. package/test/unit/data-structures/hash/coordinate-set.test.ts +66 -0
  86. package/test/unit/data-structures/hash/hash-map.test.ts +103 -0
  87. package/test/unit/data-structures/hash/hash-table.test.ts +186 -0
  88. package/test/unit/data-structures/heap/heap.test.ts +254 -0
  89. package/test/unit/data-structures/heap/max-heap.test.ts +52 -0
  90. package/test/unit/data-structures/heap/min-heap.test.ts +52 -0
  91. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +400 -0
  92. package/test/unit/data-structures/linked-list/linked-list.test.ts +8 -0
  93. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +474 -0
  94. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +13 -0
  95. package/test/unit/data-structures/linked-list/skip-list.test.ts +86 -0
  96. package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
  97. package/test/unit/data-structures/matrix/matrix2d.test.ts +345 -0
  98. package/test/unit/data-structures/matrix/navigator.test.ts +244 -0
  99. package/test/unit/data-structures/matrix/vector2d.test.ts +171 -0
  100. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +73 -0
  101. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +63 -0
  102. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +53 -0
  103. package/test/unit/data-structures/queue/deque.test.ts +410 -0
  104. package/test/unit/data-structures/queue/queue.test.ts +207 -0
  105. package/test/unit/data-structures/stack/stack.test.ts +67 -0
  106. package/test/unit/data-structures/tree/tree.test.ts +39 -0
  107. package/test/unit/data-structures/trie/trie.test.ts +825 -0
  108. package/test/utils/array.ts +5514 -0
  109. package/test/utils/big-o.ts +207 -0
  110. package/test/utils/console.ts +31 -0
  111. package/test/utils/index.ts +7 -0
  112. package/test/utils/is.ts +56 -0
  113. package/test/utils/json2html.ts +322 -0
  114. package/test/utils/number.ts +13 -0
  115. package/test/utils/string.ts +1 -0
@@ -2,36 +2,28 @@
2
2
  "avl-tree": {
3
3
  "benchmarks": [
4
4
  {
5
- "test name": "1000 add randomly",
6
- "time taken (ms)": "2.23",
7
- "executions per sec": "448.62",
8
- "executed times": "23",
9
- "sample mean (secs)": "0.00",
10
- "sample deviation": "5.02e-5"
5
+ "test name": "10,000 add randomly",
6
+ "time taken (ms)": "30.29",
7
+ "executions per sec": "33.01",
8
+ "sample deviation": "3.64e-4"
11
9
  },
12
10
  {
13
- "test name": "1000 add & delete randomly",
14
- "time taken (ms)": "5.04",
15
- "executions per sec": "198.31",
16
- "executed times": "11",
17
- "sample mean (secs)": "0.01",
18
- "sample deviation": "1.30e-4"
11
+ "test name": "10,000 add & delete randomly",
12
+ "time taken (ms)": "68.10",
13
+ "executions per sec": "14.68",
14
+ "sample deviation": "0.00"
19
15
  },
20
16
  {
21
- "test name": "1000 addMany",
22
- "time taken (ms)": "3.11",
23
- "executions per sec": "321.43",
24
- "executed times": "17",
25
- "sample mean (secs)": "0.00",
26
- "sample deviation": "3.26e-5"
17
+ "test name": "10,000 addMany",
18
+ "time taken (ms)": "39.54",
19
+ "executions per sec": "25.29",
20
+ "sample deviation": "4.07e-4"
27
21
  },
28
22
  {
29
- "test name": "1000 get",
30
- "time taken (ms)": "2.03",
31
- "executions per sec": "493.26",
32
- "executed times": "26",
33
- "sample mean (secs)": "0.00",
34
- "sample deviation": "1.45e-4"
23
+ "test name": "10,000 get",
24
+ "time taken (ms)": "26.72",
25
+ "executions per sec": "37.42",
26
+ "sample deviation": "3.77e-4"
35
27
  }
36
28
  ],
37
29
  "testName": "avl-tree"
@@ -39,60 +31,46 @@
39
31
  "binary-tree": {
40
32
  "benchmarks": [
41
33
  {
42
- "test name": "1000 add randomly",
43
- "time taken (ms)": "12.85",
44
- "executions per sec": "77.83",
45
- "executed times": "5",
46
- "sample mean (secs)": "0.01",
47
- "sample deviation": "1.07e-4"
34
+ "test name": "1,000 add randomly",
35
+ "time taken (ms)": "12.88",
36
+ "executions per sec": "77.63",
37
+ "sample deviation": "1.02e-4"
48
38
  },
49
39
  {
50
- "test name": "1000 add & delete randomly",
51
- "time taken (ms)": "15.97",
52
- "executions per sec": "62.63",
53
- "executed times": "4",
54
- "sample mean (secs)": "0.02",
55
- "sample deviation": "3.07e-4"
40
+ "test name": "1,000 add & delete randomly",
41
+ "time taken (ms)": "15.90",
42
+ "executions per sec": "62.88",
43
+ "sample deviation": "1.08e-4"
56
44
  },
57
45
  {
58
- "test name": "1000 addMany",
59
- "time taken (ms)": "10.64",
60
- "executions per sec": "94.01",
61
- "executed times": "5",
62
- "sample mean (secs)": "0.01",
63
- "sample deviation": "2.06e-4"
46
+ "test name": "1,000 addMany",
47
+ "time taken (ms)": "10.59",
48
+ "executions per sec": "94.41",
49
+ "sample deviation": "8.39e-5"
64
50
  },
65
51
  {
66
- "test name": "1000 get",
67
- "time taken (ms)": "18.05",
68
- "executions per sec": "55.39",
69
- "executed times": "3",
70
- "sample mean (secs)": "0.02",
71
- "sample deviation": "2.29e-4"
52
+ "test name": "1,000 get",
53
+ "time taken (ms)": "18.01",
54
+ "executions per sec": "55.53",
55
+ "sample deviation": "1.95e-4"
72
56
  },
73
57
  {
74
- "test name": "1000 dfs",
75
- "time taken (ms)": "68.91",
76
- "executions per sec": "14.51",
77
- "executed times": "1",
78
- "sample mean (secs)": "0.07",
79
- "sample deviation": "5.62e-4"
58
+ "test name": "1,000 dfs",
59
+ "time taken (ms)": "69.11",
60
+ "executions per sec": "14.47",
61
+ "sample deviation": "6.47e-4"
80
62
  },
81
63
  {
82
- "test name": "1000 bfs",
83
- "time taken (ms)": "54.57",
84
- "executions per sec": "18.33",
85
- "executed times": "1",
86
- "sample mean (secs)": "0.05",
87
- "sample deviation": "7.02e-4"
64
+ "test name": "1,000 bfs",
65
+ "time taken (ms)": "54.42",
66
+ "executions per sec": "18.38",
67
+ "sample deviation": "4.20e-4"
88
68
  },
89
69
  {
90
- "test name": "1000 morris",
70
+ "test name": "1,000 morris",
91
71
  "time taken (ms)": "37.14",
92
72
  "executions per sec": "26.92",
93
- "executed times": "2",
94
- "sample mean (secs)": "0.04",
95
- "sample deviation": "2.33e-4"
73
+ "sample deviation": "2.27e-4"
96
74
  }
97
75
  ],
98
76
  "testName": "binary-tree"
@@ -100,96 +78,97 @@
100
78
  "bst": {
101
79
  "benchmarks": [
102
80
  {
103
- "test name": "1000 add randomly",
104
- "time taken (ms)": "2.02",
105
- "executions per sec": "494.26",
106
- "executed times": "25",
107
- "sample mean (secs)": "0.00",
108
- "sample deviation": "1.40e-5"
81
+ "test name": "10,000 add randomly",
82
+ "time taken (ms)": "28.48",
83
+ "executions per sec": "35.11",
84
+ "sample deviation": "2.29e-4"
109
85
  },
110
86
  {
111
- "test name": "1000 add & delete randomly",
112
- "time taken (ms)": "4.40",
113
- "executions per sec": "227.23",
114
- "executed times": "12",
115
- "sample mean (secs)": "0.00",
116
- "sample deviation": "4.24e-5"
87
+ "test name": "10,000 add & delete randomly",
88
+ "time taken (ms)": "64.82",
89
+ "executions per sec": "15.43",
90
+ "sample deviation": "0.01"
117
91
  },
118
92
  {
119
- "test name": "1000 addMany",
120
- "time taken (ms)": "2.12",
121
- "executions per sec": "472.41",
122
- "executed times": "25",
123
- "sample mean (secs)": "0.00",
124
- "sample deviation": "3.10e-5"
93
+ "test name": "10,000 addMany",
94
+ "time taken (ms)": "28.74",
95
+ "executions per sec": "34.80",
96
+ "sample deviation": "9.06e-4"
125
97
  },
126
98
  {
127
- "test name": "1000 get",
128
- "time taken (ms)": "2.00",
129
- "executions per sec": "500.77",
130
- "executed times": "26",
131
- "sample mean (secs)": "0.00",
132
- "sample deviation": "2.07e-5"
99
+ "test name": "10,000 get",
100
+ "time taken (ms)": "27.38",
101
+ "executions per sec": "36.52",
102
+ "sample deviation": "1.82e-4"
133
103
  }
134
104
  ],
135
105
  "testName": "bst"
136
106
  },
107
+ "rb-tree": {
108
+ "benchmarks": [
109
+ {
110
+ "test name": "100,000 add randomly",
111
+ "time taken (ms)": "72.30",
112
+ "executions per sec": "13.83",
113
+ "sample deviation": "0.00"
114
+ },
115
+ {
116
+ "test name": "100,000 add & 1000 delete randomly",
117
+ "time taken (ms)": "81.37",
118
+ "executions per sec": "12.29",
119
+ "sample deviation": "0.01"
120
+ },
121
+ {
122
+ "test name": "100,000 getNode",
123
+ "time taken (ms)": "59.48",
124
+ "executions per sec": "16.81",
125
+ "sample deviation": "9.29e-4"
126
+ }
127
+ ],
128
+ "testName": "rb-tree"
129
+ },
137
130
  "directed-graph": {
138
131
  "benchmarks": [
139
132
  {
140
- "test name": "1000 addVertex",
133
+ "test name": "1,000 addVertex",
141
134
  "time taken (ms)": "0.10",
142
- "executions per sec": "1.01e+4",
143
- "executed times": "518",
144
- "sample mean (secs)": "9.88e-5",
145
- "sample deviation": "1.32e-6"
135
+ "executions per sec": "9786.77",
136
+ "sample deviation": "5.56e-7"
146
137
  },
147
138
  {
148
- "test name": "1000 addEdge",
149
- "time taken (ms)": "6.33",
150
- "executions per sec": "157.96",
151
- "executed times": "9",
152
- "sample mean (secs)": "0.01",
153
- "sample deviation": "4.97e-4"
139
+ "test name": "1,000 addEdge",
140
+ "time taken (ms)": "6.02",
141
+ "executions per sec": "166.04",
142
+ "sample deviation": "1.27e-4"
154
143
  },
155
144
  {
156
- "test name": "1000 getVertex",
145
+ "test name": "1,000 getVertex",
157
146
  "time taken (ms)": "0.05",
158
- "executions per sec": "2.17e+4",
159
- "executed times": "1103",
160
- "sample mean (secs)": "4.60e-5",
161
- "sample deviation": "4.30e-7"
147
+ "executions per sec": "2.18e+4",
148
+ "sample deviation": "3.02e-7"
162
149
  },
163
150
  {
164
- "test name": "1000 getEdge",
165
- "time taken (ms)": "24.75",
166
- "executions per sec": "40.41",
167
- "executed times": "3",
168
- "sample mean (secs)": "0.02",
169
- "sample deviation": "0.01"
151
+ "test name": "1,000 getEdge",
152
+ "time taken (ms)": "23.41",
153
+ "executions per sec": "42.71",
154
+ "sample deviation": "0.00"
170
155
  },
171
156
  {
172
157
  "test name": "tarjan",
173
- "time taken (ms)": "227.37",
174
- "executions per sec": "4.40",
175
- "executed times": "1",
176
- "sample mean (secs)": "0.23",
177
- "sample deviation": "0.05"
158
+ "time taken (ms)": "223.51",
159
+ "executions per sec": "4.47",
160
+ "sample deviation": "0.01"
178
161
  },
179
162
  {
180
163
  "test name": "tarjan all",
181
- "time taken (ms)": "210.81",
182
- "executions per sec": "4.74",
183
- "executed times": "1",
184
- "sample mean (secs)": "0.21",
185
- "sample deviation": "9.28e-4"
164
+ "time taken (ms)": "224.89",
165
+ "executions per sec": "4.45",
166
+ "sample deviation": "0.00"
186
167
  },
187
168
  {
188
169
  "test name": "topologicalSort",
189
- "time taken (ms)": "172.00",
190
- "executions per sec": "5.81",
191
- "executed times": "1",
192
- "sample mean (secs)": "0.17",
170
+ "time taken (ms)": "181.90",
171
+ "executions per sec": "5.50",
193
172
  "sample deviation": "0.00"
194
173
  }
195
174
  ],
@@ -198,20 +177,16 @@
198
177
  "heap": {
199
178
  "benchmarks": [
200
179
  {
201
- "test name": "1000 add & pop",
202
- "time taken (ms)": "0.34",
203
- "executions per sec": "2920.80",
204
- "executed times": "148",
205
- "sample mean (secs)": "3.42e-4",
206
- "sample deviation": "2.56e-6"
180
+ "test name": "10,000 add & pop",
181
+ "time taken (ms)": "4.62",
182
+ "executions per sec": "216.33",
183
+ "sample deviation": "3.06e-5"
207
184
  },
208
185
  {
209
- "test name": "1000 fib add & pop",
210
- "time taken (ms)": "3.89",
211
- "executions per sec": "257.21",
212
- "executed times": "14",
213
- "sample mean (secs)": "0.00",
214
- "sample deviation": "3.07e-5"
186
+ "test name": "10,000 fib add & pop",
187
+ "time taken (ms)": "351.41",
188
+ "executions per sec": "2.85",
189
+ "sample deviation": "0.00"
215
190
  }
216
191
  ],
217
192
  "testName": "heap"
@@ -219,28 +194,22 @@
219
194
  "doubly-linked-list": {
220
195
  "benchmarks": [
221
196
  {
222
- "test name": "1000000 unshift",
223
- "time taken (ms)": "208.88",
224
- "executions per sec": "4.79",
225
- "executed times": "1",
226
- "sample mean (secs)": "0.21",
227
- "sample deviation": "0.03"
197
+ "test name": "1,000,000 unshift",
198
+ "time taken (ms)": "214.84",
199
+ "executions per sec": "4.65",
200
+ "sample deviation": "0.04"
228
201
  },
229
202
  {
230
- "test name": "1000000 unshift & shift",
231
- "time taken (ms)": "167.74",
232
- "executions per sec": "5.96",
233
- "executed times": "1",
234
- "sample mean (secs)": "0.17",
203
+ "test name": "1,000,000 unshift & shift",
204
+ "time taken (ms)": "167.11",
205
+ "executions per sec": "5.98",
235
206
  "sample deviation": "0.04"
236
207
  },
237
208
  {
238
- "test name": "1000 insertBefore",
239
- "time taken (ms)": "0.03",
240
- "executions per sec": "3.76e+4",
241
- "executed times": "1902",
242
- "sample mean (secs)": "2.66e-5",
243
- "sample deviation": "2.13e-7"
209
+ "test name": "1,000,000 insertBefore",
210
+ "time taken (ms)": "335.78",
211
+ "executions per sec": "2.98",
212
+ "sample deviation": "0.07"
244
213
  }
245
214
  ],
246
215
  "testName": "doubly-linked-list"
@@ -248,20 +217,16 @@
248
217
  "singly-linked-list": {
249
218
  "benchmarks": [
250
219
  {
251
- "test name": "1000 push & pop",
252
- "time taken (ms)": "1.78",
253
- "executions per sec": "561.53",
254
- "executed times": "30",
255
- "sample mean (secs)": "0.00",
256
- "sample deviation": "1.18e-4"
220
+ "test name": "10,000 push & pop",
221
+ "time taken (ms)": "212.53",
222
+ "executions per sec": "4.71",
223
+ "sample deviation": "0.01"
257
224
  },
258
225
  {
259
- "test name": "1000 insertBefore",
260
- "time taken (ms)": "2.32",
261
- "executions per sec": "430.74",
262
- "executed times": "22",
263
- "sample mean (secs)": "0.00",
264
- "sample deviation": "7.42e-5"
226
+ "test name": "10,000 insertBefore",
227
+ "time taken (ms)": "243.94",
228
+ "executions per sec": "4.10",
229
+ "sample deviation": "0.00"
265
230
  }
266
231
  ],
267
232
  "testName": "singly-linked-list"
@@ -269,12 +234,10 @@
269
234
  "max-priority-queue": {
270
235
  "benchmarks": [
271
236
  {
272
- "test name": "10000 refill & poll",
273
- "time taken (ms)": "11.30",
274
- "executions per sec": "88.52",
275
- "executed times": "5",
276
- "sample mean (secs)": "0.01",
277
- "sample deviation": "2.15e-4"
237
+ "test name": "10,000 refill & poll",
238
+ "time taken (ms)": "11.43",
239
+ "executions per sec": "87.50",
240
+ "sample deviation": "1.84e-4"
278
241
  }
279
242
  ],
280
243
  "testName": "max-priority-queue"
@@ -282,19 +245,15 @@
282
245
  "deque": {
283
246
  "benchmarks": [
284
247
  {
285
- "test name": "1000000 push",
286
- "time taken (ms)": "219.93",
287
- "executions per sec": "4.55",
288
- "executed times": "1",
289
- "sample mean (secs)": "0.22",
248
+ "test name": "1,000,000 push",
249
+ "time taken (ms)": "216.07",
250
+ "executions per sec": "4.63",
290
251
  "sample deviation": "0.05"
291
252
  },
292
253
  {
293
- "test name": "1000000 shift",
294
- "time taken (ms)": "26.22",
295
- "executions per sec": "38.14",
296
- "executed times": "3",
297
- "sample mean (secs)": "0.03",
254
+ "test name": "1,000,000 shift",
255
+ "time taken (ms)": "24.97",
256
+ "executions per sec": "40.05",
298
257
  "sample deviation": "0.00"
299
258
  }
300
259
  ],
@@ -303,20 +262,16 @@
303
262
  "queue": {
304
263
  "benchmarks": [
305
264
  {
306
- "test name": "1000000 push",
307
- "time taken (ms)": "44.03",
308
- "executions per sec": "22.71",
309
- "executed times": "2",
310
- "sample mean (secs)": "0.04",
265
+ "test name": "1,000,000 push",
266
+ "time taken (ms)": "42.57",
267
+ "executions per sec": "23.49",
311
268
  "sample deviation": "0.01"
312
269
  },
313
270
  {
314
- "test name": "1000000 push & shift",
315
- "time taken (ms)": "79.14",
316
- "executions per sec": "12.64",
317
- "executed times": "1",
318
- "sample mean (secs)": "0.08",
319
- "sample deviation": "0.00"
271
+ "test name": "1,000,000 push & shift",
272
+ "time taken (ms)": "79.94",
273
+ "executions per sec": "12.51",
274
+ "sample deviation": "9.99e-4"
320
275
  }
321
276
  ],
322
277
  "testName": "queue"
@@ -324,19 +279,15 @@
324
279
  "trie": {
325
280
  "benchmarks": [
326
281
  {
327
- "test name": "100000 push",
328
- "time taken (ms)": "54.61",
329
- "executions per sec": "18.31",
330
- "executed times": "1",
331
- "sample mean (secs)": "0.05",
282
+ "test name": "100,000 push",
283
+ "time taken (ms)": "54.02",
284
+ "executions per sec": "18.51",
332
285
  "sample deviation": "0.00"
333
286
  },
334
287
  {
335
- "test name": "100000 getWords",
336
- "time taken (ms)": "93.45",
337
- "executions per sec": "10.70",
338
- "executed times": "1",
339
- "sample mean (secs)": "0.09",
288
+ "test name": "100,000 getWords",
289
+ "time taken (ms)": "82.83",
290
+ "executions per sec": "12.07",
340
291
  "sample deviation": "0.00"
341
292
  }
342
293
  ],
@@ -26,6 +26,8 @@ export declare class RedBlackTree {
26
26
  constructor();
27
27
  protected _root: RBTreeNode;
28
28
  get root(): RBTreeNode;
29
+ protected _size: number;
30
+ get size(): number;
29
31
  /**
30
32
  * The `insert` function inserts a new node with a given key into a red-black tree and fixes any
31
33
  * violations of the red-black tree properties.
@@ -33,11 +35,11 @@ export declare class RedBlackTree {
33
35
  * the RBTree.
34
36
  * @returns The function does not explicitly return anything.
35
37
  */
36
- insert(key: number): void;
38
+ add(key: number): void;
37
39
  /**
38
40
  * The `delete` function in TypeScript is used to remove a node with a specific key from a red-black
39
41
  * tree.
40
- * @param {RBTreeNode} node - The `node` parameter is of type `RBTreeNode` and represents the current
42
+ * @param {number} key - The `node` parameter is of type `RBTreeNode` and represents the current
41
43
  * node being processed in the delete operation.
42
44
  * @returns The `delete` function does not return anything. It has a return type of `void`.
43
45
  */
@@ -80,6 +82,7 @@ export declare class RedBlackTree {
80
82
  * @returns the predecessor of the given RBTreeNode 'x'.
81
83
  */
82
84
  getPredecessor(x: RBTreeNode): RBTreeNode;
85
+ clear(): void;
83
86
  print(beginRoot?: RBTreeNode): void;
84
87
  /**
85
88
  * The function performs a left rotation on a red-black tree node.
@@ -30,11 +30,15 @@ exports.NIL = new RBTreeNode(0);
30
30
  */
31
31
  class RedBlackTree {
32
32
  constructor() {
33
+ this._size = 0;
33
34
  this._root = exports.NIL;
34
35
  }
35
36
  get root() {
36
37
  return this._root;
37
38
  }
39
+ get size() {
40
+ return this._size;
41
+ }
38
42
  /**
39
43
  * The `insert` function inserts a new node with a given key into a red-black tree and fixes any
40
44
  * violations of the red-black tree properties.
@@ -42,7 +46,7 @@ class RedBlackTree {
42
46
  * the RBTree.
43
47
  * @returns The function does not explicitly return anything.
44
48
  */
45
- insert(key) {
49
+ add(key) {
46
50
  const node = new RBTreeNode(key, types_1.RBTNColor.RED);
47
51
  node.left = exports.NIL;
48
52
  node.right = exports.NIL;
@@ -69,17 +73,20 @@ class RedBlackTree {
69
73
  }
70
74
  if (node.parent === null) {
71
75
  node.color = types_1.RBTNColor.BLACK;
76
+ this._size++;
72
77
  return;
73
78
  }
74
79
  if (node.parent.parent === null) {
80
+ this._size++;
75
81
  return;
76
82
  }
77
83
  this._fixInsert(node);
84
+ this._size++;
78
85
  }
79
86
  /**
80
87
  * The `delete` function in TypeScript is used to remove a node with a specific key from a red-black
81
88
  * tree.
82
- * @param {RBTreeNode} node - The `node` parameter is of type `RBTreeNode` and represents the current
89
+ * @param {number} key - The `node` parameter is of type `RBTreeNode` and represents the current
83
90
  * node being processed in the delete operation.
84
91
  * @returns The `delete` function does not return anything. It has a return type of `void`.
85
92
  */
@@ -99,6 +106,7 @@ class RedBlackTree {
99
106
  }
100
107
  }
101
108
  if (z === exports.NIL) {
109
+ this._size--;
102
110
  return;
103
111
  }
104
112
  y = z;
@@ -131,6 +139,7 @@ class RedBlackTree {
131
139
  if (yOriginalColor === types_1.RBTNColor.BLACK) {
132
140
  this._fixDelete(x);
133
141
  }
142
+ this._size--;
134
143
  };
135
144
  helper(this.root);
136
145
  }
@@ -219,6 +228,10 @@ class RedBlackTree {
219
228
  }
220
229
  return y;
221
230
  }
231
+ clear() {
232
+ this._root = exports.NIL;
233
+ this._size = 0;
234
+ }
222
235
  print(beginRoot = this.root) {
223
236
  const display = (root) => {
224
237
  const [lines, , ,] = _displayAux(root);