binary-tree-typed 2.5.0 → 2.5.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 (90) hide show
  1. package/dist/cjs/index.cjs +771 -68
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +771 -68
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +771 -69
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +771 -69
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/base/index.d.ts +1 -0
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/binary-tree-typed.js +773 -71
  47. package/dist/umd/binary-tree-typed.js.map +1 -1
  48. package/dist/umd/binary-tree-typed.min.js +5 -5
  49. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -145,6 +145,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
145
145
 
146
146
 
147
147
 
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
148
172
  * @example
149
173
  * // Check if empty
150
174
  * const map = new HashMap();
@@ -164,6 +188,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
164
188
 
165
189
 
166
190
 
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
167
215
  * @example
168
216
  * // Remove all entries
169
217
  * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
@@ -176,7 +224,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
176
224
  * @remarks Time O(1), Space O(1)
177
225
  * @returns True if the value is a 2-tuple.
178
226
  */
179
- isEntry(rawElement: any): rawElement is [K, V];
227
+ isEntry(rawElement: unknown): rawElement is [K, V];
180
228
  /**
181
229
  * Insert or replace a single entry.
182
230
  * @remarks Time O(1), Space O(1)
@@ -203,6 +251,54 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
203
251
 
204
252
 
205
253
 
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
206
302
 
207
303
 
208
304
  * @example
@@ -239,6 +335,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
239
335
 
240
336
 
241
337
 
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
242
362
  * @example
243
363
  * // Add multiple entries
244
364
  * const map = new HashMap<string, number>();
@@ -262,6 +382,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
262
382
 
263
383
 
264
384
 
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
265
409
  * @example
266
410
  * // HashMap get and has operations
267
411
  * const map = new HashMap<string, number>([
@@ -301,6 +445,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
301
445
 
302
446
 
303
447
 
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
304
472
  * @example
305
473
  * // Check key existence
306
474
  * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
@@ -325,6 +493,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
325
493
 
326
494
 
327
495
 
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
328
520
  * @example
329
521
  * // Remove entries by key
330
522
  * const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
@@ -354,6 +546,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
354
546
 
355
547
 
356
548
 
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
357
573
  * @example
358
574
  * // Create independent copy
359
575
  * const map = new HashMap<string, number>([['a', 1]]);
@@ -380,6 +596,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
380
596
 
381
597
 
382
598
 
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
383
623
  * @example
384
624
  * // Transform all values
385
625
  * const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
@@ -388,7 +628,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
388
628
  * console.log(doubled.get('apple')); // 2;
389
629
  * console.log(doubled.get('banana')); // 4;
390
630
  */
391
- map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: any): any;
631
+ map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: unknown): HashMap<K, VM>;
392
632
  /**
393
633
  * Filter entries into a new map.
394
634
  * @remarks Time O(N), Space O(N)
@@ -406,6 +646,30 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
406
646
 
407
647
 
408
648
 
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
409
673
  * @example
410
674
  * // HashMap iteration and filter operations
411
675
  * const map = new HashMap<number, string>([
@@ -432,7 +696,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
432
696
  * console.log(values); // contains 3; // 'Bob', 'Eve'
433
697
  * console.log(values); // contains 7;
434
698
  */
435
- filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): any;
699
+ filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): any;
436
700
  /**
437
701
  * (Protected) Create a like-kind instance and seed it from an iterable.
438
702
  * @remarks Time O(N), Space O(N)
@@ -443,10 +707,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
443
707
  * @param [options] - Options forwarded to the constructor.
444
708
  * @returns A like-kind map instance.
445
709
  */
446
- protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: any): any;
710
+ protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: Record<string, unknown>): this;
447
711
  protected _rehashNoObj(): void;
448
712
  protected _getIterator(): IterableIterator<[K, V]>;
449
- protected _isObjKey(key: any): key is object | ((...args: any[]) => any);
713
+ protected _isObjKey(key: unknown): key is object | ((...args: unknown[]) => unknown);
450
714
  protected _getNoObjKey(key: K): string;
451
715
  }
452
716
  /**
@@ -561,10 +825,10 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
561
825
  */
562
826
  deleteAt(index: number): boolean;
563
827
  isEmpty(): boolean;
564
- isEntry(rawElement: any): rawElement is [K, V];
828
+ isEntry(rawElement: unknown): rawElement is [K, V];
565
829
  clear(): void;
566
- clone(): any;
567
- filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): any;
830
+ clone(): this;
831
+ filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): this;
568
832
  /**
569
833
  * Map each entry to a new [key, value] pair and preserve order.
570
834
  * @remarks Time O(N), Space O(N)
@@ -574,8 +838,8 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
574
838
  * @param [thisArg] - Value for `this` inside the callback.
575
839
  * @returns A new map of the same class with transformed entries.
576
840
  */
577
- map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: any): any;
841
+ map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: unknown): LinkedHashMap<MK, MV>;
578
842
  protected _getIterator(): IterableIterator<[K, V]>;
579
843
  protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): boolean;
580
- protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: any): any;
844
+ protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: Record<string, unknown>): this;
581
845
  }