max-priority-queue-typed 2.5.0 → 2.5.1
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/dist/cjs/index.cjs +294 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +294 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +294 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +294 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/max-priority-queue-typed.js +294 -0
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -145,6 +145,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
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
|
+
|
|
148
169
|
* @example
|
|
149
170
|
* // Check if empty
|
|
150
171
|
* const sl = new SkipList<number, string>();
|
|
@@ -164,6 +185,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
164
185
|
|
|
165
186
|
|
|
166
187
|
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
167
209
|
* @example
|
|
168
210
|
* // Remove all entries
|
|
169
211
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
@@ -186,6 +228,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
186
228
|
|
|
187
229
|
|
|
188
230
|
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
189
252
|
* @example
|
|
190
253
|
* // Create independent copy
|
|
191
254
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
@@ -217,6 +280,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
217
280
|
|
|
218
281
|
|
|
219
282
|
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
220
304
|
* @example
|
|
221
305
|
* // In-memory sorted key-value store
|
|
222
306
|
* const store = new SkipList<number, string>();
|
|
@@ -278,6 +362,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
278
362
|
|
|
279
363
|
|
|
280
364
|
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
281
386
|
* @example
|
|
282
387
|
* // Building a sorted index
|
|
283
388
|
* type Product = { id: number; name: string; price: number };
|
|
@@ -287,8 +392,8 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
287
392
|
* { id: 3, name: 'Doohickey', price: 15 }
|
|
288
393
|
* ];
|
|
289
394
|
*
|
|
290
|
-
* const index = new SkipList<number, Product>(products
|
|
291
|
-
* toEntryFn: (p:
|
|
395
|
+
* const index = new SkipList<number, Product, Product>(products, {
|
|
396
|
+
* toEntryFn: (p: Product) => [p.price, p]
|
|
292
397
|
* });
|
|
293
398
|
*
|
|
294
399
|
* // Iterate in sorted order by price
|
|
@@ -318,6 +423,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
318
423
|
|
|
319
424
|
|
|
320
425
|
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
321
447
|
* @example
|
|
322
448
|
* // Check key existence
|
|
323
449
|
* const sl = new SkipList<number, string>([[1, 'a'], [3, 'c'], [5, 'e']]);
|
|
@@ -341,6 +467,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
341
467
|
|
|
342
468
|
|
|
343
469
|
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
344
491
|
* @example
|
|
345
492
|
* // Fast lookup with deletion
|
|
346
493
|
* const cache = new SkipList<string, number>();
|
|
@@ -389,6 +536,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
389
536
|
|
|
390
537
|
|
|
391
538
|
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
392
560
|
* @example
|
|
393
561
|
* // Access the minimum entry
|
|
394
562
|
* const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
|
|
@@ -412,6 +580,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
412
580
|
|
|
413
581
|
|
|
414
582
|
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
415
604
|
* @example
|
|
416
605
|
* // Access the maximum entry
|
|
417
606
|
* const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
|
|
@@ -437,6 +626,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
437
626
|
|
|
438
627
|
|
|
439
628
|
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
440
650
|
* @example
|
|
441
651
|
* // Remove and return smallest
|
|
442
652
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
@@ -460,6 +670,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
460
670
|
|
|
461
671
|
|
|
462
672
|
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
463
694
|
* @example
|
|
464
695
|
* // Remove and return largest
|
|
465
696
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
@@ -486,6 +717,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
486
717
|
|
|
487
718
|
|
|
488
719
|
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
489
741
|
* @example
|
|
490
742
|
* // Least entry ≥ key
|
|
491
743
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -517,6 +769,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
517
769
|
|
|
518
770
|
|
|
519
771
|
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
520
793
|
* @example
|
|
521
794
|
* // Greatest entry ≤ key
|
|
522
795
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -548,6 +821,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
548
821
|
|
|
549
822
|
|
|
550
823
|
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
551
845
|
* @example
|
|
552
846
|
* // Strictly greater entry
|
|
553
847
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -576,6 +870,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
576
870
|
|
|
577
871
|
|
|
578
872
|
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
579
894
|
* @example
|
|
580
895
|
* // Strictly less entry
|
|
581
896
|
* const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
|
|
@@ -610,6 +925,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
610
925
|
|
|
611
926
|
|
|
612
927
|
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
613
949
|
* @example
|
|
614
950
|
* // Find entries in a range
|
|
615
951
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e']]);
|
|
@@ -659,6 +995,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
659
995
|
|
|
660
996
|
|
|
661
997
|
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
662
1019
|
* @example
|
|
663
1020
|
* // Transform entries
|
|
664
1021
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
|
|
@@ -688,6 +1045,27 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
688
1045
|
|
|
689
1046
|
|
|
690
1047
|
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
691
1069
|
* @example
|
|
692
1070
|
* // Filter entries
|
|
693
1071
|
* const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
@@ -200,6 +200,27 @@ export class Matrix {
|
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
203
224
|
* @example
|
|
204
225
|
* // Get and set individual cells
|
|
205
226
|
* const m = new Matrix([
|
|
@@ -245,6 +266,27 @@ export class Matrix {
|
|
|
245
266
|
|
|
246
267
|
|
|
247
268
|
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
248
290
|
* @example
|
|
249
291
|
* // Modify individual cells
|
|
250
292
|
* const m = Matrix.zeros(2, 2);
|
|
@@ -287,6 +329,27 @@ export class Matrix {
|
|
|
287
329
|
|
|
288
330
|
|
|
289
331
|
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
290
353
|
* @example
|
|
291
354
|
* // Basic matrix arithmetic
|
|
292
355
|
* const a = new Matrix([
|
|
@@ -353,6 +416,27 @@ export class Matrix {
|
|
|
353
416
|
|
|
354
417
|
|
|
355
418
|
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
356
440
|
* @example
|
|
357
441
|
* // Element-wise subtraction
|
|
358
442
|
* const a = Matrix.from([[5, 6], [7, 8]]);
|
|
@@ -402,6 +486,27 @@ export class Matrix {
|
|
|
402
486
|
|
|
403
487
|
|
|
404
488
|
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
405
510
|
* @example
|
|
406
511
|
* // Matrix multiplication for transformations
|
|
407
512
|
* // 2x3 matrix * 3x2 matrix = 2x2 matrix
|
|
@@ -473,6 +578,27 @@ export class Matrix {
|
|
|
473
578
|
|
|
474
579
|
|
|
475
580
|
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
476
602
|
* @example
|
|
477
603
|
* // Matrix transpose (square matrix)
|
|
478
604
|
* const m = new Matrix([
|
|
@@ -531,6 +657,27 @@ export class Matrix {
|
|
|
531
657
|
|
|
532
658
|
|
|
533
659
|
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
534
681
|
* @example
|
|
535
682
|
* // Compute the inverse of a 2x2 matrix
|
|
536
683
|
* const m = Matrix.from([[4, 7], [2, 6]]);
|
|
@@ -633,6 +780,27 @@ export class Matrix {
|
|
|
633
780
|
|
|
634
781
|
|
|
635
782
|
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
636
804
|
* @example
|
|
637
805
|
* // Dot product of two matrices
|
|
638
806
|
* const a = Matrix.from([[1, 2], [3, 4]]);
|
|
@@ -749,7 +917,7 @@ export class Matrix {
|
|
|
749
917
|
if (i < data.length) {
|
|
750
918
|
return { value: [...data[i++]], done: false };
|
|
751
919
|
}
|
|
752
|
-
return { value: undefined
|
|
920
|
+
return { value: undefined, done: true } as IteratorResult<number[]>;
|
|
753
921
|
}
|
|
754
922
|
};
|
|
755
923
|
}
|