data-structure-typed 1.41.6 → 1.41.7

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 (107) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +11 -11
  3. package/benchmark/report.html +11 -11
  4. package/benchmark/report.json +111 -111
  5. package/dist/cjs/src/data-structures/graph/abstract-graph.js +5 -5
  6. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  7. package/dist/mjs/src/data-structures/graph/abstract-graph.js +5 -5
  8. package/dist/umd/data-structure-typed.min.js +1 -1
  9. package/dist/umd/data-structure-typed.min.js.map +1 -1
  10. package/package.json +5 -5
  11. package/src/data-structures/graph/abstract-graph.ts +6 -6
  12. package/test/config.ts +1 -0
  13. package/test/integration/avl-tree.test.ts +110 -0
  14. package/test/integration/bst.test.ts +385 -0
  15. package/test/integration/heap.test.js +16 -0
  16. package/test/integration/index.html +51 -0
  17. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +36 -0
  18. package/test/performance/data-structures/binary-tree/binary-index-tree.test.ts +0 -0
  19. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +45 -0
  20. package/test/performance/data-structures/binary-tree/bst.test.ts +36 -0
  21. package/test/performance/data-structures/binary-tree/overall.test.ts +0 -0
  22. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +0 -0
  23. package/test/performance/data-structures/binary-tree/segment-tree.test.ts +0 -0
  24. package/test/performance/data-structures/binary-tree/tree-multiset.test.ts +0 -0
  25. package/test/performance/data-structures/graph/abstract-graph.test.ts +0 -0
  26. package/test/performance/data-structures/graph/directed-graph.test.ts +49 -0
  27. package/test/performance/data-structures/graph/map-graph.test.ts +0 -0
  28. package/test/performance/data-structures/graph/overall.test.ts +0 -0
  29. package/test/performance/data-structures/graph/undirected-graph.test.ts +0 -0
  30. package/test/performance/data-structures/hash/coordinate-map.test.ts +0 -0
  31. package/test/performance/data-structures/hash/coordinate-set.test.ts +0 -0
  32. package/test/performance/data-structures/hash/hash-map.test.ts +0 -0
  33. package/test/performance/data-structures/hash/hash-table.test.ts +0 -0
  34. package/test/performance/data-structures/heap/heap.test.ts +30 -0
  35. package/test/performance/data-structures/heap/max-heap.test.ts +0 -0
  36. package/test/performance/data-structures/heap/min-heap.test.ts +0 -0
  37. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +40 -0
  38. package/test/performance/data-structures/linked-list/linked-list.test.ts +0 -0
  39. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +34 -0
  40. package/test/performance/data-structures/linked-list/skip-linked-list.test.ts +0 -0
  41. package/test/performance/data-structures/linked-list/skip-list.test.ts +0 -0
  42. package/test/performance/data-structures/matrix/matrix.test.ts +0 -0
  43. package/test/performance/data-structures/matrix/matrix2d.test.ts +0 -0
  44. package/test/performance/data-structures/matrix/navigator.test.ts +0 -0
  45. package/test/performance/data-structures/matrix/vector2d.test.ts +0 -0
  46. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +19 -0
  47. package/test/performance/data-structures/priority-queue/min-priority-queue.test.ts +0 -0
  48. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +0 -0
  49. package/test/performance/data-structures/queue/deque.test.ts +21 -0
  50. package/test/performance/data-structures/queue/queue.test.ts +25 -0
  51. package/test/performance/data-structures/stack/stack.test.ts +0 -0
  52. package/test/performance/data-structures/tree/tree.test.ts +0 -0
  53. package/test/performance/data-structures/trie/trie.test.ts +22 -0
  54. package/test/performance/reportor.ts +186 -0
  55. package/test/performance/types/index.ts +1 -0
  56. package/test/performance/types/reportor.ts +3 -0
  57. package/test/types/index.ts +1 -0
  58. package/test/types/utils/big-o.ts +1 -0
  59. package/test/types/utils/index.ts +2 -0
  60. package/test/types/utils/json2html.ts +1 -0
  61. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +269 -0
  62. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +320 -0
  63. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +486 -0
  64. package/test/unit/data-structures/binary-tree/bst.test.ts +840 -0
  65. package/test/unit/data-structures/binary-tree/overall.test.ts +66 -0
  66. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +435 -0
  67. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +50 -0
  68. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +542 -0
  69. package/test/unit/data-structures/graph/abstract-graph.test.ts +100 -0
  70. package/test/unit/data-structures/graph/directed-graph.test.ts +564 -0
  71. package/test/unit/data-structures/graph/map-graph.test.ts +126 -0
  72. package/test/unit/data-structures/graph/overall.test.ts +49 -0
  73. package/test/unit/data-structures/graph/salty-edges.json +1 -0
  74. package/test/unit/data-structures/graph/salty-vertexes.json +1 -0
  75. package/test/unit/data-structures/graph/undirected-graph.test.ts +168 -0
  76. package/test/unit/data-structures/hash/coordinate-map.test.ts +74 -0
  77. package/test/unit/data-structures/hash/coordinate-set.test.ts +66 -0
  78. package/test/unit/data-structures/hash/hash-map.test.ts +103 -0
  79. package/test/unit/data-structures/hash/hash-table.test.ts +186 -0
  80. package/test/unit/data-structures/heap/heap.test.ts +254 -0
  81. package/test/unit/data-structures/heap/max-heap.test.ts +52 -0
  82. package/test/unit/data-structures/heap/min-heap.test.ts +52 -0
  83. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +400 -0
  84. package/test/unit/data-structures/linked-list/linked-list.test.ts +8 -0
  85. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +474 -0
  86. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +13 -0
  87. package/test/unit/data-structures/linked-list/skip-list.test.ts +86 -0
  88. package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
  89. package/test/unit/data-structures/matrix/matrix2d.test.ts +345 -0
  90. package/test/unit/data-structures/matrix/navigator.test.ts +244 -0
  91. package/test/unit/data-structures/matrix/vector2d.test.ts +171 -0
  92. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +73 -0
  93. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +63 -0
  94. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +53 -0
  95. package/test/unit/data-structures/queue/deque.test.ts +410 -0
  96. package/test/unit/data-structures/queue/queue.test.ts +207 -0
  97. package/test/unit/data-structures/stack/stack.test.ts +67 -0
  98. package/test/unit/data-structures/tree/tree.test.ts +39 -0
  99. package/test/unit/data-structures/trie/trie.test.ts +825 -0
  100. package/test/utils/array.ts +5514 -0
  101. package/test/utils/big-o.ts +207 -0
  102. package/test/utils/console.ts +31 -0
  103. package/test/utils/index.ts +7 -0
  104. package/test/utils/is.ts +56 -0
  105. package/test/utils/json2html.ts +322 -0
  106. package/test/utils/number.ts +13 -0
  107. package/test/utils/string.ts +1 -0
@@ -0,0 +1,171 @@
1
+ import {Vector2D} from '../../../../src';
2
+
3
+ describe('Vector2D', () => {
4
+ it('should create a vector with default values', () => {
5
+ const vector = new Vector2D();
6
+ expect(vector.x).toBe(0);
7
+ expect(vector.y).toBe(0);
8
+ expect(vector.w).toBe(1);
9
+ });
10
+
11
+ it('should correctly check if a vector is zero', () => {
12
+ const nonZeroVector = new Vector2D(3, 4);
13
+ const zeroVector = new Vector2D(0, 0);
14
+ expect(nonZeroVector.isZero).toBe(false);
15
+ expect(zeroVector.isZero).toBe(true);
16
+ });
17
+
18
+ it('should correctly calculate vector length', () => {
19
+ const vector = new Vector2D(3, 4);
20
+ expect(vector.length).toBe(5);
21
+ });
22
+
23
+ it('should correctly calculate squared vector length', () => {
24
+ const vector = new Vector2D(3, 4);
25
+ expect(vector.lengthSq).toBe(25);
26
+ });
27
+
28
+ it('should correctly round vector components', () => {
29
+ const vector = new Vector2D(3.6, 4.3);
30
+ const roundedVector = vector.rounded;
31
+ expect(roundedVector.x).toBe(4);
32
+ expect(roundedVector.y).toBe(4);
33
+ });
34
+
35
+ it('should correctly add two vectors', () => {
36
+ const vector1 = new Vector2D(2, 3);
37
+ const vector2 = new Vector2D(1, 2);
38
+ const result = Vector2D.add(vector1, vector2);
39
+ expect(result.x).toBe(3);
40
+ expect(result.y).toBe(5);
41
+ });
42
+
43
+ it('should correctly subtract two vectors', () => {
44
+ const vector1 = new Vector2D(4, 5);
45
+ const vector2 = new Vector2D(1, 2);
46
+ const result = Vector2D.subtract(vector1, vector2);
47
+ expect(result.x).toBe(3);
48
+ expect(result.y).toBe(3);
49
+ });
50
+
51
+ it('should correctly subtract value from a vector', () => {
52
+ const vector = new Vector2D(5, 7);
53
+ const result = Vector2D.subtractValue(vector, 3);
54
+ expect(result.x).toBe(2);
55
+ expect(result.y).toBe(4);
56
+ });
57
+
58
+ it('should correctly multiply a vector by a value', () => {
59
+ const vector = new Vector2D(2, 3);
60
+ const result = Vector2D.multiply(vector, 4);
61
+ expect(result.x).toBe(8);
62
+ expect(result.y).toBe(12);
63
+ });
64
+
65
+ it('should correctly divide a vector by a value', () => {
66
+ const vector = new Vector2D(6, 8);
67
+ const result = Vector2D.divide(vector, 2);
68
+ expect(result.x).toBe(3);
69
+ expect(result.y).toBe(4);
70
+ });
71
+
72
+ it('should correctly check if two vectors are equal', () => {
73
+ const vector1 = new Vector2D(3, 4);
74
+ const vector2 = new Vector2D(3, 4);
75
+ const vector3 = new Vector2D(4, 5);
76
+ expect(Vector2D.equals(vector1, vector2)).toBe(true);
77
+ expect(Vector2D.equals(vector1, vector3)).toBe(false);
78
+ });
79
+
80
+ it('should correctly check if two vectors are equal within a rounding factor', () => {
81
+ const vector1 = new Vector2D(3, 4);
82
+ const vector2 = new Vector2D(2.9, 3.9);
83
+ const vector3 = new Vector2D(4, 5);
84
+ expect(Vector2D.equalsRounded(vector1, vector2, 0.2)).toBe(true);
85
+ expect(Vector2D.equalsRounded(vector1, vector3, 0.2)).toBe(false);
86
+ });
87
+
88
+ it('should correctly normalize a vector', () => {
89
+ const vector = new Vector2D(3, 4);
90
+ const normalized = Vector2D.normalize(vector);
91
+ expect(normalized.x).toBeCloseTo(0.6);
92
+ expect(normalized.y).toBeCloseTo(0.8);
93
+ });
94
+
95
+ it('should correctly truncate a vector', () => {
96
+ const vector = new Vector2D(3, 4);
97
+ const truncated = Vector2D.truncate(vector, 4);
98
+ expect(truncated.length).toBeLessThanOrEqual(4);
99
+ });
100
+
101
+ it('should correctly get the perpendicular vector', () => {
102
+ const vector = new Vector2D(3, 4);
103
+ const perpendicular = Vector2D.perp(vector);
104
+ expect(Vector2D.dot(vector, perpendicular)).toBe(0);
105
+ });
106
+
107
+ it('should correctly reverse the vector', () => {
108
+ const vector = new Vector2D(3, 4);
109
+ const reversed = Vector2D.reverse(vector);
110
+ expect(reversed.x).toBe(-3);
111
+ expect(reversed.y).toBe(-4);
112
+ });
113
+
114
+ it('should correctly get the absolute vector', () => {
115
+ const vector = new Vector2D(-3, 4);
116
+ const absVector = Vector2D.abs(vector);
117
+ expect(absVector.x).toBe(3);
118
+ expect(absVector.y).toBe(4);
119
+ });
120
+
121
+ it('should correctly calculate the dot product of two vectors', () => {
122
+ const vector1 = new Vector2D(2, 3);
123
+ const vector2 = new Vector2D(4, 5);
124
+ const dotProduct = Vector2D.dot(vector1, vector2);
125
+ expect(dotProduct).toBe(23);
126
+ });
127
+
128
+ it('should correctly calculate the distance between two vectors', () => {
129
+ const vector1 = new Vector2D(1, 1);
130
+ const vector2 = new Vector2D(4, 5);
131
+ const distance = Vector2D.distance(vector1, vector2);
132
+ expect(distance).toBeCloseTo(5);
133
+ });
134
+
135
+ it('should correctly calculate the squared distance between two vectors', () => {
136
+ const vector1 = new Vector2D(1, 1);
137
+ const vector2 = new Vector2D(4, 5);
138
+ const distanceSq = Vector2D.distanceSq(vector1, vector2);
139
+ expect(distanceSq).toBe(25);
140
+ });
141
+
142
+ it('should correctly determine the sign of the cross product of two vectors', () => {
143
+ const vector1 = new Vector2D(2, 3);
144
+ const vector2 = new Vector2D(4, 5);
145
+ const sign = Vector2D.sign(vector1, vector2);
146
+ expect(sign).toBe(-1); // Assuming specific vector values, the result may vary
147
+ });
148
+
149
+ it('should correctly calculate the angle between a vector and the negative y-axis', () => {
150
+ const vector = new Vector2D(3, 4);
151
+ const angle = Vector2D.angle(vector);
152
+ expect(angle).toBeCloseTo(2.498091544796509, 3);
153
+ });
154
+
155
+ it('should create a random vector within the specified range', () => {
156
+ const maxX = 10;
157
+ const maxY = 10;
158
+ const randomVector = Vector2D.random(maxX, maxY);
159
+ expect(randomVector.x).toBeGreaterThanOrEqual(-maxX / 2);
160
+ expect(randomVector.x).toBeLessThanOrEqual(maxX / 2);
161
+ expect(randomVector.y).toBeGreaterThanOrEqual(-maxY / 2);
162
+ expect(randomVector.y).toBeLessThanOrEqual(maxY / 2);
163
+ });
164
+
165
+ it('should zero the vector components', () => {
166
+ const vector = new Vector2D(3, 4);
167
+ vector.zero();
168
+ expect(vector.x).toBe(0);
169
+ expect(vector.y).toBe(0);
170
+ });
171
+ });
@@ -0,0 +1,73 @@
1
+ import {MaxPriorityQueue} from '../../../../src';
2
+
3
+ describe('MaxPriorityQueue Operation Test', () => {
4
+ it('should add elements and maintain heap property', () => {
5
+ const priorityQueue = new MaxPriorityQueue<number>();
6
+
7
+ priorityQueue.add(5);
8
+ priorityQueue.add(3);
9
+ priorityQueue.add(7);
10
+ priorityQueue.add(1);
11
+
12
+ expect(priorityQueue.poll()).toBe(7);
13
+ expect(priorityQueue.poll()).toBe(5);
14
+ expect(priorityQueue.poll()).toBe(3);
15
+ expect(priorityQueue.poll()).toBe(1);
16
+ });
17
+
18
+ it('should add elements and maintain heap property in a object MaxPriorityQueue', () => {
19
+ const priorityQueue = new MaxPriorityQueue<{keyA: number}>({comparator: (a, b) => b.keyA - a.keyA});
20
+ priorityQueue.refill([{keyA: 5}, {keyA: 3}, {keyA: 1}]);
21
+ priorityQueue.add({keyA: 7});
22
+
23
+ expect(priorityQueue.poll()?.keyA).toBe(7);
24
+ expect(priorityQueue.poll()?.keyA).toBe(5);
25
+ expect(priorityQueue.poll()?.keyA).toBe(3);
26
+ expect(priorityQueue.poll()?.keyA).toBe(1);
27
+ });
28
+
29
+ it('should return and delete the smallest element', () => {
30
+ const priorityQueue = new MaxPriorityQueue<number>();
31
+ priorityQueue.add(5);
32
+ priorityQueue.add(3);
33
+ priorityQueue.add(7);
34
+
35
+ expect(priorityQueue.poll()).toBe(7);
36
+ expect(priorityQueue.poll()).toBe(5);
37
+ expect(priorityQueue.size).toBe(1);
38
+ });
39
+
40
+ it('should create a clone of the priority queue', () => {
41
+ const priorityQueue = new MaxPriorityQueue<number>();
42
+ priorityQueue.add(5);
43
+ priorityQueue.add(3);
44
+ priorityQueue.add(7);
45
+
46
+ const clone = priorityQueue.clone();
47
+ expect(clone.poll()).toBe(7);
48
+ expect(clone.poll()).toBe(5);
49
+ expect(clone.poll()).toBe(3);
50
+ expect(clone.isEmpty()).toBe(true);
51
+ });
52
+
53
+ it('should correctly heapify an array', () => {
54
+ const array = [5, 3, 7, 1];
55
+ const heap = MaxPriorityQueue.heapify<number>({nodes: array, comparator: (a, b) => b - a});
56
+ heap.refill(array);
57
+
58
+ expect(heap.poll()).toBe(7);
59
+ expect(heap.poll()).toBe(5);
60
+ expect(heap.poll()).toBe(3);
61
+ expect(heap.poll()).toBe(1);
62
+ });
63
+
64
+ it('should correctly heapify an object array', () => {
65
+ const nodes = [{keyA: 5}, {keyA: 3}, {keyA: 7}, {keyA: 1}];
66
+ const maxPQ = MaxPriorityQueue.heapify<{keyA: number}>({nodes: nodes, comparator: (a, b) => b.keyA - a.keyA});
67
+
68
+ expect(maxPQ.poll()?.keyA).toBe(7);
69
+ expect(maxPQ.poll()?.keyA).toBe(5);
70
+ expect(maxPQ.poll()?.keyA).toBe(3);
71
+ expect(maxPQ.poll()?.keyA).toBe(1);
72
+ });
73
+ });
@@ -0,0 +1,63 @@
1
+ import {MinPriorityQueue} from '../../../../src';
2
+
3
+ describe('MinPriorityQueue Operation Test', () => {
4
+ it('should check if a node exists in the queue', () => {
5
+ const priorityQueue = new MinPriorityQueue<number>();
6
+ priorityQueue.add(5);
7
+
8
+ expect(priorityQueue.has(5)).toBe(true);
9
+ expect(priorityQueue.has(3)).toBe(false);
10
+ });
11
+
12
+ it('should return the smallest element without removing it', () => {
13
+ const priorityQueue = new MinPriorityQueue<number>();
14
+ priorityQueue.add(5);
15
+ priorityQueue.add(3);
16
+ priorityQueue.add(7);
17
+
18
+ expect(priorityQueue.peek()).toBe(3);
19
+ expect(priorityQueue.size).toBe(3);
20
+ });
21
+
22
+ it('should return the last element', () => {
23
+ const priorityQueue = new MinPriorityQueue<number>();
24
+ priorityQueue.add(5);
25
+ priorityQueue.add(3);
26
+ priorityQueue.add(7);
27
+
28
+ expect(priorityQueue.leaf).toBe(7);
29
+ });
30
+
31
+ it('should check if the queue is empty', () => {
32
+ const priorityQueue = new MinPriorityQueue<number>();
33
+
34
+ expect(priorityQueue.isEmpty()).toBe(true);
35
+
36
+ priorityQueue.add(5);
37
+
38
+ expect(priorityQueue.isEmpty()).toBe(false);
39
+ });
40
+
41
+ it('should clear the queue', () => {
42
+ const priorityQueue = new MinPriorityQueue<number>();
43
+ priorityQueue.add(5);
44
+ priorityQueue.add(3);
45
+ priorityQueue.add(7);
46
+
47
+ priorityQueue.clear();
48
+
49
+ expect(priorityQueue.size).toBe(0);
50
+ expect(priorityQueue.isEmpty()).toBe(true);
51
+ });
52
+
53
+ it('should sort the elements', () => {
54
+ const priorityQueue = new MinPriorityQueue<number>();
55
+ priorityQueue.add(5);
56
+ priorityQueue.add(3);
57
+ priorityQueue.add(7);
58
+ priorityQueue.add(1);
59
+
60
+ const sortedArray = priorityQueue.sort();
61
+ expect(sortedArray).toEqual([1, 3, 5, 7]);
62
+ });
63
+ });
@@ -0,0 +1,53 @@
1
+ import {PriorityQueue} from '../../../../src';
2
+ import {getRandomInt} from '../../../utils';
3
+
4
+ describe('PriorityQueue Operation Test', () => {
5
+ it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
6
+ const minPQ = new PriorityQueue<number>({comparator: (a, b) => a - b});
7
+ minPQ.refill([5, 2, 3, 4, 6, 1]);
8
+ expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);
9
+ minPQ.poll();
10
+ minPQ.poll();
11
+ minPQ.poll();
12
+ expect(minPQ.toArray()).toEqual([4, 5, 6]);
13
+ expect(minPQ.peek()).toBe(4);
14
+ expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
15
+ [1, 2, 3, 5, 6, 7, 8, 9, 10]
16
+ );
17
+ });
18
+
19
+ it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
20
+ const maxPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => b - a});
21
+ maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]);
22
+ expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);
23
+ maxPriorityQueue.poll();
24
+ maxPriorityQueue.poll();
25
+ maxPriorityQueue.poll();
26
+ expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
27
+ expect(maxPriorityQueue.peek()).toBe(3);
28
+ expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual(
29
+ [1, 2, 3, 5, 6, 7, 8, 9, 10]
30
+ );
31
+ });
32
+
33
+ it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
34
+ const minPQ1 = new PriorityQueue<number>({comparator: (a, b) => a - b});
35
+ minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]);
36
+ const clonedPriorityQueue = minPQ1.clone();
37
+ expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes());
38
+ expect(clonedPriorityQueue.sort()).toEqual([1, 2, 3, 4, 5, 6, 7, 8]);
39
+ expect(minPQ1.dfs('in')).toEqual([4, 3, 2, 5, 1, 8, 6, 7]);
40
+ expect(minPQ1.dfs('post')).toEqual([4, 3, 5, 2, 8, 7, 6, 1]);
41
+ expect(minPQ1.dfs('pre')).toEqual([1, 2, 3, 4, 5, 6, 8, 7]);
42
+ });
43
+ });
44
+
45
+ describe('Priority Queue Performance Test', () => {
46
+ it('should numeric heap work well', function () {
47
+ const values = Array.from(new Array(10000), () => getRandomInt(1, 10000000));
48
+ const minPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => a - b});
49
+ minPriorityQueue.refill(values);
50
+ const sorted = minPriorityQueue.sort();
51
+ expect(sorted).toEqual(values.sort((a, b) => a - b));
52
+ });
53
+ });