data-structure-typed 1.33.2 → 1.33.6

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 (148) hide show
  1. package/{.eslintrc.json → .eslintrc.js} +2 -1
  2. package/.github/workflows/ci.yml +15 -3
  3. package/.github/workflows/release-package.yml +32 -0
  4. package/{.prettierrc → .prettierrc.js} +1 -1
  5. package/CHANGELOG.md +5 -1
  6. package/README.md +2 -3
  7. package/coverage/coverage-final.json +64 -64
  8. package/coverage/coverage-summary.json +2 -2
  9. package/dist/data-structures/graph/abstract-graph.js +12 -12
  10. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  11. package/dist/data-structures/priority-queue/priority-queue.js +6 -6
  12. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  13. package/docs/index.html +2 -3
  14. package/package.json +68 -60
  15. package/src/data-structures/binary-tree/aa-tree.ts +1 -0
  16. package/src/data-structures/binary-tree/abstract-binary-tree.ts +1608 -0
  17. package/src/data-structures/binary-tree/avl-tree.ts +307 -0
  18. package/src/data-structures/binary-tree/b-tree.ts +1 -0
  19. package/src/data-structures/binary-tree/binary-indexed-tree.ts +76 -0
  20. package/src/data-structures/binary-tree/binary-tree.ts +47 -0
  21. package/src/data-structures/binary-tree/bst.ts +537 -0
  22. package/src/data-structures/binary-tree/index.ts +12 -0
  23. package/src/data-structures/binary-tree/rb-tree.ts +366 -0
  24. package/src/data-structures/binary-tree/segment-tree.ts +242 -0
  25. package/src/data-structures/binary-tree/splay-tree.ts +1 -0
  26. package/src/data-structures/binary-tree/tree-multiset.ts +700 -0
  27. package/src/data-structures/binary-tree/two-three-tree.ts +1 -0
  28. package/src/data-structures/graph/abstract-graph.ts +1040 -0
  29. package/src/data-structures/graph/directed-graph.ts +470 -0
  30. package/src/data-structures/graph/index.ts +4 -0
  31. package/src/data-structures/graph/map-graph.ts +129 -0
  32. package/src/data-structures/graph/undirected-graph.ts +274 -0
  33. package/src/data-structures/hash/coordinate-map.ts +67 -0
  34. package/src/data-structures/hash/coordinate-set.ts +56 -0
  35. package/src/data-structures/hash/hash-table.ts +157 -0
  36. package/src/data-structures/hash/index.ts +6 -0
  37. package/src/data-structures/hash/pair.ts +1 -0
  38. package/src/data-structures/hash/tree-map.ts +1 -0
  39. package/src/data-structures/hash/tree-set.ts +1 -0
  40. package/src/data-structures/heap/heap.ts +212 -0
  41. package/src/data-structures/heap/index.ts +3 -0
  42. package/src/data-structures/heap/max-heap.ts +31 -0
  43. package/src/data-structures/heap/min-heap.ts +32 -0
  44. package/src/data-structures/index.ts +11 -0
  45. package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
  46. package/src/data-structures/linked-list/index.ts +3 -0
  47. package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
  48. package/src/data-structures/linked-list/skip-linked-list.ts +1 -0
  49. package/src/data-structures/matrix/index.ts +4 -0
  50. package/src/data-structures/matrix/matrix.ts +27 -0
  51. package/src/data-structures/matrix/matrix2d.ts +213 -0
  52. package/src/data-structures/matrix/navigator.ts +121 -0
  53. package/src/data-structures/matrix/vector2d.ts +316 -0
  54. package/src/data-structures/priority-queue/index.ts +3 -0
  55. package/src/data-structures/priority-queue/max-priority-queue.ts +56 -0
  56. package/src/data-structures/priority-queue/min-priority-queue.ts +57 -0
  57. package/src/data-structures/priority-queue/priority-queue.ts +359 -0
  58. package/src/data-structures/queue/deque.ts +297 -0
  59. package/src/data-structures/queue/index.ts +2 -0
  60. package/src/data-structures/queue/queue.ts +191 -0
  61. package/src/data-structures/stack/index.ts +1 -0
  62. package/src/data-structures/stack/stack.ts +98 -0
  63. package/src/data-structures/tree/index.ts +1 -0
  64. package/src/data-structures/tree/tree.ts +69 -0
  65. package/src/data-structures/trie/index.ts +1 -0
  66. package/src/data-structures/trie/trie.ts +225 -0
  67. package/src/index.ts +4 -0
  68. package/src/interfaces/abstract-binary-tree.ts +189 -0
  69. package/src/interfaces/abstract-graph.ts +31 -0
  70. package/src/interfaces/avl-tree.ts +25 -0
  71. package/src/interfaces/binary-tree.ts +6 -0
  72. package/src/interfaces/bst.ts +31 -0
  73. package/src/interfaces/directed-graph.ts +20 -0
  74. package/src/interfaces/doubly-linked-list.ts +1 -0
  75. package/src/interfaces/heap.ts +1 -0
  76. package/src/interfaces/index.ts +15 -0
  77. package/src/interfaces/navigator.ts +1 -0
  78. package/src/interfaces/priority-queue.ts +1 -0
  79. package/src/interfaces/rb-tree.ts +9 -0
  80. package/src/interfaces/segment-tree.ts +1 -0
  81. package/src/interfaces/singly-linked-list.ts +1 -0
  82. package/src/interfaces/tree-multiset.ts +7 -0
  83. package/src/interfaces/undirected-graph.ts +6 -0
  84. package/src/types/data-structures/abstract-binary-tree.ts +50 -0
  85. package/src/types/data-structures/abstract-graph.ts +11 -0
  86. package/src/types/data-structures/avl-tree.ts +5 -0
  87. package/src/types/data-structures/binary-tree.ts +5 -0
  88. package/src/types/data-structures/bst.ts +13 -0
  89. package/src/types/data-structures/directed-graph.ts +8 -0
  90. package/src/types/data-structures/doubly-linked-list.ts +1 -0
  91. package/src/types/data-structures/heap.ts +5 -0
  92. package/src/types/data-structures/index.ts +15 -0
  93. package/src/types/data-structures/map-graph.ts +1 -0
  94. package/src/types/data-structures/navigator.ts +13 -0
  95. package/src/types/data-structures/priority-queue.ts +9 -0
  96. package/src/types/data-structures/rb-tree.ts +8 -0
  97. package/src/types/data-structures/segment-tree.ts +1 -0
  98. package/src/types/data-structures/singly-linked-list.ts +1 -0
  99. package/src/types/data-structures/tree-multiset.ts +6 -0
  100. package/src/types/helpers.ts +1 -0
  101. package/src/types/index.ts +3 -0
  102. package/src/types/utils/index.ts +2 -0
  103. package/src/types/utils/utils.ts +6 -0
  104. package/src/types/utils/validate-type.ts +35 -0
  105. package/src/utils/index.ts +1 -0
  106. package/src/utils/utils.ts +79 -0
  107. package/test/integration/avl-tree.test.ts +14 -17
  108. package/test/integration/bst.test.ts +50 -41
  109. package/test/integration/heap.test.js +0 -3
  110. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +14 -17
  111. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -4
  112. package/test/unit/data-structures/binary-tree/bst.test.ts +50 -41
  113. package/test/unit/data-structures/binary-tree/overall.test.ts +36 -28
  114. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +0 -1
  115. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +23 -12
  116. package/test/unit/data-structures/graph/directed-graph.test.ts +27 -25
  117. package/test/unit/data-structures/graph/map-graph.test.ts +4 -5
  118. package/test/unit/data-structures/graph/overall.test.ts +10 -11
  119. package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -1
  120. package/test/unit/data-structures/heap/heap.test.ts +7 -8
  121. package/test/unit/data-structures/heap/max-heap.test.ts +7 -5
  122. package/test/unit/data-structures/heap/min-heap.test.ts +6 -5
  123. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +9 -10
  124. package/test/unit/data-structures/linked-list/linked-list.test.ts +1 -1
  125. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +4 -7
  126. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +3 -3
  127. package/test/unit/data-structures/matrix/matrix.test.ts +4 -4
  128. package/test/unit/data-structures/matrix/navigator.test.ts +4 -5
  129. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +5 -7
  130. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +13 -13
  131. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +8 -8
  132. package/test/unit/data-structures/queue/deque.test.ts +0 -1
  133. package/test/unit/data-structures/queue/queue.test.ts +1 -5
  134. package/test/unit/data-structures/trie/trie.test.ts +2 -2
  135. package/test/utils/magnitude.ts +3 -3
  136. package/tsconfig.json +3 -12
  137. package/tsconfig.prod.json +25 -0
  138. package/.auto-changelog +0 -9
  139. package/.gitattributes +0 -112
  140. package/.idea/codeStyles/Project.xml +0 -61
  141. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  142. package/.idea/data-structure-typed.iml +0 -19
  143. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  144. package/.idea/misc.xml +0 -6
  145. package/.idea/modules.xml +0 -8
  146. package/.idea/vcs.xml +0 -6
  147. package/.prettierignore +0 -6
  148. package/webpack.config.js +0 -28
@@ -7,7 +7,6 @@ describe('DirectedGraph Operation Test', () => {
7
7
  graph = new DirectedGraph();
8
8
  });
9
9
 
10
-
11
10
  it('should add vertices', () => {
12
11
  const vertex1 = new DirectedVertex('A');
13
12
  const vertex2 = new DirectedVertex('B');
@@ -64,7 +63,6 @@ describe('DirectedGraph Operation Test', () => {
64
63
  });
65
64
 
66
65
  class MyVertex<V extends string> extends DirectedVertex<V> {
67
-
68
66
  constructor(id: VertexId, val?: V) {
69
67
  super(id, val);
70
68
  this._data = val;
@@ -82,7 +80,6 @@ class MyVertex<V extends string> extends DirectedVertex<V> {
82
80
  }
83
81
 
84
82
  class MyEdge<E extends string> extends DirectedEdge<E> {
85
-
86
83
  constructor(v1: VertexId, v2: VertexId, weight?: number, val?: E) {
87
84
  super(v1, v2, weight, val);
88
85
  this._data = val;
@@ -125,7 +122,6 @@ describe('Inherit from DirectedGraph and perform operations', () => {
125
122
  myGraph.addVertex(new MyVertex(7, 'data7'));
126
123
  myGraph.addVertex(new MyVertex(8, 'data8'));
127
124
  myGraph.addVertex(new MyVertex(9, 'data9'));
128
-
129
125
  });
130
126
 
131
127
  it('Add edges', () => {
@@ -157,13 +153,10 @@ describe('Inherit from DirectedGraph and perform operations', () => {
157
153
  expect(edge1).toEqual(edge2);
158
154
  expect(edge3).toBeNull();
159
155
  }
160
-
161
156
  });
162
157
 
163
158
  it('Edge set and vertex set', () => {
164
- const edges = myGraph.edgeSet();
165
- const vertices = myGraph.vertices;
166
-
159
+ expect(true).toBeTruthy();
167
160
  });
168
161
 
169
162
  it('Remove edge between vertices', () => {
@@ -177,13 +170,12 @@ describe('Inherit from DirectedGraph and perform operations', () => {
177
170
  expect(removedEdge).toBeInstanceOf(MyEdge);
178
171
  if (removedEdge) {
179
172
  removedEdge && expect(removedEdge.val).toBe('edge-data1-2');
180
- removedEdge && expect(removedEdge.src).toBe(1)
173
+ removedEdge && expect(removedEdge.src).toBe(1);
181
174
  }
182
175
  expect(edgeAfterRemoval).toBeNull();
183
176
  });
184
177
 
185
178
  it('Topological sort', () => {
186
-
187
179
  const sorted = myGraph.topologicalSort();
188
180
 
189
181
  expect(sorted).toBeInstanceOf(Array);
@@ -193,15 +185,12 @@ describe('Inherit from DirectedGraph and perform operations', () => {
193
185
  sorted[3] instanceof MyVertex && expect(sorted[3].data).toBe('data6');
194
186
  sorted[8] instanceof MyVertex && expect(sorted[8].id).toBe(1);
195
187
  }
196
-
197
188
  });
198
189
 
199
190
  it('Minimum path between vertices', () => {
200
191
  myGraph.addVertex(new MyVertex(1, 'data1'));
201
192
  myGraph.addVertex(new MyVertex(2, 'data2'));
202
193
  myGraph.addEdge(new MyEdge(1, 2, 10, 'edge-data1-2'));
203
-
204
- const minPath = myGraph.getMinPathBetween(1, 2);
205
194
  });
206
195
 
207
196
  it('All paths between vertices', () => {
@@ -210,8 +199,6 @@ describe('Inherit from DirectedGraph and perform operations', () => {
210
199
  myGraph.addVertex(new MyVertex(2, 'data2'));
211
200
  myGraph.addEdge(new MyEdge(1, 2, 10, 'edge-data1-2'));
212
201
 
213
- const allPaths = myGraph.getAllPathsBetween(1, 2);
214
-
215
202
  // Add expect statements here to verify the allPaths
216
203
  });
217
204
  });
@@ -308,7 +295,6 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
308
295
  expect(min).toBe(Infinity);
309
296
  expect(minPath).toBeInstanceOf(Array);
310
297
 
311
-
312
298
  const floydResult = myGraph.floyd();
313
299
  expect(floydResult).toBeTruthy();
314
300
  if (floydResult) {
@@ -320,9 +306,29 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
320
306
  expect(costs[2]).toEqual([3, 15, 38, 17, 35, Infinity, 64, Infinity, 22]);
321
307
  expect(costs[3]).toEqual([123, 135, 120, 137, 155, Infinity, 47, Infinity, 126]);
322
308
  expect(costs[4]).toEqual([133, 145, 130, 147, 165, Infinity, 57, Infinity, 136]);
323
- expect(costs[5]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
309
+ expect(costs[5]).toEqual([
310
+ Infinity,
311
+ Infinity,
312
+ Infinity,
313
+ Infinity,
314
+ Infinity,
315
+ Infinity,
316
+ Infinity,
317
+ Infinity,
318
+ Infinity
319
+ ]);
324
320
  expect(costs[6]).toEqual([76, 88, 73, 90, 108, Infinity, 137, Infinity, 79]);
325
- expect(costs[7]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
321
+ expect(costs[7]).toEqual([
322
+ Infinity,
323
+ Infinity,
324
+ Infinity,
325
+ Infinity,
326
+ Infinity,
327
+ Infinity,
328
+ Infinity,
329
+ Infinity,
330
+ Infinity
331
+ ]);
326
332
  expect(costs[8]).toEqual([173, 185, 170, 187, 205, Infinity, 97, Infinity, 176]);
327
333
 
328
334
  expect(predecessor).toBeInstanceOf(Array);
@@ -338,7 +344,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
338
344
 
339
345
  expect(dijkstraRes12tt).toBeTruthy();
340
346
  if (dijkstraRes12tt) {
341
- const {distMap, minDist, minPath, paths, preMap, seen} = dijkstraRes12tt;
347
+ const {distMap, minDist, minPath, paths} = dijkstraRes12tt;
342
348
  expect(distMap).toBeInstanceOf(Map);
343
349
  expect(distMap.size).toBe(9);
344
350
  expect(distMap.get(vertex1)).toBe(0);
@@ -383,14 +389,13 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
383
389
  expect(paths[8]).toBeInstanceOf(Array);
384
390
  expect(paths[8][0]).toBe(vertex1);
385
391
  expect(paths[8][1]).toBe(vertex9);
386
-
387
392
  }
388
393
 
389
394
  const dijkstraRes1ntt = myGraph.dijkstra(1, null, true, true);
390
395
 
391
396
  expect(dijkstraRes1ntt).toBeTruthy();
392
397
  if (dijkstraRes1ntt) {
393
- const {distMap, minDist, minPath, paths, preMap, seen} = dijkstraRes1ntt;
398
+ const {distMap, minDist, minPath, paths} = dijkstraRes1ntt;
394
399
  expect(distMap).toBeInstanceOf(Map);
395
400
  expect(distMap.size).toBe(9);
396
401
  expect(distMap.get(vertex1)).toBe(0);
@@ -447,13 +452,12 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
447
452
  expect(paths[8]).toBeInstanceOf(Array);
448
453
  expect(paths[8][0]).toBe(vertex1);
449
454
  expect(paths[8][1]).toBe(vertex9);
450
-
451
455
  }
452
456
 
453
457
  const dijkstraWithoutHeapRes1ntt = myGraph.dijkstraWithoutHeap(1, null, true, true);
454
458
  expect(dijkstraWithoutHeapRes1ntt).toBeTruthy();
455
459
  if (dijkstraWithoutHeapRes1ntt) {
456
- const {distMap, minDist, minPath, paths, preMap, seen} = dijkstraWithoutHeapRes1ntt;
460
+ const {distMap, minDist, minPath, paths} = dijkstraWithoutHeapRes1ntt;
457
461
  expect(distMap).toBeInstanceOf(Map);
458
462
  expect(distMap.size).toBe(9);
459
463
  expect(distMap.get(vertex1)).toBe(0);
@@ -510,8 +514,6 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
510
514
  expect(paths[8]).toBeInstanceOf(Array);
511
515
  expect(paths[8][0]).toBe(vertex1);
512
516
  expect(paths[8][1]).toBe(vertex9);
513
-
514
517
  }
515
518
  });
516
519
  });
517
-
@@ -5,13 +5,13 @@ describe('MapGraph Operation Test', () => {
5
5
  const mapGraph = new MapGraph([5.500338, 100.173665]);
6
6
 
7
7
  mapGraph.addVertex(new MapVertex('Surin', 5.466724, 100.274805));
8
- mapGraph.addVertex(new MapVertex('Batu Feringgi Beach', 5.475141, 100.276670));
8
+ mapGraph.addVertex(new MapVertex('Batu Feringgi Beach', 5.475141, 100.27667));
9
9
  mapGraph.addVertex(new MapVertex('Lotus', 5.459044, 100.308767));
10
10
  mapGraph.addVertex(new MapVertex('The Breeza', 5.454197, 100.307859));
11
- mapGraph.addVertex(new MapVertex('Hard Rock Hotel', 5.467850, 100.241876));
12
- mapGraph.addVertex(new MapVertex('Mira', 5.456749, 100.286650));
11
+ mapGraph.addVertex(new MapVertex('Hard Rock Hotel', 5.46785, 100.241876));
12
+ mapGraph.addVertex(new MapVertex('Mira', 5.456749, 100.28665));
13
13
  mapGraph.addVertex(new MapVertex('Penang Bible Church', 5.428683, 100.314825));
14
- mapGraph.addVertex(new MapVertex('Queensbay', 5.332760, 100.306651));
14
+ mapGraph.addVertex(new MapVertex('Queensbay', 5.33276, 100.306651));
15
15
  mapGraph.addVertex(new MapVertex('Saanen Goat Farm', 5.405738, 100.207699));
16
16
  mapGraph.addVertex(new MapVertex('Trinity Auto', 5.401126, 100.303739));
17
17
  mapGraph.addVertex(new MapVertex('Penang Airport', 5.293185, 100.265772));
@@ -42,5 +42,4 @@ describe('MapGraph Operation Test', () => {
42
42
  expect(surinToSaanenGoatFarmViaDij?.minPath.map(v => v.id)).toEqual(expected2);
43
43
  expect(surinToSaanenGoatFarmViaDij?.minDist).toBe(25.2);
44
44
  });
45
-
46
45
  });
@@ -1,19 +1,18 @@
1
1
  import {DirectedGraph, UndirectedGraph} from '../../../../src';
2
2
 
3
3
  describe('Overall Graph Operation Test', () => {
4
-
5
4
  it('Overall DirectedGraph Operation Test', () => {
6
5
  const graph = new DirectedGraph();
7
6
 
8
7
  graph.addVertex('A');
9
8
  graph.addVertex('B');
10
9
 
11
- graph.hasVertex('A'); // true
12
- graph.hasVertex('B'); // true
13
- graph.hasVertex('C'); // false
14
- expect(graph.hasVertex('A')).toBe(true); // true
15
- expect(graph.hasVertex('B')).toBe(true); // true
16
- expect(graph.hasVertex('C')).toBe(false); // false
10
+ graph.hasVertex('A'); // true
11
+ graph.hasVertex('B'); // true
12
+ graph.hasVertex('C'); // false
13
+ expect(graph.hasVertex('A')).toBe(true); // true
14
+ expect(graph.hasVertex('B')).toBe(true); // true
15
+ expect(graph.hasVertex('C')).toBe(false); // false
17
16
 
18
17
  graph.addEdge('A', 'B');
19
18
  graph.hasEdge('A', 'B'); // true
@@ -22,8 +21,8 @@ describe('Overall Graph Operation Test', () => {
22
21
  expect(graph.hasEdge('B', 'A')).toBe(false); // false
23
22
 
24
23
  graph.removeEdgeSrcToDest('A', 'B');
25
- graph.hasEdge('A', 'B'); // false
26
- expect(graph.hasEdge('A', 'B')).toBe(false); // false
24
+ graph.hasEdge('A', 'B'); // false
25
+ expect(graph.hasEdge('A', 'B')).toBe(false); // false
27
26
 
28
27
  graph.addVertex('C');
29
28
 
@@ -31,7 +30,7 @@ describe('Overall Graph Operation Test', () => {
31
30
  graph.addEdge('B', 'C');
32
31
 
33
32
  const topologicalOrderIds = graph.topologicalSort();
34
- expect(topologicalOrderIds).toEqual(['A', 'B', 'C'])
33
+ expect(topologicalOrderIds).toEqual(['A', 'B', 'C']);
35
34
  });
36
35
  it('Overall UndirectedGraph Operation Test', () => {
37
36
  const graph = new UndirectedGraph();
@@ -44,7 +43,7 @@ describe('Overall Graph Operation Test', () => {
44
43
  graph.addEdge('B', 'D');
45
44
 
46
45
  const dijkstraResult = graph.dijkstra('A');
47
- Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D']
46
+ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id); // ['A', 'B', 'D']
48
47
  expect(Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id)).toEqual(['A', 'B', 'D']);
49
48
  });
50
49
  });
@@ -7,7 +7,6 @@ describe('UndirectedGraph Operation Test', () => {
7
7
  graph = new UndirectedGraph();
8
8
  });
9
9
 
10
-
11
10
  it('should add vertices', () => {
12
11
  const vertex1 = new UndirectedVertex('A');
13
12
  const vertex2 = new UndirectedVertex('B');
@@ -21,31 +21,31 @@ describe('Heap Operation Test', () => {
21
21
  });
22
22
 
23
23
  it('should object heap work well', function () {
24
- const minHeap = new MinHeap<{ a: string }>();
24
+ const minHeap = new MinHeap<{a: string}>();
25
25
  minHeap.add(1, {a: 'a1'});
26
26
  minHeap.add(6, {a: 'a6'});
27
27
  minHeap.add(2, {a: 'a2'});
28
28
  minHeap.add(0, {a: 'a0'});
29
29
 
30
30
  expect(minHeap.peek()).toEqual({a: 'a0'});
31
- expect(minHeap.toArray()).toEqual(([{'a': 'a0'}, {'a': 'a1'}, {'a': 'a2'}, {'a': 'a6'}]));
31
+ expect(minHeap.toArray()).toEqual([{a: 'a0'}, {a: 'a1'}, {a: 'a2'}, {a: 'a6'}]);
32
32
  let i = 0;
33
- const expectPolled = [{'a': 'a0'}, {'a': 'a1'}, {'a': 'a2'}, {'a': 'a6'}];
33
+ const expectPolled = [{a: 'a0'}, {a: 'a1'}, {a: 'a2'}, {a: 'a6'}];
34
34
  while (minHeap.size > 0) {
35
35
  expect(minHeap.poll()).toEqual(expectPolled[i]);
36
36
  i++;
37
37
  }
38
38
 
39
- const maxHeap = new MaxHeap<{ a: string }>();
39
+ const maxHeap = new MaxHeap<{a: string}>();
40
40
  maxHeap.add(1, {a: 'a1'});
41
41
  maxHeap.add(6, {a: 'a6'});
42
42
  maxHeap.add(5, {a: 'a5'});
43
43
  maxHeap.add(2, {a: 'a2'});
44
44
  maxHeap.add(0, {a: 'a0'});
45
45
  maxHeap.add(9, {a: 'a9'});
46
- expect(maxHeap.peek()).toEqual({'a': 'a9'});
47
- expect(maxHeap.toArray()).toEqual([{'a': 'a9'}, {'a': 'a2'}, {'a': 'a6'}, {'a': 'a1'}, {'a': 'a0'}, {'a': 'a5'}]);
48
- const maxExpectPolled = [{'a': 'a9'}, {'a': 'a6'}, {'a': 'a5'}, {'a': 'a2'}, {'a': 'a1'}, {'a': 'a0'}];
46
+ expect(maxHeap.peek()).toEqual({a: 'a9'});
47
+ expect(maxHeap.toArray()).toEqual([{a: 'a9'}, {a: 'a2'}, {a: 'a6'}, {a: 'a1'}, {a: 'a0'}, {a: 'a5'}]);
48
+ const maxExpectPolled = [{a: 'a9'}, {a: 'a6'}, {a: 'a5'}, {a: 'a2'}, {a: 'a1'}, {a: 'a0'}];
49
49
  let maxI = 0;
50
50
  while (maxHeap.size > 0) {
51
51
  expect(maxHeap.poll()).toEqual(maxExpectPolled[maxI]);
@@ -53,4 +53,3 @@ describe('Heap Operation Test', () => {
53
53
  }
54
54
  });
55
55
  });
56
-
@@ -1,11 +1,14 @@
1
1
  import {HeapItem, MaxHeap} from '../../../../src';
2
2
 
3
3
  describe('MaxHeap Operation Test', () => {
4
-
5
4
  it('should object Max Heap operations be proper', function () {
6
- const maxHeap = new MaxHeap<{ keyA: string }>();
7
- const myObj1 = {keyA: 'a1'}, myObj6 = {keyA: 'a6'}, myObj5 = {keyA: 'a5'}, myObj2 = {keyA: 'a2'},
8
- myObj0 = {keyA: 'a0'}, myObj9 = {keyA: 'a9'};
5
+ const maxHeap = new MaxHeap<{keyA: string}>();
6
+ const myObj1 = {keyA: 'a1'},
7
+ myObj6 = {keyA: 'a6'},
8
+ myObj5 = {keyA: 'a5'},
9
+ myObj2 = {keyA: 'a2'},
10
+ myObj0 = {keyA: 'a0'},
11
+ myObj9 = {keyA: 'a9'};
9
12
  maxHeap.add(1, myObj1);
10
13
  expect(maxHeap.has(myObj1)).toBe(true);
11
14
  expect(maxHeap.has(myObj9)).toBe(false);
@@ -38,5 +41,4 @@ describe('MaxHeap Operation Test', () => {
38
41
  i++;
39
42
  }
40
43
  });
41
-
42
44
  });
@@ -1,7 +1,6 @@
1
1
  import {HeapItem, MinHeap} from '../../../../src';
2
2
 
3
3
  describe('MinHeap Operation Test', () => {
4
-
5
4
  it('should numeric Min Heap operations be proper', function () {
6
5
  const minNumHeap = new MinHeap<number>();
7
6
  expect(minNumHeap).toBeInstanceOf(MinHeap);
@@ -22,15 +21,15 @@ describe('MinHeap Operation Test', () => {
22
21
  expect(minNumHeap.size).toBe(6);
23
22
 
24
23
  const poll1 = minNumHeap.poll(true);
25
- expect(poll1).toBeInstanceOf(HeapItem)
24
+ expect(poll1).toBeInstanceOf(HeapItem);
26
25
  poll1 instanceof HeapItem && expect(poll1.val).toBe(0);
27
26
 
28
27
  const poll2 = minNumHeap.poll(true);
29
- expect(poll2).toBeInstanceOf(HeapItem)
28
+ expect(poll2).toBeInstanceOf(HeapItem);
30
29
  poll2 instanceof HeapItem && expect(poll2.val).toBe(1);
31
30
 
32
31
  const peek1 = minNumHeap.peek(true);
33
- expect(peek1).toBeInstanceOf(HeapItem)
32
+ expect(peek1).toBeInstanceOf(HeapItem);
34
33
  peek1 instanceof HeapItem && expect(peek1.val).toBe(2);
35
34
 
36
35
  const heapArray = minNumHeap.toArray(true);
@@ -50,7 +49,9 @@ describe('MinHeap Operation Test', () => {
50
49
 
51
50
  const minObjHeap = new MinHeap<MyObject>();
52
51
 
53
- const obj1 = new MyObject('a1'), obj6 = new MyObject('a6'), obj2 = new MyObject('a2'),
52
+ const obj1 = new MyObject('a1'),
53
+ obj6 = new MyObject('a6'),
54
+ obj2 = new MyObject('a2'),
54
55
  obj0 = new MyObject('a0');
55
56
  minObjHeap.add(1, obj1);
56
57
  expect(minObjHeap.has(obj1)).toBe(true);
@@ -3,7 +3,7 @@ import {bigO, magnitude} from '../../../utils';
3
3
 
4
4
  describe('DoublyLinkedList Operation Test', () => {
5
5
  let list: DoublyLinkedList<number>;
6
- let objectList: DoublyLinkedList<{ keyA: number }>;
6
+ let objectList: DoublyLinkedList<{keyA: number}>;
7
7
 
8
8
  beforeEach(() => {
9
9
  list = new DoublyLinkedList();
@@ -117,7 +117,7 @@ describe('DoublyLinkedList Operation Test', () => {
117
117
  list.push(2);
118
118
  list.push(3);
119
119
 
120
- const mappedList = list.map((val) => val * 2);
120
+ const mappedList = list.map(val => val * 2);
121
121
 
122
122
  expect(mappedList.toArray()).toEqual([2, 4, 6]);
123
123
  });
@@ -128,7 +128,7 @@ describe('DoublyLinkedList Operation Test', () => {
128
128
  list.push(3);
129
129
  list.push(4);
130
130
 
131
- const filteredList = list.filter((val) => val % 2 === 0);
131
+ const filteredList = list.filter(val => val % 2 === 0);
132
132
 
133
133
  expect(filteredList.toArray()).toEqual([2, 4]);
134
134
  });
@@ -168,7 +168,7 @@ describe('DoublyLinkedList Operation Test', () => {
168
168
  list.push(2);
169
169
  list.push(3);
170
170
 
171
- const found = list.find((val) => val % 2 === 0);
171
+ const found = list.find(val => val % 2 === 0);
172
172
 
173
173
  expect(found).toBe(2);
174
174
  });
@@ -189,7 +189,7 @@ describe('DoublyLinkedList Operation Test', () => {
189
189
  list.push(3);
190
190
  list.push(4);
191
191
 
192
- const lastEven = list.findLast((val) => val % 2 === 0);
192
+ const lastEven = list.findLast(val => val % 2 === 0);
193
193
 
194
194
  expect(lastEven).toBe(4);
195
195
  });
@@ -234,7 +234,7 @@ describe('DoublyLinkedList Operation Test', () => {
234
234
  list.push(3);
235
235
 
236
236
  const result: number[] = [];
237
- list.forEach((val) => {
237
+ list.forEach(val => {
238
238
  result.push(val * 2);
239
239
  });
240
240
 
@@ -246,7 +246,7 @@ describe('DoublyLinkedList Operation Test', () => {
246
246
  list.push(2);
247
247
  list.push(3);
248
248
 
249
- const mappedList = list.map((val) => val * 2);
249
+ const mappedList = list.map(val => val * 2);
250
250
 
251
251
  expect(mappedList.toArray()).toEqual([2, 4, 6]);
252
252
  });
@@ -257,7 +257,7 @@ describe('DoublyLinkedList Operation Test', () => {
257
257
  list.push(3);
258
258
  list.push(4);
259
259
 
260
- const filteredList = list.filter((val) => val % 2 === 0);
260
+ const filteredList = list.filter(val => val % 2 === 0);
261
261
 
262
262
  expect(filteredList.toArray()).toEqual([2, 4]);
263
263
  });
@@ -339,7 +339,6 @@ describe('DoublyLinkedList Operation Test', () => {
339
339
  const shiftedObj = objectList.shift();
340
340
  expect(shiftedObj).toBe(obj1);
341
341
  });
342
-
343
342
  });
344
343
 
345
344
  describe('DoublyLinkedList Performance Test', () => {
@@ -357,7 +356,7 @@ describe('DoublyLinkedList Performance Test', () => {
357
356
  for (let i = 0; i < magnitude.LINEAR; i++) {
358
357
  list.shift();
359
358
  }
360
- expect(performance.now() - startPopTime).toBeLessThan(bigO.LINEAR * 10);
359
+ expect(performance.now() - startPopTime).toBeLessThan(bigO.LINEAR * 100);
361
360
 
362
361
  expect(list.pop()).toBeUndefined();
363
362
  expect(list.length).toBe(0);
@@ -7,7 +7,7 @@ describe('LinkedList Performance Test', () => {
7
7
 
8
8
  const startPushTime = performance.now();
9
9
  let midNode: DoublyLinkedListNode | null = null;
10
- const midIndex = Math.floor((magnitude.SQUARED) / 2);
10
+ const midIndex = Math.floor(magnitude.SQUARED / 2);
11
11
  for (let i = 0; i < magnitude.SQUARED; i++) {
12
12
  doublyList.push(i);
13
13
  if (i === midIndex) {
@@ -3,10 +3,10 @@ import {bigO, magnitude} from '../../../utils';
3
3
 
4
4
  describe('SinglyLinkedList Operation Test', () => {
5
5
  let list: SinglyLinkedList<number>;
6
- let objectList: SinglyLinkedList<{ keyA: number }>;
6
+ let objectList: SinglyLinkedList<{keyA: number}>;
7
7
  beforeEach(() => {
8
8
  list = new SinglyLinkedList<number>();
9
- objectList = new SinglyLinkedList<{ keyA: number }>();
9
+ objectList = new SinglyLinkedList<{keyA: number}>();
10
10
  });
11
11
 
12
12
  describe('push', () => {
@@ -71,7 +71,6 @@ describe('SinglyLinkedList Operation Test', () => {
71
71
  });
72
72
  });
73
73
 
74
-
75
74
  describe('insertAfter', () => {
76
75
  it('should insert an element after an existing value', () => {
77
76
  list.push(1);
@@ -129,7 +128,6 @@ describe('SinglyLinkedList Operation Test', () => {
129
128
  });
130
129
  });
131
130
 
132
-
133
131
  describe('isEmpty', () => {
134
132
  it('should return true for an empty list', () => {
135
133
  expect(list.isEmpty()).toBe(true);
@@ -309,14 +307,14 @@ describe('SinglyLinkedList Operation Test', () => {
309
307
  list.push(1);
310
308
  list.push(2);
311
309
  list.push(3);
312
- const result = list.find((data) => data % 2 === 0);
310
+ const result = list.find(data => data % 2 === 0);
313
311
  expect(result).toBe(2);
314
312
  });
315
313
 
316
314
  it('should return undefined if element is not found', () => {
317
315
  list.push(1);
318
316
  list.push(3);
319
- const result = list.find((data) => data % 2 === 0);
317
+ const result = list.find(data => data % 2 === 0);
320
318
  expect(result).toBeNull();
321
319
  });
322
320
  });
@@ -376,7 +374,6 @@ describe('SinglyLinkedList Operation Test', () => {
376
374
  const shiftedObj = objectList.shift();
377
375
  expect(shiftedObj).toBe(obj1);
378
376
  });
379
-
380
377
  });
381
378
 
382
379
  describe('SinglyLinkedList Performance Test', () => {
@@ -1,13 +1,13 @@
1
- import {SkipLinkedList} from '../../../../src'
1
+ // import {SkipLinkedList} from '../../../../src'
2
2
 
3
3
  describe('SkipLinkedList Operation Test', () => {
4
4
  it('should xxx', function () {
5
- const xxx = new SkipLinkedList();
5
+ expect(true).toBeTruthy();
6
6
  });
7
7
  });
8
8
 
9
9
  describe('SkipLinkedList Performance Test', () => {
10
10
  it('should xxx', function () {
11
- const xxx = new SkipLinkedList();
11
+ expect(true).toBeTruthy();
12
12
  });
13
13
  });
@@ -4,7 +4,7 @@ describe('MatrixNTI2D', () => {
4
4
  it('should initialize a matrix with rows and columns', () => {
5
5
  const numRows = 3;
6
6
  const numCols = 4;
7
- const matrix = new MatrixNTI2D({ row: numRows, col: numCols });
7
+ const matrix = new MatrixNTI2D({row: numRows, col: numCols});
8
8
 
9
9
  expect(matrix.toArray().length).toBe(numRows);
10
10
  expect(matrix.toArray()[0].length).toBe(numCols);
@@ -14,7 +14,7 @@ describe('MatrixNTI2D', () => {
14
14
  const numRows = 3;
15
15
  const numCols = 4;
16
16
  const initialValue = 42;
17
- const matrix = new MatrixNTI2D({ row: numRows, col: numCols, initialVal: initialValue });
17
+ const matrix = new MatrixNTI2D({row: numRows, col: numCols, initialVal: initialValue});
18
18
 
19
19
  const matrixArray = matrix.toArray();
20
20
  for (let i = 0; i < numRows; i++) {
@@ -27,7 +27,7 @@ describe('MatrixNTI2D', () => {
27
27
  it('should initialize all elements with 0 if no initial value is provided', () => {
28
28
  const numRows = 3;
29
29
  const numCols = 4;
30
- const matrix = new MatrixNTI2D({ row: numRows, col: numCols });
30
+ const matrix = new MatrixNTI2D({row: numRows, col: numCols});
31
31
 
32
32
  const matrixArray = matrix.toArray();
33
33
  for (let i = 0; i < numRows; i++) {
@@ -40,7 +40,7 @@ describe('MatrixNTI2D', () => {
40
40
  it('should convert the matrix to a two-dimensional array', () => {
41
41
  const numRows = 2;
42
42
  const numCols = 3;
43
- const matrix = new MatrixNTI2D({ row: numRows, col: numCols, initialVal: 1 });
43
+ const matrix = new MatrixNTI2D({row: numRows, col: numCols, initialVal: 1});
44
44
 
45
45
  const matrixArray = matrix.toArray();
46
46
  expect(matrixArray.length).toBe(numRows);
@@ -3,7 +3,7 @@ import {Character, NavigatorParams, Turning, Navigator} from '../../../../src';
3
3
  const exampleMatrix: number[][] = [
4
4
  [0, 0, 0, 0],
5
5
  [0, 1, 1, 0],
6
- [0, 0, 0, 0],
6
+ [0, 0, 0, 0]
7
7
  ];
8
8
 
9
9
  // Create a sample redirect object
@@ -11,7 +11,7 @@ const exampleTurning: Turning = {
11
11
  up: 'right',
12
12
  right: 'down',
13
13
  down: 'left',
14
- left: 'up',
14
+ left: 'up'
15
15
  };
16
16
 
17
17
  // Create a sample move callback function
@@ -24,7 +24,7 @@ const exampleOnMove = () => {
24
24
  const exampleInit: NavigatorParams<number>['init'] = {
25
25
  cur: [0, 0],
26
26
  charDir: 'right',
27
- VISITED: -1,
27
+ VISITED: -1
28
28
  };
29
29
 
30
30
  // Create a Navigator Params object
@@ -32,7 +32,7 @@ const exampleNavigatorParams: NavigatorParams<number> = {
32
32
  matrix: exampleMatrix,
33
33
  turning: exampleTurning,
34
34
  onMove: exampleOnMove,
35
- init: exampleInit,
35
+ init: exampleInit
36
36
  };
37
37
 
38
38
  describe('Character class', () => {
@@ -76,5 +76,4 @@ describe('Navigator class', () => {
76
76
  expect(navigator.check('down')).toBe(true); // Blocked by wall
77
77
  expect(navigator.check('left')).toBe(false); // Open path
78
78
  });
79
-
80
79
  });
@@ -2,7 +2,6 @@ import {MaxPriorityQueue} from '../../../../src';
2
2
  import {bigO, magnitude} from '../../../utils';
3
3
 
4
4
  describe('MaxPriorityQueue Operation Test', () => {
5
-
6
5
  it('should add elements and maintain heap property', () => {
7
6
  const priorityQueue = new MaxPriorityQueue<number>();
8
7
 
@@ -18,7 +17,7 @@ describe('MaxPriorityQueue Operation Test', () => {
18
17
  });
19
18
 
20
19
  it('should add elements and maintain heap property in a object MaxPriorityQueue', () => {
21
- const priorityQueue = new MaxPriorityQueue<{ keyA: number }>({
20
+ const priorityQueue = new MaxPriorityQueue<{keyA: number}>({
22
21
  nodes: [{keyA: 5}, {keyA: 3}, {keyA: 1}],
23
22
  comparator: (a, b) => b.keyA - a.keyA
24
23
  });
@@ -67,20 +66,20 @@ describe('MaxPriorityQueue Operation Test', () => {
67
66
 
68
67
  it('should correctly heapify an object array', () => {
69
68
  const nodes = [{keyA: 5}, {keyA: 3}, {keyA: 7}, {keyA: 1}];
70
- const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>({nodes, comparator: (a, b) => b.keyA - a.keyA});
69
+ const maxPQ = MaxPriorityQueue.heapify<{keyA: number}>({nodes, comparator: (a, b) => b.keyA - a.keyA});
71
70
 
72
71
  expect(maxPQ.poll()?.keyA).toBe(7);
73
72
  expect(maxPQ.poll()?.keyA).toBe(5);
74
73
  expect(maxPQ.poll()?.keyA).toBe(3);
75
74
  expect(maxPQ.poll()?.keyA).toBe(1);
76
75
  });
77
-
78
76
  });
79
77
 
80
78
  describe('MaxPriorityQueue Performance Test', () => {
81
-
82
79
  it('should the poll method adheres to a time complexity of O(log n) and executed correctly under large scale distinct data', () => {
83
- const nodes = Array.from(new Set<number>(Array.from(new Array(magnitude.LINEAR), () => Math.floor(Math.random() * magnitude.LINEAR * 100))));
80
+ const nodes = Array.from(
81
+ new Set<number>(Array.from(new Array(magnitude.LINEAR), () => Math.floor(Math.random() * magnitude.LINEAR * 100)))
82
+ );
84
83
  expect(nodes.length).toBeGreaterThan(magnitude.LINEAR / 2);
85
84
  const maxPQ = new MaxPriorityQueue<number>({nodes});
86
85
 
@@ -94,7 +93,6 @@ describe('MaxPriorityQueue Performance Test', () => {
94
93
  }
95
94
  expect(performance.now() - startTime).toBeLessThan(bigO.LINEAR * 50);
96
95
  expect(prev).toBeGreaterThan(0);
97
-
98
96
  });
99
97
 
100
98
  it('should sorted.length to be the same as original data', () => {