data-structure-typed 1.50.4 → 1.50.5

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 (62) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +116 -55
  3. package/SPECIFICATION.md +2 -2
  4. package/SPECIFICATION_zh-CN.md +81 -0
  5. package/{SPONSOR-zh-CN.md → SPONSOR_zh-CN.md} +1 -1
  6. package/benchmark/report.html +24 -24
  7. package/benchmark/report.json +242 -242
  8. package/dist/cjs/data-structures/base/iterable-base.d.ts +10 -8
  9. package/dist/cjs/data-structures/base/iterable-base.js +8 -12
  10. package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
  11. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -0
  12. package/dist/cjs/data-structures/graph/abstract-graph.js +3 -0
  13. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  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 +14 -76
  16. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +16 -86
  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 +27 -69
  19. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +35 -79
  20. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  21. package/dist/cjs/data-structures/queue/deque.d.ts +0 -53
  22. package/dist/cjs/data-structures/queue/deque.js +0 -61
  23. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  24. package/dist/cjs/data-structures/queue/queue.d.ts +0 -70
  25. package/dist/cjs/data-structures/queue/queue.js +0 -87
  26. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  27. package/dist/mjs/data-structures/base/iterable-base.d.ts +10 -8
  28. package/dist/mjs/data-structures/base/iterable-base.js +8 -12
  29. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -0
  30. package/dist/mjs/data-structures/graph/abstract-graph.js +3 -0
  31. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +14 -76
  32. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +16 -86
  33. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +27 -69
  34. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +33 -79
  35. package/dist/mjs/data-structures/queue/deque.d.ts +0 -53
  36. package/dist/mjs/data-structures/queue/deque.js +0 -61
  37. package/dist/mjs/data-structures/queue/queue.d.ts +0 -70
  38. package/dist/mjs/data-structures/queue/queue.js +0 -86
  39. package/dist/umd/data-structure-typed.js +62 -325
  40. package/dist/umd/data-structure-typed.min.js +2 -2
  41. package/dist/umd/data-structure-typed.min.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/data-structures/base/iterable-base.ts +14 -10
  44. package/src/data-structures/graph/abstract-graph.ts +4 -0
  45. package/src/data-structures/heap/heap.ts +1 -1
  46. package/src/data-structures/linked-list/doubly-linked-list.ts +16 -94
  47. package/src/data-structures/linked-list/singly-linked-list.ts +35 -87
  48. package/src/data-structures/queue/deque.ts +0 -67
  49. package/src/data-structures/queue/queue.ts +0 -98
  50. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +3 -3
  51. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +3 -3
  52. package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
  53. package/test/performance/data-structures/heap/heap.test.ts +14 -14
  54. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +11 -6
  55. package/test/performance/data-structures/queue/deque.test.ts +8 -8
  56. package/test/performance/data-structures/queue/queue.test.ts +5 -12
  57. package/test/performance/reportor.ts +43 -1
  58. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
  59. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +10 -10
  60. package/test/unit/data-structures/linked-list/skip-list.test.ts +4 -4
  61. package/test/unit/data-structures/queue/deque.test.ts +26 -26
  62. package/test/unit/data-structures/queue/queue.test.ts +20 -20
@@ -178,10 +178,6 @@ var dataStructureTyped = (() => {
178
178
 
179
179
  // src/data-structures/base/iterable-base.ts
180
180
  var IterableEntryBase = class {
181
- /**
182
- * Time Complexity: O(n)
183
- * Space Complexity: O(1)
184
- */
185
181
  /**
186
182
  * Time Complexity: O(n)
187
183
  * Space Complexity: O(1)
@@ -299,6 +295,10 @@ var dataStructureTyped = (() => {
299
295
  * Time Complexity: O(n)
300
296
  * Space Complexity: O(1)
301
297
  */
298
+ /**
299
+ * Time Complexity: O(n)
300
+ * Space Complexity: O(1)
301
+ */
302
302
  /**
303
303
  * Time Complexity: O(n)
304
304
  * Space Complexity: O(1)
@@ -413,10 +413,6 @@ var dataStructureTyped = (() => {
413
413
  }
414
414
  return;
415
415
  }
416
- /**
417
- * Time Complexity: O(n)
418
- * Space Complexity: O(1)
419
- */
420
416
  /**
421
417
  * Time Complexity: O(n)
422
418
  * Space Complexity: O(1)
@@ -513,6 +509,10 @@ var dataStructureTyped = (() => {
513
509
  * Time Complexity: O(n)
514
510
  * Space Complexity: O(1)
515
511
  */
512
+ /**
513
+ * Time Complexity: O(n)
514
+ * Space Complexity: O(1)
515
+ */
516
516
  /**
517
517
  * Time Complexity: O(n)
518
518
  * Space Complexity: O(1)
@@ -587,10 +587,6 @@ var dataStructureTyped = (() => {
587
587
  }
588
588
  return;
589
589
  }
590
- /**
591
- * Time Complexity: O(n)
592
- * Space Complexity: O(1)
593
- */
594
590
  /**
595
591
  * Time Complexity: O(n)
596
592
  * Space Complexity: O(1)
@@ -1663,6 +1659,24 @@ var dataStructureTyped = (() => {
1663
1659
  get tail() {
1664
1660
  return this._tail;
1665
1661
  }
1662
+ /**
1663
+ * The above function returns the value of the first element in a linked list, or undefined if the
1664
+ * list is empty.
1665
+ * @returns The value of the first node in the linked list, or undefined if the linked list is empty.
1666
+ */
1667
+ get first() {
1668
+ var _a;
1669
+ return (_a = this.head) == null ? void 0 : _a.value;
1670
+ }
1671
+ /**
1672
+ * The function returns the value of the last element in a linked list, or undefined if the list is
1673
+ * empty.
1674
+ * @returns The value of the last node in the linked list, or undefined if the linked list is empty.
1675
+ */
1676
+ get last() {
1677
+ var _a;
1678
+ return (_a = this.tail) == null ? void 0 : _a.value;
1679
+ }
1666
1680
  /**
1667
1681
  * The function returns the size of an object.
1668
1682
  * @returns The size of the object, which is a number.
@@ -1695,19 +1709,18 @@ var dataStructureTyped = (() => {
1695
1709
  /**
1696
1710
  * Time Complexity: O(1)
1697
1711
  * Space Complexity: O(1)
1698
- * Constant time, as it involves basic pointer adjustments.
1699
- * Constant space, as it only creates a new node.
1700
1712
  */
1701
1713
  /**
1702
1714
  * Time Complexity: O(1)
1703
1715
  * Space Complexity: O(1)
1704
1716
  *
1705
- * The `push` function adds a new node with the given value to the end of a singly linked list.
1706
- * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
1707
- * any type (E) as specified in the generic type declaration of the class or function.
1717
+ * The push function adds a new element to the end of a singly linked list.
1718
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
1719
+ * add to the linked list.
1720
+ * @returns The `push` method is returning a boolean value, `true`.
1708
1721
  */
1709
- push(value) {
1710
- const newNode = new SinglyLinkedListNode(value);
1722
+ push(element) {
1723
+ const newNode = new SinglyLinkedListNode(element);
1711
1724
  if (!this.head) {
1712
1725
  this._head = newNode;
1713
1726
  this._tail = newNode;
@@ -1718,21 +1731,6 @@ var dataStructureTyped = (() => {
1718
1731
  this._size++;
1719
1732
  return true;
1720
1733
  }
1721
- /**
1722
- * Time Complexity: O(1)
1723
- * Space Complexity: O(1)
1724
- */
1725
- /**
1726
- * Time Complexity: O(1)
1727
- * Space Complexity: O(1)
1728
- *
1729
- * The `push` function adds a new node with the given value to the end of a singly linked list.
1730
- * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
1731
- * any type (E) as specified in the generic type declaration of the class or function.
1732
- */
1733
- addLast(value) {
1734
- return this.push(value);
1735
- }
1736
1734
  /**
1737
1735
  * Time Complexity: O(n)
1738
1736
  * Space Complexity: O(1)
@@ -1742,10 +1740,9 @@ var dataStructureTyped = (() => {
1742
1740
  * Time Complexity: O(n)
1743
1741
  * Space Complexity: O(1)
1744
1742
  *
1745
- * The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
1746
- * pointers accordingly.
1747
- * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
1748
- * the linked list is empty, it returns `undefined`.
1743
+ * The `pop` function removes and returns the value of the last element in a linked list.
1744
+ * @returns The method is returning the value of the element that is being popped from the end of the
1745
+ * list.
1749
1746
  */
1750
1747
  pop() {
1751
1748
  if (!this.head)
@@ -1767,22 +1764,6 @@ var dataStructureTyped = (() => {
1767
1764
  this._size--;
1768
1765
  return value;
1769
1766
  }
1770
- /**
1771
- * Time Complexity: O(n)
1772
- * Space Complexity: O(1)
1773
- */
1774
- /**
1775
- * Time Complexity: O(n)
1776
- * Space Complexity: O(1)
1777
- *
1778
- * The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
1779
- * pointers accordingly.
1780
- * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
1781
- * the linked list is empty, it returns `undefined`.
1782
- */
1783
- pollLast() {
1784
- return this.pop();
1785
- }
1786
1767
  /**
1787
1768
  * Time Complexity: O(1)
1788
1769
  * Space Complexity: O(1)
@@ -1791,8 +1772,8 @@ var dataStructureTyped = (() => {
1791
1772
  * Time Complexity: O(1)
1792
1773
  * Space Complexity: O(1)
1793
1774
  *
1794
- * The `shift()` function removes and returns the value of the first node in a linked list.
1795
- * @returns The value of the node that is being removed from the beginning of the linked list.
1775
+ * The `shift()` function removes and returns the value of the first element in a linked list.
1776
+ * @returns The value of the removed node.
1796
1777
  */
1797
1778
  shift() {
1798
1779
  if (!this.head)
@@ -1810,26 +1791,13 @@ var dataStructureTyped = (() => {
1810
1791
  * Time Complexity: O(1)
1811
1792
  * Space Complexity: O(1)
1812
1793
  *
1813
- * The `pollFirst()` function removes and returns the value of the first node in a linked list.
1814
- * @returns The value of the node that is being removed from the beginning of the linked list.
1815
- */
1816
- pollFirst() {
1817
- return this.shift();
1818
- }
1819
- /**
1820
- * Time Complexity: O(1)
1821
- * Space Complexity: O(1)
1794
+ * The unshift function adds a new element to the beginning of a singly linked list.
1795
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
1796
+ * add to the beginning of the singly linked list.
1797
+ * @returns The `unshift` method is returning a boolean value, `true`.
1822
1798
  */
1823
- /**
1824
- * Time Complexity: O(1)
1825
- * Space Complexity: O(1)
1826
- *
1827
- * The unshift function adds a new node with the given value to the beginning of a singly linked list.
1828
- * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
1829
- * linked list.
1830
- */
1831
- unshift(value) {
1832
- const newNode = new SinglyLinkedListNode(value);
1799
+ unshift(element) {
1800
+ const newNode = new SinglyLinkedListNode(element);
1833
1801
  if (!this.head) {
1834
1802
  this._head = newNode;
1835
1803
  this._tail = newNode;
@@ -1840,25 +1808,9 @@ var dataStructureTyped = (() => {
1840
1808
  this._size++;
1841
1809
  return true;
1842
1810
  }
1843
- /**
1844
- * Time Complexity: O(1)
1845
- * Space Complexity: O(1)
1846
- */
1847
- /**
1848
- * Time Complexity: O(1)
1849
- * Space Complexity: O(1)
1850
- *
1851
- * The addFirst function adds a new node with the given value to the beginning of a singly linked list.
1852
- * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
1853
- * linked list.
1854
- */
1855
- addFirst(value) {
1856
- return this.unshift(value);
1857
- }
1858
1811
  /**
1859
1812
  * Time Complexity: O(n)
1860
1813
  * Space Complexity: O(1)
1861
- * Linear time, where n is the index, as it may need to traverse the list to find the desired node.
1862
1814
  */
1863
1815
  /**
1864
1816
  * Time Complexity: O(n)
@@ -2467,14 +2419,13 @@ var dataStructureTyped = (() => {
2467
2419
  * Space Complexity: O(1)
2468
2420
  */
2469
2421
  /**
2470
- * Time Complexity: O(1)
2471
- * Space Complexity: O(1)
2472
- *
2473
- * The push function adds a new node with the given value to the end of the doubly linked list.
2474
- * @param {E} value - The value to be added to the linked list.
2422
+ * The push function adds a new element to the end of a doubly linked list.
2423
+ * @param {E} element - The "element" parameter represents the value that you want to add to the
2424
+ * doubly linked list.
2425
+ * @returns The `push` method is returning a boolean value, `true`.
2475
2426
  */
2476
- push(value) {
2477
- const newNode = new DoublyLinkedListNode(value);
2427
+ push(element) {
2428
+ const newNode = new DoublyLinkedListNode(element);
2478
2429
  if (!this.head) {
2479
2430
  this._head = newNode;
2480
2431
  this._tail = newNode;
@@ -2491,12 +2442,8 @@ var dataStructureTyped = (() => {
2491
2442
  * Space Complexity: O(1)
2492
2443
  */
2493
2444
  /**
2494
- * Time Complexity: O(1)
2495
- * Space Complexity: O(1)
2496
- *
2497
- * The `pop()` function removes and returns the value of the last node in a doubly linked list.
2498
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
2499
- * list is empty, it returns undefined.
2445
+ * The `pop()` function removes and returns the value of the last element in a linked list.
2446
+ * @returns The method is returning the value of the removed node.
2500
2447
  */
2501
2448
  pop() {
2502
2449
  if (!this.tail)
@@ -2517,12 +2464,8 @@ var dataStructureTyped = (() => {
2517
2464
  * Space Complexity: O(1)
2518
2465
  */
2519
2466
  /**
2520
- * Time Complexity: O(1)
2521
- * Space Complexity: O(1)
2522
- *
2523
- * The `shift()` function removes and returns the value of the first node in a doubly linked list.
2524
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
2525
- * list.
2467
+ * The `shift()` function removes and returns the value of the first element in a doubly linked list.
2468
+ * @returns The value of the removed node.
2526
2469
  */
2527
2470
  shift() {
2528
2471
  if (!this.head)
@@ -2543,15 +2486,13 @@ var dataStructureTyped = (() => {
2543
2486
  * Space Complexity: O(1)
2544
2487
  */
2545
2488
  /**
2546
- * Time Complexity: O(1)
2547
- * Space Complexity: O(1)
2548
- *
2549
- * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
2550
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
2551
- * doubly linked list.
2489
+ * The unshift function adds a new element to the beginning of a doubly linked list.
2490
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
2491
+ * add to the beginning of the doubly linked list.
2492
+ * @returns The `unshift` method is returning a boolean value, `true`.
2552
2493
  */
2553
- unshift(value) {
2554
- const newNode = new DoublyLinkedListNode(value);
2494
+ unshift(element) {
2495
+ const newNode = new DoublyLinkedListNode(element);
2555
2496
  if (!this.head) {
2556
2497
  this._head = newNode;
2557
2498
  this._tail = newNode;
@@ -3035,65 +2976,6 @@ var dataStructureTyped = (() => {
3035
2976
  }
3036
2977
  return mappedList;
3037
2978
  }
3038
- /**
3039
- * Time Complexity: O(1)
3040
- * Space Complexity: O(1)
3041
- */
3042
- /**
3043
- * Time Complexity: O(1)
3044
- * Space Complexity: O(1)
3045
- *
3046
- * The addLast function adds a new node with the given value to the end of the doubly linked list.
3047
- * @param {E} value - The value to be added to the linked list.
3048
- */
3049
- addLast(value) {
3050
- return this.push(value);
3051
- }
3052
- /**
3053
- * Time Complexity: O(1)
3054
- * Space Complexity: O(1)
3055
- */
3056
- /**
3057
- * Time Complexity: O(1)
3058
- * Space Complexity: O(1)
3059
- *
3060
- * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
3061
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
3062
- * list is empty, it returns undefined.
3063
- */
3064
- pollLast() {
3065
- return this.pop();
3066
- }
3067
- /**
3068
- * Time Complexity: O(1)
3069
- * Space Complexity: O(1)
3070
- */
3071
- /**
3072
- * Time Complexity: O(1)
3073
- * Space Complexity: O(1)
3074
- *
3075
- * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
3076
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
3077
- * list.
3078
- */
3079
- pollFirst() {
3080
- return this.shift();
3081
- }
3082
- /**
3083
- * Time Complexity: O(1)
3084
- * Space Complexity: O(1)
3085
- */
3086
- /**
3087
- * Time Complexity: O(1)
3088
- * Space Complexity: O(1)
3089
- *
3090
- * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
3091
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
3092
- * doubly linked list.
3093
- */
3094
- addFirst(value) {
3095
- this.unshift(value);
3096
- }
3097
2979
  /**
3098
2980
  * The function returns an iterator that iterates over the values of a linked list.
3099
2981
  */
@@ -3760,64 +3642,6 @@ var dataStructureTyped = (() => {
3760
3642
  const spliced = this.elements.splice(index, 1);
3761
3643
  return spliced.length === 1;
3762
3644
  }
3763
- /**
3764
- * Time Complexity: O(1)
3765
- * Space Complexity: O(1)
3766
- */
3767
- /**
3768
- * Time Complexity: O(1)
3769
- * Space Complexity: O(1)
3770
- *
3771
- * The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
3772
- * @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
3773
- * the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
3774
- */
3775
- peek() {
3776
- return this.first;
3777
- }
3778
- /**
3779
- * Time Complexity: O(1)
3780
- * Space Complexity: O(1)
3781
- */
3782
- /**
3783
- * Time Complexity: O(1)
3784
- * Space Complexity: O(1)
3785
- *
3786
- * The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
3787
- * @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
3788
- * array is empty, it returns `undefined`.
3789
- */
3790
- peekLast() {
3791
- return this.last;
3792
- }
3793
- /**
3794
- * Time Complexity: O(1)
3795
- * Space Complexity: O(1)
3796
- */
3797
- /**
3798
- * Time Complexity: O(1)
3799
- * Space Complexity: O(1)
3800
- *
3801
- * The enqueue function adds a value to the end of a queue.
3802
- * @param {E} value - The value parameter represents the value that you want to add to the queue.
3803
- */
3804
- enqueue(value) {
3805
- return this.push(value);
3806
- }
3807
- /**
3808
- * Time Complexity: O(1)
3809
- * Space Complexity: O(1)
3810
- */
3811
- /**
3812
- * Time Complexity: O(1)
3813
- * Space Complexity: O(1)
3814
- *
3815
- * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
3816
- * @returns The method is returning a value of type E or undefined.
3817
- */
3818
- dequeue() {
3819
- return this.shift();
3820
- }
3821
3645
  /**
3822
3646
  * Time Complexity: O(1)
3823
3647
  * Space Complexity: O(1)
@@ -3963,35 +3787,6 @@ var dataStructureTyped = (() => {
3963
3787
  }
3964
3788
  };
3965
3789
  var LinkedListQueue = class _LinkedListQueue extends SinglyLinkedList {
3966
- /**
3967
- * The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
3968
- * @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
3969
- */
3970
- get first() {
3971
- var _a;
3972
- return (_a = this.head) == null ? void 0 : _a.value;
3973
- }
3974
- /**
3975
- * The enqueue function adds a value to the end of an array.
3976
- * @param {E} value - The value parameter represents the value that you want to add to the queue.
3977
- */
3978
- enqueue(value) {
3979
- return this.push(value);
3980
- }
3981
- /**
3982
- * The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
3983
- * @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
3984
- */
3985
- dequeue() {
3986
- return this.shift();
3987
- }
3988
- /**
3989
- * The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
3990
- * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
3991
- */
3992
- peek() {
3993
- return this.first;
3994
- }
3995
3790
  /**
3996
3791
  * Time Complexity: O(n)
3997
3792
  * Space Complexity: O(n)
@@ -4753,67 +4548,6 @@ var dataStructureTyped = (() => {
4753
4548
  }
4754
4549
  return newDeque;
4755
4550
  }
4756
- /**
4757
- * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
4758
- * Space Complexity: O(n) - Due to potential resizing.
4759
- */
4760
- /**
4761
- * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
4762
- * Space Complexity: O(n) - Due to potential resizing.
4763
- *
4764
- * The addLast function adds an element to the end of an array.
4765
- * @param {E} element - The element parameter represents the element that you want to add to the end of the
4766
- * data structure.
4767
- */
4768
- addLast(element) {
4769
- return this.push(element);
4770
- }
4771
- /**
4772
- * Time Complexity: O(1)
4773
- * Space Complexity: O(1)
4774
- */
4775
- /**
4776
- * Time Complexity: O(1)
4777
- * Space Complexity: O(1)
4778
- *
4779
- * The function "pollLast" removes and returns the last element of an array.
4780
- * @returns The last element of the array is being returned.
4781
- */
4782
- pollLast() {
4783
- return this.pop();
4784
- }
4785
- /**
4786
- * Time Complexity: O(1)
4787
- * Space Complexity: O(1)
4788
- * /
4789
-
4790
- /**
4791
- * Time Complexity: O(1)
4792
- * Space Complexity: O(1)
4793
- *
4794
- * The "addFirst" function adds an element to the beginning of an array.
4795
- * @param {E} element - The parameter "element" represents the element that you want to add to the
4796
- * beginning of the data structure.
4797
- */
4798
- addFirst(element) {
4799
- return this.unshift(element);
4800
- }
4801
- /**
4802
- * Time Complexity: O(1)
4803
- * Space Complexity: O(1)
4804
- * /
4805
-
4806
- /**
4807
- * Time Complexity: O(1)
4808
- * Space Complexity: O(1)
4809
- *
4810
- * The function "pollFirst" removes and returns the first element of an array.
4811
- * @returns The method `pollFirst()` is returning the first element of the array after removing it
4812
- * from the beginning. If the array is empty, it will return `undefined`.
4813
- */
4814
- pollFirst() {
4815
- return this.shift();
4816
- }
4817
4551
  /**
4818
4552
  * Time Complexity: O(n)
4819
4553
  * Space Complexity: O(1)
@@ -5786,6 +5520,9 @@ var dataStructureTyped = (() => {
5786
5520
  set vertexMap(v) {
5787
5521
  this._vertexMap = v;
5788
5522
  }
5523
+ get size() {
5524
+ return this._vertexMap.size;
5525
+ }
5789
5526
  /**
5790
5527
  * Time Complexity: O(1) - Constant time for Map lookup.
5791
5528
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.