data-structure-typed 1.19.3 → 1.19.4

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 (155) hide show
  1. package/dist/data-structures/binary-tree/aa-tree.js +2 -5
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.js +361 -488
  3. package/dist/data-structures/binary-tree/avl-tree.js +46 -90
  4. package/dist/data-structures/binary-tree/b-tree.js +2 -5
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +17 -22
  6. package/dist/data-structures/binary-tree/binary-tree.js +9 -31
  7. package/dist/data-structures/binary-tree/bst.js +96 -139
  8. package/dist/data-structures/binary-tree/rb-tree.js +32 -56
  9. package/dist/data-structures/binary-tree/segment-tree.js +78 -120
  10. package/dist/data-structures/binary-tree/splay-tree.js +2 -5
  11. package/dist/data-structures/binary-tree/tree-multiset.js +176 -253
  12. package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
  13. package/dist/data-structures/graph/abstract-graph.js +340 -574
  14. package/dist/data-structures/graph/directed-graph.js +146 -276
  15. package/dist/data-structures/graph/undirected-graph.js +87 -176
  16. package/dist/data-structures/hash/coordinate-map.js +23 -45
  17. package/dist/data-structures/hash/coordinate-set.js +20 -42
  18. package/dist/data-structures/hash/hash-table.js +2 -5
  19. package/dist/data-structures/hash/pair.js +2 -5
  20. package/dist/data-structures/hash/tree-map.js +2 -5
  21. package/dist/data-structures/hash/tree-set.js +2 -5
  22. package/dist/data-structures/heap/heap.js +53 -77
  23. package/dist/data-structures/heap/max-heap.js +8 -26
  24. package/dist/data-structures/heap/min-heap.js +8 -26
  25. package/dist/data-structures/linked-list/doubly-linked-list.js +132 -197
  26. package/dist/data-structures/linked-list/singly-linked-list.js +112 -173
  27. package/dist/data-structures/linked-list/skip-linked-list.js +2 -5
  28. package/dist/data-structures/matrix/matrix.js +7 -8
  29. package/dist/data-structures/matrix/matrix2d.js +76 -93
  30. package/dist/data-structures/matrix/navigator.js +18 -37
  31. package/dist/data-structures/matrix/vector2d.js +80 -101
  32. package/dist/data-structures/priority-queue/max-priority-queue.js +11 -39
  33. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -39
  34. package/dist/data-structures/priority-queue/priority-queue.js +93 -139
  35. package/dist/data-structures/queue/deque.js +82 -128
  36. package/dist/data-structures/queue/queue.js +24 -25
  37. package/dist/data-structures/stack/stack.js +21 -22
  38. package/dist/data-structures/tree/tree.js +32 -45
  39. package/dist/data-structures/trie/trie.js +93 -200
  40. package/dist/utils/utils.js +22 -107
  41. package/dist/utils/validate-type.js +2 -2
  42. package/package.json +1 -1
  43. package/src/assets/complexities-diff.jpg +0 -0
  44. package/src/assets/data-structure-complexities.jpg +0 -0
  45. package/src/assets/logo.png +0 -0
  46. package/src/assets/overview-diagram-of-data-structures.png +0 -0
  47. package/src/data-structures/binary-tree/aa-tree.ts +3 -0
  48. package/src/data-structures/binary-tree/abstract-binary-tree.ts +1528 -0
  49. package/src/data-structures/binary-tree/avl-tree.ts +297 -0
  50. package/src/data-structures/binary-tree/b-tree.ts +3 -0
  51. package/src/data-structures/binary-tree/binary-indexed-tree.ts +78 -0
  52. package/src/data-structures/binary-tree/binary-tree.ts +40 -0
  53. package/src/data-structures/binary-tree/bst.ts +435 -0
  54. package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  55. package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  56. package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  57. package/src/data-structures/binary-tree/index.ts +12 -0
  58. package/src/data-structures/binary-tree/rb-tree.ts +102 -0
  59. package/src/data-structures/binary-tree/segment-tree.ts +243 -0
  60. package/src/data-structures/binary-tree/splay-tree.ts +3 -0
  61. package/src/data-structures/binary-tree/tree-multiset.ts +694 -0
  62. package/src/data-structures/binary-tree/two-three-tree.ts +3 -0
  63. package/src/data-structures/diagrams/README.md +5 -0
  64. package/src/data-structures/graph/abstract-graph.ts +1032 -0
  65. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  66. package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  67. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  68. package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  69. package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  70. package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  71. package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  72. package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  73. package/src/data-structures/graph/diagrams/mst.jpg +0 -0
  74. package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  75. package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  76. package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  77. package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  78. package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  79. package/src/data-structures/graph/directed-graph.ts +472 -0
  80. package/src/data-structures/graph/index.ts +3 -0
  81. package/src/data-structures/graph/undirected-graph.ts +270 -0
  82. package/src/data-structures/hash/coordinate-map.ts +67 -0
  83. package/src/data-structures/hash/coordinate-set.ts +56 -0
  84. package/src/data-structures/hash/hash-table.ts +3 -0
  85. package/src/data-structures/hash/index.ts +6 -0
  86. package/src/data-structures/hash/pair.ts +3 -0
  87. package/src/data-structures/hash/tree-map.ts +3 -0
  88. package/src/data-structures/hash/tree-set.ts +3 -0
  89. package/src/data-structures/heap/heap.ts +183 -0
  90. package/src/data-structures/heap/index.ts +3 -0
  91. package/src/data-structures/heap/max-heap.ts +31 -0
  92. package/src/data-structures/heap/min-heap.ts +34 -0
  93. package/src/data-structures/index.ts +15 -0
  94. package/src/data-structures/interfaces/abstract-binary-tree.ts +231 -0
  95. package/src/data-structures/interfaces/abstract-graph.ts +40 -0
  96. package/src/data-structures/interfaces/avl-tree.ts +28 -0
  97. package/src/data-structures/interfaces/binary-tree.ts +8 -0
  98. package/src/data-structures/interfaces/bst.ts +32 -0
  99. package/src/data-structures/interfaces/directed-graph.ts +20 -0
  100. package/src/data-structures/interfaces/doubly-linked-list.ts +1 -0
  101. package/src/data-structures/interfaces/heap.ts +1 -0
  102. package/src/data-structures/interfaces/index.ts +15 -0
  103. package/src/data-structures/interfaces/navigator.ts +1 -0
  104. package/src/data-structures/interfaces/priority-queue.ts +1 -0
  105. package/src/data-structures/interfaces/rb-tree.ts +11 -0
  106. package/src/data-structures/interfaces/segment-tree.ts +1 -0
  107. package/src/data-structures/interfaces/singly-linked-list.ts +1 -0
  108. package/src/data-structures/interfaces/tree-multiset.ts +12 -0
  109. package/src/data-structures/interfaces/undirected-graph.ts +6 -0
  110. package/src/data-structures/linked-list/doubly-linked-list.ts +573 -0
  111. package/src/data-structures/linked-list/index.ts +3 -0
  112. package/src/data-structures/linked-list/singly-linked-list.ts +490 -0
  113. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  114. package/src/data-structures/matrix/index.ts +4 -0
  115. package/src/data-structures/matrix/matrix.ts +27 -0
  116. package/src/data-structures/matrix/matrix2d.ts +208 -0
  117. package/src/data-structures/matrix/navigator.ts +122 -0
  118. package/src/data-structures/matrix/vector2d.ts +316 -0
  119. package/src/data-structures/priority-queue/index.ts +3 -0
  120. package/src/data-structures/priority-queue/max-priority-queue.ts +49 -0
  121. package/src/data-structures/priority-queue/min-priority-queue.ts +50 -0
  122. package/src/data-structures/priority-queue/priority-queue.ts +354 -0
  123. package/src/data-structures/queue/deque.ts +251 -0
  124. package/src/data-structures/queue/index.ts +2 -0
  125. package/src/data-structures/queue/queue.ts +120 -0
  126. package/src/data-structures/stack/index.ts +1 -0
  127. package/src/data-structures/stack/stack.ts +98 -0
  128. package/src/data-structures/tree/index.ts +1 -0
  129. package/src/data-structures/tree/tree.ts +69 -0
  130. package/src/data-structures/trie/index.ts +1 -0
  131. package/src/data-structures/trie/trie.ts +227 -0
  132. package/src/data-structures/types/abstract-binary-tree.ts +42 -0
  133. package/src/data-structures/types/abstract-graph.ts +5 -0
  134. package/src/data-structures/types/avl-tree.ts +5 -0
  135. package/src/data-structures/types/binary-tree.ts +9 -0
  136. package/src/data-structures/types/bst.ts +12 -0
  137. package/src/data-structures/types/directed-graph.ts +8 -0
  138. package/src/data-structures/types/doubly-linked-list.ts +1 -0
  139. package/src/data-structures/types/heap.ts +5 -0
  140. package/src/data-structures/types/helpers.ts +1 -0
  141. package/src/data-structures/types/index.ts +15 -0
  142. package/src/data-structures/types/navigator.ts +13 -0
  143. package/src/data-structures/types/priority-queue.ts +9 -0
  144. package/src/data-structures/types/rb-tree.ts +8 -0
  145. package/src/data-structures/types/segment-tree.ts +1 -0
  146. package/src/data-structures/types/singly-linked-list.ts +1 -0
  147. package/src/data-structures/types/tree-multiset.ts +8 -0
  148. package/src/index.ts +2 -0
  149. package/src/utils/index.ts +3 -0
  150. package/src/utils/types/index.ts +2 -0
  151. package/src/utils/types/utils.ts +6 -0
  152. package/src/utils/types/validate-type.ts +25 -0
  153. package/src/utils/utils.ts +78 -0
  154. package/src/utils/validate-type.ts +69 -0
  155. package/tsconfig.json +1 -1
@@ -8,61 +8,42 @@ exports.Vector2D = void 0;
8
8
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
9
9
  * @license MIT License
10
10
  */
11
- var Vector2D = /** @class */ (function () {
12
- function Vector2D(x, y, w // needed for matrix multiplication
11
+ class Vector2D {
12
+ constructor(x = 0, y = 0, w = 1 // needed for matrix multiplication
13
13
  ) {
14
- if (x === void 0) { x = 0; }
15
- if (y === void 0) { y = 0; }
16
- if (w === void 0) { w = 1; }
17
14
  this.x = x;
18
15
  this.y = y;
19
16
  this.w = w;
20
17
  }
21
- Object.defineProperty(Vector2D.prototype, "isZero", {
22
- /**
23
- * The function checks if the x and y values of a point are both zero.
24
- * @returns A boolean value indicating whether both the x and y properties of the object are equal to 0.
25
- */
26
- get: function () {
27
- return this.x === 0 && this.y === 0;
28
- },
29
- enumerable: false,
30
- configurable: true
31
- });
32
- Object.defineProperty(Vector2D.prototype, "length", {
33
- /**
34
- * The above function calculates the length of a vector using the Pythagorean theorem.
35
- * @returns The length of a vector, calculated using the Pythagorean theorem.
36
- */
37
- get: function () {
38
- return Math.sqrt((this.x * this.x) + (this.y * this.y));
39
- },
40
- enumerable: false,
41
- configurable: true
42
- });
43
- Object.defineProperty(Vector2D.prototype, "lengthSq", {
44
- /**
45
- * The function calculates the square of the length of a vector.
46
- * @returns The method is returning the sum of the squares of the x and y values.
47
- */
48
- get: function () {
49
- return (this.x * this.x) + (this.y * this.y);
50
- },
51
- enumerable: false,
52
- configurable: true
53
- });
54
- Object.defineProperty(Vector2D.prototype, "rounded", {
55
- /**
56
- * The "rounded" function returns a new Vector2D object with the x and y values rounded to the nearest whole number.
57
- * @returns The method is returning a new instance of the Vector2D class with the x and y values rounded to the nearest
58
- * whole number.
59
- */
60
- get: function () {
61
- return new Vector2D(Math.round(this.x), Math.round(this.y));
62
- },
63
- enumerable: false,
64
- configurable: true
65
- });
18
+ /**
19
+ * The function checks if the x and y values of a point are both zero.
20
+ * @returns A boolean value indicating whether both the x and y properties of the object are equal to 0.
21
+ */
22
+ get isZero() {
23
+ return this.x === 0 && this.y === 0;
24
+ }
25
+ /**
26
+ * The above function calculates the length of a vector using the Pythagorean theorem.
27
+ * @returns The length of a vector, calculated using the Pythagorean theorem.
28
+ */
29
+ get length() {
30
+ return Math.sqrt((this.x * this.x) + (this.y * this.y));
31
+ }
32
+ /**
33
+ * The function calculates the square of the length of a vector.
34
+ * @returns The method is returning the sum of the squares of the x and y values.
35
+ */
36
+ get lengthSq() {
37
+ return (this.x * this.x) + (this.y * this.y);
38
+ }
39
+ /**
40
+ * The "rounded" function returns a new Vector2D object with the x and y values rounded to the nearest whole number.
41
+ * @returns The method is returning a new instance of the Vector2D class with the x and y values rounded to the nearest
42
+ * whole number.
43
+ */
44
+ get rounded() {
45
+ return new Vector2D(Math.round(this.x), Math.round(this.y));
46
+ }
66
47
  /**
67
48
  * The function "add" takes two Vector2D objects as parameters and returns a new Vector2D object with the sum of their
68
49
  * x and y components.
@@ -73,9 +54,9 @@ var Vector2D = /** @class */ (function () {
73
54
  * @returns The method is returning a new instance of the Vector2D class with the x and y components of the two input
74
55
  * vectors added together.
75
56
  */
76
- Vector2D.add = function (vector1, vector2) {
57
+ static add(vector1, vector2) {
77
58
  return new Vector2D(vector1.x + vector2.x, vector1.y + vector2.y);
78
- };
59
+ }
79
60
  /**
80
61
  * The subtract function takes two Vector2D objects as parameters and returns a new Vector2D object with the x and y
81
62
  * components subtracted.
@@ -87,9 +68,9 @@ var Vector2D = /** @class */ (function () {
87
68
  * @returns The method is returning a new Vector2D object with the x and y components subtracted from vector1 and
88
69
  * vector2.
89
70
  */
90
- Vector2D.subtract = function (vector1, vector2) {
71
+ static subtract(vector1, vector2) {
91
72
  return new Vector2D(vector1.x - vector2.x, vector1.y - vector2.y);
92
- };
73
+ }
93
74
  /**
94
75
  * The function subtracts a given value from the x and y components of a Vector2D object and returns a new Vector2D
95
76
  * object.
@@ -99,9 +80,9 @@ var Vector2D = /** @class */ (function () {
99
80
  * of the "vector" parameter.
100
81
  * @returns A new Vector2D object with the x and y values subtracted by the given value.
101
82
  */
102
- Vector2D.subtractValue = function (vector, value) {
83
+ static subtractValue(vector, value) {
103
84
  return new Vector2D(vector.x - value, vector.y - value);
104
- };
85
+ }
105
86
  /**
106
87
  * The function multiplies a Vector2D object by a given value.
107
88
  * @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with
@@ -110,9 +91,9 @@ var Vector2D = /** @class */ (function () {
110
91
  * of the vector will be multiplied.
111
92
  * @returns A new Vector2D object with the x and y values multiplied by the given value.
112
93
  */
113
- Vector2D.multiply = function (vector, value) {
94
+ static multiply(vector, value) {
114
95
  return new Vector2D(vector.x * value, vector.y * value);
115
- };
96
+ }
116
97
  /**
117
98
  * The function divides the x and y components of a Vector2D by a given value and returns a new Vector2D.
118
99
  * @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector with
@@ -121,9 +102,9 @@ var Vector2D = /** @class */ (function () {
121
102
  * vector.
122
103
  * @returns A new instance of the Vector2D class with the x and y values divided by the given value.
123
104
  */
124
- Vector2D.divide = function (vector, value) {
105
+ static divide(vector, value) {
125
106
  return new Vector2D(vector.x / value, vector.y / value);
126
- };
107
+ }
127
108
  /**
128
109
  * The function checks if two Vector2D objects are equal by comparing their x and y values.
129
110
  * @param {Vector2D} vector1 - The parameter `vector1` is of type `Vector2D`, which represents a 2-dimensional vector.
@@ -131,9 +112,9 @@ var Vector2D = /** @class */ (function () {
131
112
  * @param {Vector2D} vector2 - The parameter "vector2" is of type Vector2D.
132
113
  * @returns a boolean value, which indicates whether the two input vectors are equal or not.
133
114
  */
134
- Vector2D.equals = function (vector1, vector2) {
115
+ static equals(vector1, vector2) {
135
116
  return vector1.x === vector2.x && vector1.y === vector2.y;
136
- };
117
+ }
137
118
  /**
138
119
  * The function checks if two Vector2D objects are equal within a specified rounding factor.
139
120
  * @param {Vector2D} vector1 - The first vector to compare.
@@ -144,27 +125,26 @@ var Vector2D = /** @class */ (function () {
144
125
  * roundingFactor, the vectors are considered equal.
145
126
  * @returns a boolean value.
146
127
  */
147
- Vector2D.equalsRounded = function (vector1, vector2, roundingFactor) {
148
- if (roundingFactor === void 0) { roundingFactor = 12; }
149
- var vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
128
+ static equalsRounded(vector1, vector2, roundingFactor = 12) {
129
+ const vector = Vector2D.abs(Vector2D.subtract(vector1, vector2));
150
130
  if (vector.x < roundingFactor && vector.y < roundingFactor) {
151
131
  return true;
152
132
  }
153
133
  return false;
154
- };
134
+ }
155
135
  /**
156
136
  * The normalize function takes a vector as input and returns a normalized version of the vector.Normalizes the vector if it matches a certain condition
157
137
  * @param {Vector2D} vector - The parameter "vector" is of type Vector2D.
158
138
  * @returns the normalized vector if its length is greater than a very small value (epsilon), otherwise it returns the
159
139
  * original vector.
160
140
  */
161
- Vector2D.normalize = function (vector) {
162
- var length = vector.length;
141
+ static normalize(vector) {
142
+ const length = vector.length;
163
143
  if (length > 2.220446049250313e-16) { // Epsilon
164
144
  return Vector2D.divide(vector, length);
165
145
  }
166
146
  return vector;
167
- };
147
+ }
168
148
  /**
169
149
  * The function truncates a vector to a maximum length if it exceeds that length.Adjusts x and y so that the length of the vector does not exceed max
170
150
  * @param {Vector2D} vector - A 2D vector represented by the Vector2D class.
@@ -173,29 +153,29 @@ var Vector2D = /** @class */ (function () {
173
153
  * @returns either the original vector or a truncated version of the vector, depending on whether the length of the
174
154
  * vector is greater than the maximum value specified.
175
155
  */
176
- Vector2D.truncate = function (vector, max) {
156
+ static truncate(vector, max) {
177
157
  if (vector.length > max) {
178
158
  return Vector2D.multiply(Vector2D.normalize(vector), max);
179
159
  }
180
160
  return vector;
181
- };
161
+ }
182
162
  /**
183
163
  * The function returns a new Vector2D object that is perpendicular to the input vector.The vector that is perpendicular to this one
184
164
  * @param {Vector2D} vector - The parameter "vector" is of type Vector2D.
185
165
  * @returns A new Vector2D object is being returned.
186
166
  */
187
- Vector2D.perp = function (vector) {
167
+ static perp(vector) {
188
168
  return new Vector2D(-vector.y, vector.x);
189
- };
169
+ }
190
170
  /**
191
171
  * The reverse function takes a Vector2D object and returns a new Vector2D object with the negated x and y values.
192
172
  * @param {Vector2D} vector - The parameter "vector" is of type Vector2D, which represents a 2-dimensional vector. It
193
173
  * has two properties: "x" and "y", which represent the x and y components of the vector, respectively.
194
174
  * @returns A new Vector2D object with the negated x and y values of the input vector. Returns the vector that is the reverse of this vector
195
175
  */
196
- Vector2D.reverse = function (vector) {
176
+ static reverse(vector) {
197
177
  return new Vector2D(-vector.x, -vector.y);
198
- };
178
+ }
199
179
  /**
200
180
  * The function takes a Vector2D object as input and returns a new Vector2D object with the absolute values of its x
201
181
  * and y components.
@@ -204,9 +184,9 @@ var Vector2D = /** @class */ (function () {
204
184
  * @returns The method is returning a new Vector2D object with the absolute values of the x and y components of the
205
185
  * input vector.
206
186
  */
207
- Vector2D.abs = function (vector) {
187
+ static abs(vector) {
208
188
  return new Vector2D(Math.abs(vector.x), Math.abs(vector.y));
209
- };
189
+ }
210
190
  /**
211
191
  * The dot function calculates the dot product of two 2D vectors.The dot product of v1 and v2
212
192
  * @param {Vector2D} vector1 - The parameter `vector1` represents a 2D vector with its x and y components.
@@ -214,9 +194,9 @@ var Vector2D = /** @class */ (function () {
214
194
  * with an x and y component.
215
195
  * @returns The dot product of the two input vectors.
216
196
  */
217
- Vector2D.dot = function (vector1, vector2) {
197
+ static dot(vector1, vector2) {
218
198
  return (vector1.x * vector2.x) + (vector1.y * vector2.y);
219
- };
199
+ }
220
200
  // /**
221
201
  // * Transform vectors based on the current tranformation matrices: translation, rotation and scale
222
202
  // * @param vectors The vectors to transform
@@ -241,11 +221,11 @@ var Vector2D = /** @class */ (function () {
241
221
  * the vector in a 2D space.
242
222
  * @returns The distance between vector1 and vector2.
243
223
  */
244
- Vector2D.distance = function (vector1, vector2) {
245
- var ySeparation = vector2.y - vector1.y;
246
- var xSeparation = vector2.x - vector1.x;
224
+ static distance(vector1, vector2) {
225
+ const ySeparation = vector2.y - vector1.y;
226
+ const xSeparation = vector2.x - vector1.x;
247
227
  return Math.sqrt((ySeparation * ySeparation) + (xSeparation * xSeparation));
248
- };
228
+ }
249
229
  /**
250
230
  * The function calculates the squared distance between two 2D vectors.
251
231
  * @param {Vector2D} vector1 - The parameter `vector1` represents the first vector, which is an instance of the
@@ -254,11 +234,11 @@ var Vector2D = /** @class */ (function () {
254
234
  * properties `x` and `y` which represent the coordinates of the vector.
255
235
  * @returns the square of the distance between the two input vectors.
256
236
  */
257
- Vector2D.distanceSq = function (vector1, vector2) {
258
- var ySeparation = vector2.y - vector1.y;
259
- var xSeparation = vector2.x - vector1.x;
237
+ static distanceSq(vector1, vector2) {
238
+ const ySeparation = vector2.y - vector1.y;
239
+ const xSeparation = vector2.x - vector1.x;
260
240
  return (ySeparation * ySeparation) + (xSeparation * xSeparation);
261
- };
241
+ }
262
242
  /**
263
243
  * The sign function determines the sign of the cross product between two 2D vectors.
264
244
  * (assuming the Y axis is pointing down, X axis to right like a Window app)
@@ -268,12 +248,12 @@ var Vector2D = /** @class */ (function () {
268
248
  * vector2. Both vector1 and vector2 are of type Vector2D.
269
249
  * @returns either -1 or 1. Returns positive if v2 is clockwise of this vector, negative if counterclockwise
270
250
  */
271
- Vector2D.sign = function (vector1, vector2) {
251
+ static sign(vector1, vector2) {
272
252
  if (vector1.y * vector2.x > vector1.x * vector2.y) {
273
253
  return -1;
274
254
  }
275
255
  return 1;
276
- };
256
+ }
277
257
  /**
278
258
  * The function calculates the angle between a given vector and the negative y-axis.
279
259
  * @param {Vector2D} vector - The "vector" parameter is an instance of the Vector2D class, which represents a
@@ -281,11 +261,11 @@ var Vector2D = /** @class */ (function () {
281
261
  * respectively.
282
262
  * @returns the angle between the given vector and the vector (0, -1) in radians.Returns the angle between origin and the given vector in radians
283
263
  */
284
- Vector2D.angle = function (vector) {
285
- var origin = new Vector2D(0, -1);
286
- var radian = Math.acos(Vector2D.dot(vector, origin) / (vector.length * origin.length));
264
+ static angle(vector) {
265
+ const origin = new Vector2D(0, -1);
266
+ const radian = Math.acos(Vector2D.dot(vector, origin) / (vector.length * origin.length));
287
267
  return Vector2D.sign(vector, origin) === 1 ? ((Math.PI * 2) - radian) : radian;
288
- };
268
+ }
289
269
  /**
290
270
  * The function "random" generates a random Vector2D object with x and y values within the specified range.
291
271
  * @param {number} maxX - The maxX parameter represents the maximum value for the x-coordinate of the random vector.
@@ -293,19 +273,18 @@ var Vector2D = /** @class */ (function () {
293
273
  * random vector.
294
274
  * @returns a new instance of the Vector2D class with random x and y values.
295
275
  */
296
- Vector2D.random = function (maxX, maxY) {
297
- var randX = Math.floor(Math.random() * maxX - (maxX / 2));
298
- var randY = Math.floor(Math.random() * maxY - (maxY / 2));
276
+ static random(maxX, maxY) {
277
+ const randX = Math.floor(Math.random() * maxX - (maxX / 2));
278
+ const randY = Math.floor(Math.random() * maxY - (maxY / 2));
299
279
  return new Vector2D(randX, randY);
300
- };
280
+ }
301
281
  /**
302
282
  * The function sets the values of x and y to zero.
303
283
  */
304
- Vector2D.prototype.zero = function () {
284
+ zero() {
305
285
  this.x = 0;
306
286
  this.y = 0;
307
- };
308
- return Vector2D;
309
- }());
287
+ }
288
+ }
310
289
  exports.Vector2D = Vector2D;
311
290
  exports.default = Vector2D;
@@ -1,30 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
3
  exports.MaxPriorityQueue = void 0;
30
4
  /**
@@ -34,19 +8,18 @@ exports.MaxPriorityQueue = void 0;
34
8
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
35
9
  * @license MIT License
36
10
  */
37
- var priority_queue_1 = require("./priority-queue");
38
- var MaxPriorityQueue = /** @class */ (function (_super) {
39
- __extends(MaxPriorityQueue, _super);
11
+ const priority_queue_1 = require("./priority-queue");
12
+ class MaxPriorityQueue extends priority_queue_1.PriorityQueue {
40
13
  /**
41
14
  * The constructor initializes a priority queue with an optional comparator function.
42
15
  * @param [options] - The `options` parameter is an optional object that can contain various properties to configure
43
16
  * the priority queue.
44
17
  */
45
- function MaxPriorityQueue(options) {
46
- return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
47
- var aKey = a, bKey = b;
18
+ constructor(options) {
19
+ super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
20
+ const aKey = a, bKey = b;
48
21
  return bKey - aKey;
49
- } })) || this;
22
+ } }));
50
23
  }
51
24
  /**
52
25
  * The function `heapify` creates a max priority queue from the given options and returns it.
@@ -54,14 +27,13 @@ var MaxPriorityQueue = /** @class */ (function (_super) {
54
27
  * queue. It can have the following properties:
55
28
  * @returns a MaxPriorityQueue object.
56
29
  */
57
- MaxPriorityQueue.heapify = function (options) {
58
- var maxPQ = new MaxPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
59
- var aKey = a, bKey = b;
30
+ static heapify(options) {
31
+ const maxPQ = new MaxPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
32
+ const aKey = a, bKey = b;
60
33
  return bKey - aKey;
61
34
  } }));
62
35
  maxPQ._fix();
63
36
  return maxPQ;
64
- };
65
- return MaxPriorityQueue;
66
- }(priority_queue_1.PriorityQueue));
37
+ }
38
+ }
67
39
  exports.MaxPriorityQueue = MaxPriorityQueue;
@@ -1,30 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
3
  exports.MinPriorityQueue = void 0;
30
4
  /**
@@ -34,19 +8,18 @@ exports.MinPriorityQueue = void 0;
34
8
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
35
9
  * @license MIT License
36
10
  */
37
- var priority_queue_1 = require("./priority-queue");
38
- var MinPriorityQueue = /** @class */ (function (_super) {
39
- __extends(MinPriorityQueue, _super);
11
+ const priority_queue_1 = require("./priority-queue");
12
+ class MinPriorityQueue extends priority_queue_1.PriorityQueue {
40
13
  /**
41
14
  * The constructor initializes a priority queue with an optional comparator function.
42
15
  * @param [options] - The `options` parameter is an optional object that can contain various configuration options for
43
16
  * the `PriorityQueue` constructor.
44
17
  */
45
- function MinPriorityQueue(options) {
46
- return _super.call(this, __assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
47
- var aKey = a, bKey = b;
18
+ constructor(options) {
19
+ super(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
20
+ const aKey = a, bKey = b;
48
21
  return aKey - bKey;
49
- } })) || this;
22
+ } }));
50
23
  }
51
24
  /**
52
25
  * The function `heapify` creates a new MinPriorityQueue instance and sets the comparator function based on the options
@@ -55,14 +28,13 @@ var MinPriorityQueue = /** @class */ (function (_super) {
55
28
  * queue. It can have the following properties:
56
29
  * @returns a MinPriorityQueue object.
57
30
  */
58
- MinPriorityQueue.heapify = function (options) {
59
- var minPQ = new MinPriorityQueue(__assign(__assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : function (a, b) {
60
- var aKey = a, bKey = b;
31
+ static heapify(options) {
32
+ const minPQ = new MinPriorityQueue(Object.assign(Object.assign({}, options), { comparator: (options === null || options === void 0 ? void 0 : options.comparator) ? options.comparator : (a, b) => {
33
+ const aKey = a, bKey = b;
61
34
  return aKey - bKey;
62
35
  } }));
63
36
  minPQ._fix();
64
37
  return minPQ;
65
- };
66
- return MinPriorityQueue;
67
- }(priority_queue_1.PriorityQueue));
38
+ }
39
+ }
68
40
  exports.MinPriorityQueue = MinPriorityQueue;