data-structure-typed 1.49.1 → 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.
Files changed (85) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +16 -16
  3. package/README_zh-CN.md +2 -2
  4. package/benchmark/report.html +46 -1
  5. package/benchmark/report.json +457 -22
  6. package/dist/cjs/data-structures/base/iterable-base.d.ts +11 -0
  7. package/dist/cjs/data-structures/base/iterable-base.js +21 -0
  8. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  9. package/dist/cjs/data-structures/hash/hash-map.d.ts +9 -9
  10. package/dist/cjs/data-structures/hash/hash-map.js +16 -15
  11. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  12. package/dist/cjs/data-structures/heap/heap.d.ts +6 -35
  13. package/dist/cjs/data-structures/heap/heap.js +10 -42
  14. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  15. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +87 -93
  16. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +126 -129
  17. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  18. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  19. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +42 -42
  20. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  21. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  22. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +2 -2
  23. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  24. package/dist/cjs/data-structures/queue/deque.d.ts +70 -75
  25. package/dist/cjs/data-structures/queue/deque.js +100 -110
  26. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  27. package/dist/cjs/data-structures/queue/queue.d.ts +13 -14
  28. package/dist/cjs/data-structures/queue/queue.js +15 -18
  29. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  30. package/dist/cjs/data-structures/stack/stack.d.ts +2 -3
  31. package/dist/cjs/data-structures/stack/stack.js +2 -5
  32. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  33. package/dist/cjs/data-structures/trie/trie.d.ts +1 -2
  34. package/dist/cjs/data-structures/trie/trie.js +2 -5
  35. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  36. package/dist/mjs/data-structures/base/iterable-base.d.ts +11 -0
  37. package/dist/mjs/data-structures/base/iterable-base.js +21 -0
  38. package/dist/mjs/data-structures/hash/hash-map.d.ts +9 -9
  39. package/dist/mjs/data-structures/hash/hash-map.js +16 -15
  40. package/dist/mjs/data-structures/heap/heap.d.ts +6 -35
  41. package/dist/mjs/data-structures/heap/heap.js +10 -42
  42. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +87 -93
  43. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +125 -128
  44. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  45. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +43 -43
  46. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  47. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +2 -2
  48. package/dist/mjs/data-structures/queue/deque.d.ts +70 -75
  49. package/dist/mjs/data-structures/queue/deque.js +100 -110
  50. package/dist/mjs/data-structures/queue/queue.d.ts +13 -14
  51. package/dist/mjs/data-structures/queue/queue.js +15 -18
  52. package/dist/mjs/data-structures/stack/stack.d.ts +2 -3
  53. package/dist/mjs/data-structures/stack/stack.js +2 -5
  54. package/dist/mjs/data-structures/trie/trie.d.ts +1 -2
  55. package/dist/mjs/data-structures/trie/trie.js +2 -5
  56. package/dist/umd/data-structure-typed.js +338 -370
  57. package/dist/umd/data-structure-typed.min.js +2 -2
  58. package/dist/umd/data-structure-typed.min.js.map +1 -1
  59. package/package.json +1 -1
  60. package/src/data-structures/base/iterable-base.ts +24 -0
  61. package/src/data-structures/hash/hash-map.ts +27 -28
  62. package/src/data-structures/heap/heap.ts +19 -57
  63. package/src/data-structures/linked-list/doubly-linked-list.ts +138 -142
  64. package/src/data-structures/linked-list/singly-linked-list.ts +49 -49
  65. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  66. package/src/data-structures/queue/deque.ts +122 -135
  67. package/src/data-structures/queue/queue.ts +19 -23
  68. package/src/data-structures/stack/stack.ts +4 -8
  69. package/src/data-structures/trie/trie.ts +5 -9
  70. package/test/performance/data-structures/comparison/comparison.test.ts +6 -6
  71. package/test/performance/data-structures/heap/heap.test.ts +2 -2
  72. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +2 -2
  73. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +2 -2
  74. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +2 -2
  75. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +2 -2
  76. package/test/unit/data-structures/hash/hash-map.test.ts +2 -2
  77. package/test/unit/data-structures/heap/heap.test.ts +1 -1
  78. package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
  79. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +30 -30
  80. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
  81. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +21 -21
  82. package/test/unit/data-structures/linked-list/skip-list.test.ts +2 -2
  83. package/test/unit/data-structures/queue/deque.test.ts +5 -5
  84. package/test/unit/data-structures/queue/queue.test.ts +4 -4
  85. package/test/unit/data-structures/trie/trie.test.ts +1 -1
@@ -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)": "17.61",
7
- "executions per sec": "56.79",
8
- "sample deviation": "4.75e-4"
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)": "23.21",
13
- "executions per sec": "43.08",
14
- "sample deviation": "0.00"
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)": "17.89",
19
- "executions per sec": "55.90",
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)": "17.71",
25
- "executions per sec": "56.47",
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)": "17.15",
31
- "executions per sec": "58.30",
32
- "sample deviation": "2.88e-4"
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)": "161.44",
37
- "executions per sec": "6.19",
38
- "sample deviation": "0.00"
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)": "57.53",
43
- "executions per sec": "17.38",
44
- "sample deviation": "0.00"
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)": "258.22",
49
- "executions per sec": "3.87",
50
- "sample deviation": "0.00"
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;;;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AAE,CAAC;gBACvD,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,SAAsC,EAAE,OAAa;QACxD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAS,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,EAAE,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;CAGF;AA9ID,kDA8IC"}
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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D,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"}
@@ -42,13 +42,13 @@ export declare class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {
42
42
  * @param {V} value - The value parameter represents the value that you want to associate with the
43
43
  * key in the data structure.
44
44
  */
45
- set(key: K, value: V): void;
45
+ set(key: K, value: V): boolean;
46
46
  /**
47
47
  * The function "setMany" sets multiple key-value pairs in a map.
48
48
  * @param elements - The `elements` parameter is an iterable containing key-value pairs. Each
49
49
  * key-value pair is represented as an array with two elements: the key and the value.
50
50
  */
51
- setMany(elements: Iterable<[K, V]>): void;
51
+ setMany(elements: Iterable<[K, V]>): boolean[];
52
52
  /**
53
53
  * The `get` function retrieves a value from a map based on a given key, either from an object map or
54
54
  * a string map.
@@ -114,6 +114,7 @@ export declare class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {
114
114
  */
115
115
  filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): HashMap<K, V>;
116
116
  print(): void;
117
+ put(key: K, value: V): boolean;
117
118
  /**
118
119
  * The function returns an iterator that yields key-value pairs from both an object store and an
119
120
  * object map.
@@ -178,10 +179,9 @@ export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K
178
179
  * value associated with the key being set in the data structure.
179
180
  * @returns the size of the data structure after the key-value pair has been set.
180
181
  */
181
- set(key: K, value?: V): number;
182
+ set(key: K, value?: V): boolean;
182
183
  has(key: K): boolean;
183
- hasValue(value: V): boolean;
184
- setMany(entries: Iterable<[K, V]>): void;
184
+ setMany(entries: Iterable<[K, V]>): boolean[];
185
185
  /**
186
186
  * Time Complexity: O(1)
187
187
  * Space Complexity: O(1)
@@ -207,7 +207,7 @@ export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K
207
207
  * the specified index in the data structure. The key-value pair is represented as a tuple `[K, V]`,
208
208
  * where `K` is the key and `V` is the value.
209
209
  */
210
- getAt(index: number): [K, V];
210
+ getAt(index: number): V | undefined;
211
211
  /**
212
212
  * Time Complexity: O(1)
213
213
  * Space Complexity: O(1)
@@ -228,7 +228,7 @@ export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K
228
228
  * deleted in the linked list.
229
229
  * @returns The size of the list after deleting the element at the specified index.
230
230
  */
231
- deleteAt(index: number): number;
231
+ deleteAt(index: number): boolean;
232
232
  /**
233
233
  * Time Complexity: O(1)
234
234
  * Space Complexity: O(1)
@@ -288,7 +288,7 @@ export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K
288
288
  * function.
289
289
  */
290
290
  map<NV>(callback: EntryCallback<K, V, NV>, thisArg?: any): LinkedHashMap<K, NV>;
291
- print(): void;
291
+ put(key: K, value: V): boolean;
292
292
  /**
293
293
  * Time Complexity: O(n), where n is the number of elements in the LinkedHashMap.
294
294
  * Space Complexity: O(1)
@@ -306,5 +306,5 @@ export declare class LinkedHashMap<K = any, V = any> extends IterableEntryBase<K
306
306
  * represents a node in a linked list. It contains a key-value pair and references to the previous
307
307
  * and next nodes in the list.
308
308
  */
309
- protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): void;
309
+ protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): boolean;
310
310
  }