data-structure-typed 1.45.0 → 1.45.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.
Files changed (144) hide show
  1. package/.eslintrc.js +6 -6
  2. package/CHANGELOG.md +1 -1
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  4. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  5. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  6. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  9. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  10. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  11. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  12. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  13. package/dist/cjs/data-structures/hash/hash-map.d.ts +58 -58
  14. package/dist/cjs/data-structures/hash/hash-map.js +73 -73
  15. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  16. package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
  17. package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
  18. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  19. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  20. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  21. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  22. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  23. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  24. package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
  25. package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
  26. package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
  27. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  28. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  29. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  30. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  31. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  32. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  33. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  34. package/dist/cjs/utils/utils.js.map +1 -1
  35. package/dist/mjs/data-structures/hash/hash-map.d.ts +58 -58
  36. package/dist/mjs/data-structures/hash/hash-map.js +76 -76
  37. package/dist/umd/data-structure-typed.js +74 -72
  38. package/dist/umd/data-structure-typed.min.js +1 -1
  39. package/dist/umd/data-structure-typed.min.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/data-structures/binary-tree/avl-tree.ts +7 -7
  42. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
  43. package/src/data-structures/binary-tree/binary-tree.ts +39 -31
  44. package/src/data-structures/binary-tree/bst.ts +12 -8
  45. package/src/data-structures/binary-tree/rb-tree.ts +17 -6
  46. package/src/data-structures/binary-tree/segment-tree.ts +1 -1
  47. package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
  48. package/src/data-structures/graph/abstract-graph.ts +46 -31
  49. package/src/data-structures/graph/directed-graph.ts +10 -5
  50. package/src/data-structures/graph/map-graph.ts +8 -8
  51. package/src/data-structures/graph/undirected-graph.ts +9 -9
  52. package/src/data-structures/hash/hash-map.ts +103 -103
  53. package/src/data-structures/hash/hash-table.ts +1 -1
  54. package/src/data-structures/hash/tree-map.ts +2 -1
  55. package/src/data-structures/hash/tree-set.ts +2 -1
  56. package/src/data-structures/heap/heap.ts +8 -5
  57. package/src/data-structures/heap/max-heap.ts +3 -3
  58. package/src/data-structures/heap/min-heap.ts +3 -3
  59. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  60. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  61. package/src/data-structures/matrix/matrix.ts +2 -2
  62. package/src/data-structures/matrix/matrix2d.ts +1 -1
  63. package/src/data-structures/matrix/navigator.ts +3 -3
  64. package/src/data-structures/matrix/vector2d.ts +2 -1
  65. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
  66. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
  67. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  68. package/src/data-structures/queue/deque.ts +5 -4
  69. package/src/data-structures/queue/queue.ts +2 -2
  70. package/src/data-structures/tree/tree.ts +1 -1
  71. package/src/data-structures/trie/trie.ts +1 -1
  72. package/src/interfaces/binary-tree.ts +2 -2
  73. package/src/interfaces/graph.ts +1 -1
  74. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
  75. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  76. package/src/types/data-structures/binary-tree/bst.ts +2 -2
  77. package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
  78. package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
  79. package/src/types/data-structures/hash/hash-map.ts +6 -6
  80. package/src/types/data-structures/matrix/navigator.ts +1 -1
  81. package/src/types/utils/utils.ts +1 -1
  82. package/src/types/utils/validate-type.ts +18 -4
  83. package/src/utils/utils.ts +6 -6
  84. package/test/integration/all-in-one.ts +1 -1
  85. package/test/integration/avl-tree.test.ts +1 -1
  86. package/test/integration/bst.test.ts +19 -19
  87. package/test/integration/heap.test.js +1 -1
  88. package/test/integration/index.html +7 -7
  89. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
  90. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
  91. package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
  92. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +6 -6
  93. package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
  94. package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
  95. package/test/performance/data-structures/heap/heap.test.ts +5 -5
  96. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
  97. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
  98. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
  99. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
  100. package/test/performance/data-structures/queue/deque.test.ts +5 -5
  101. package/test/performance/data-structures/queue/queue.test.ts +6 -6
  102. package/test/performance/data-structures/stack/stack.test.ts +6 -6
  103. package/test/performance/data-structures/trie/trie.test.ts +4 -4
  104. package/test/performance/reportor.ts +15 -13
  105. package/test/performance/types/reportor.ts +1 -1
  106. package/test/types/utils/json2html.ts +1 -1
  107. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +6 -6
  108. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
  109. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
  110. package/test/unit/data-structures/binary-tree/bst.test.ts +44 -40
  111. package/test/unit/data-structures/binary-tree/overall.test.ts +17 -17
  112. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
  113. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
  114. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +35 -35
  115. package/test/unit/data-structures/graph/abstract-graph.test.ts +7 -7
  116. package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
  117. package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
  118. package/test/unit/data-structures/graph/overall.test.ts +1 -1
  119. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  120. package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
  121. package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
  122. package/test/unit/data-structures/hash/hash-map.test.ts +10 -12
  123. package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
  124. package/test/unit/data-structures/heap/heap.test.ts +35 -23
  125. package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
  126. package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
  127. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +5 -5
  128. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +5 -5
  129. package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
  130. package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
  131. package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
  132. package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
  133. package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
  134. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
  135. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
  136. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -19
  137. package/test/unit/data-structures/queue/deque.test.ts +3 -3
  138. package/test/unit/data-structures/queue/queue.test.ts +3 -3
  139. package/test/unit/data-structures/stack/stack.test.ts +1 -1
  140. package/test/unit/data-structures/tree/tree.test.ts +1 -1
  141. package/test/unit/data-structures/trie/trie.test.ts +1 -1
  142. package/test/utils/array.ts +1 -1
  143. package/test/utils/big-o.ts +4 -4
  144. package/test/utils/json2html.ts +7 -3
@@ -624,8 +624,8 @@ var dataStructureTyped = (() => {
624
624
  */
625
625
  constructor(node, sentinel, hashMap, iterateDirection = 0 /* DEFAULT */) {
626
626
  __publicField(this, "hashMap");
627
- __publicField(this, "_node");
628
627
  __publicField(this, "iterateDirection");
628
+ __publicField(this, "_node");
629
629
  __publicField(this, "_sentinel");
630
630
  this._node = node;
631
631
  this._sentinel = sentinel;
@@ -713,12 +713,12 @@ var dataStructureTyped = (() => {
713
713
  * `K` represents the type of the key and `V` represents the
714
714
  */
715
715
  constructor(hashMap = []) {
716
+ __publicField(this, "OBJ_KEY_INDEX", Symbol("OBJ_KEY_INDEX"));
716
717
  __publicField(this, "_nodes", []);
717
718
  __publicField(this, "_orgMap", {});
718
719
  __publicField(this, "_head");
719
720
  __publicField(this, "_tail");
720
721
  __publicField(this, "_sentinel");
721
- __publicField(this, "OBJ_KEY_INDEX", Symbol("OBJ_KEY_INDEX"));
722
722
  __publicField(this, "_size", 0);
723
723
  Object.setPrototypeOf(this._orgMap, null);
724
724
  this._sentinel = {};
@@ -730,6 +730,75 @@ var dataStructureTyped = (() => {
730
730
  get size() {
731
731
  return this._size;
732
732
  }
733
+ /**
734
+ * Time Complexity: O(1)
735
+ * Space Complexity: O(1)
736
+ *
737
+ * The function returns a new iterator object for a HashMap.
738
+ * @returns A new instance of the HashMapIterator class is being returned.
739
+ */
740
+ get begin() {
741
+ return new HashMapIterator(this._head, this._sentinel, this);
742
+ }
743
+ /**
744
+ * Time Complexity: O(1)
745
+ * Space Complexity: O(1)
746
+ *
747
+ * The function returns a new HashMapIterator object with the _sentinel value as both the start and
748
+ * end values.
749
+ * @returns A new instance of the HashMapIterator class is being returned.
750
+ */
751
+ get end() {
752
+ return new HashMapIterator(this._sentinel, this._sentinel, this);
753
+ }
754
+ /**
755
+ * Time Complexity: O(1)
756
+ * Space Complexity: O(1)
757
+ *
758
+ * The reverseBegin function returns a new HashMapIterator object that iterates over the elements of
759
+ * a HashMap in reverse order.
760
+ * @returns A new instance of the HashMapIterator class is being returned.
761
+ */
762
+ get reverseBegin() {
763
+ return new HashMapIterator(this._tail, this._sentinel, this, 1 /* REVERSE */);
764
+ }
765
+ /**
766
+ * Time Complexity: O(1)
767
+ * Space Complexity: O(1)
768
+ *
769
+ * The reverseEnd function returns a new HashMapIterator object that iterates over the elements of a
770
+ * HashMap in reverse order.
771
+ * @returns A new instance of the HashMapIterator class is being returned.
772
+ */
773
+ get reverseEnd() {
774
+ return new HashMapIterator(this._sentinel, this._sentinel, this, 1 /* REVERSE */);
775
+ }
776
+ /**
777
+ * Time Complexity: O(1)
778
+ * Space Complexity: O(1)
779
+ *
780
+ * The function returns the key-value pair at the front of a data structure.
781
+ * @returns The front element of the data structure, represented as a tuple with a key (K) and a
782
+ * value (V).
783
+ */
784
+ get front() {
785
+ if (this._size === 0)
786
+ return;
787
+ return [this._head.key, this._head.value];
788
+ }
789
+ /**
790
+ * Time Complexity: O(1)
791
+ * Space Complexity: O(1)
792
+ *
793
+ * The function returns the key-value pair at the end of a data structure.
794
+ * @returns The method is returning an array containing the key-value pair of the tail element in the
795
+ * data structure.
796
+ */
797
+ get back() {
798
+ if (this._size === 0)
799
+ return;
800
+ return [this._tail.key, this._tail.value];
801
+ }
733
802
  /**
734
803
  * Time Complexity: O(1)
735
804
  * Space Complexity: O(1)
@@ -928,75 +997,6 @@ var dataStructureTyped = (() => {
928
997
  this._size = 0;
929
998
  this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
930
999
  }
931
- /**
932
- * Time Complexity: O(1)
933
- * Space Complexity: O(1)
934
- *
935
- * The function returns a new iterator object for a HashMap.
936
- * @returns A new instance of the HashMapIterator class is being returned.
937
- */
938
- get begin() {
939
- return new HashMapIterator(this._head, this._sentinel, this);
940
- }
941
- /**
942
- * Time Complexity: O(1)
943
- * Space Complexity: O(1)
944
- *
945
- * The function returns a new HashMapIterator object with the _sentinel value as both the start and
946
- * end values.
947
- * @returns A new instance of the HashMapIterator class is being returned.
948
- */
949
- get end() {
950
- return new HashMapIterator(this._sentinel, this._sentinel, this);
951
- }
952
- /**
953
- * Time Complexity: O(1)
954
- * Space Complexity: O(1)
955
- *
956
- * The reverseBegin function returns a new HashMapIterator object that iterates over the elements of
957
- * a HashMap in reverse order.
958
- * @returns A new instance of the HashMapIterator class is being returned.
959
- */
960
- get reverseBegin() {
961
- return new HashMapIterator(this._tail, this._sentinel, this, 1 /* REVERSE */);
962
- }
963
- /**
964
- * Time Complexity: O(1)
965
- * Space Complexity: O(1)
966
- *
967
- * The reverseEnd function returns a new HashMapIterator object that iterates over the elements of a
968
- * HashMap in reverse order.
969
- * @returns A new instance of the HashMapIterator class is being returned.
970
- */
971
- get reverseEnd() {
972
- return new HashMapIterator(this._sentinel, this._sentinel, this, 1 /* REVERSE */);
973
- }
974
- /**
975
- * Time Complexity: O(1)
976
- * Space Complexity: O(1)
977
- *
978
- * The function returns the key-value pair at the front of a data structure.
979
- * @returns The front element of the data structure, represented as a tuple with a key (K) and a
980
- * value (V).
981
- */
982
- get front() {
983
- if (this._size === 0)
984
- return;
985
- return [this._head.key, this._head.value];
986
- }
987
- /**
988
- * Time Complexity: O(1)
989
- * Space Complexity: O(1)
990
- *
991
- * The function returns the key-value pair at the end of a data structure.
992
- * @returns The method is returning an array containing the key-value pair of the tail element in the
993
- * data structure.
994
- */
995
- get back() {
996
- if (this._size === 0)
997
- return;
998
- return [this._tail.key, this._tail.value];
999
- }
1000
1000
  /**
1001
1001
  * Time Complexity: O(n), where n is the number of elements in the HashMap.
1002
1002
  * Space Complexity: O(1)
@@ -7860,7 +7860,9 @@ var dataStructureTyped = (() => {
7860
7860
  return super.addMany(keysOrNodes, data).map((n) => n != null ? n : void 0);
7861
7861
  }
7862
7862
  const inserted = [];
7863
- const combinedArr = keysOrNodes.map((value, index) => [value, data == null ? void 0 : data[index]]);
7863
+ const combinedArr = keysOrNodes.map(
7864
+ (value, index) => [value, data == null ? void 0 : data[index]]
7865
+ );
7864
7866
  let sorted = [];
7865
7867
  function _isNodeOrUndefinedTuple(arr) {
7866
7868
  for (const [keyOrNode] of arr)