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
@@ -1,5 +1,5 @@
1
- import {CP, IterationType, TreeMultimap, TreeMultimapNode} from '../../../../src';
2
- import {isDebugTest} from '../../../config';
1
+ import { CP, IterationType, TreeMultimap, TreeMultimapNode } from '../../../../src';
2
+ import { isDebugTest } from '../../../config';
3
3
 
4
4
  const isDebug = isDebugTest;
5
5
 
@@ -209,23 +209,23 @@ describe('TreeMultimap operations test', () => {
209
209
  it('should perform various operations on a Binary Search Tree with object values', () => {
210
210
  const objTreeMultimap = new TreeMultimap<{ key: number; keyA: number }>();
211
211
  expect(objTreeMultimap).toBeInstanceOf(TreeMultimap);
212
- objTreeMultimap.add(11, {key: 11, keyA: 11});
213
- objTreeMultimap.add(3, {key: 3, keyA: 3});
212
+ objTreeMultimap.add(11, { key: 11, keyA: 11 });
213
+ objTreeMultimap.add(3, { key: 3, keyA: 3 });
214
214
  const values = [
215
- {key: 15, keyA: 15},
216
- {key: 1, keyA: 1},
217
- {key: 8, keyA: 8},
218
- {key: 13, keyA: 13},
219
- {key: 16, keyA: 16},
220
- {key: 2, keyA: 2},
221
- {key: 6, keyA: 6},
222
- {key: 9, keyA: 9},
223
- {key: 12, keyA: 12},
224
- {key: 14, keyA: 14},
225
- {key: 4, keyA: 4},
226
- {key: 7, keyA: 7},
227
- {key: 10, keyA: 10},
228
- {key: 5, keyA: 5}
215
+ { key: 15, keyA: 15 },
216
+ { key: 1, keyA: 1 },
217
+ { key: 8, keyA: 8 },
218
+ { key: 13, keyA: 13 },
219
+ { key: 16, keyA: 16 },
220
+ { key: 2, keyA: 2 },
221
+ { key: 6, keyA: 6 },
222
+ { key: 9, keyA: 9 },
223
+ { key: 12, keyA: 12 },
224
+ { key: 14, keyA: 14 },
225
+ { key: 4, keyA: 4 },
226
+ { key: 7, keyA: 7 },
227
+ { key: 10, keyA: 10 },
228
+ { key: 5, keyA: 5 }
229
229
  ];
230
230
 
231
231
  objTreeMultimap.addMany(
@@ -245,7 +245,7 @@ describe('TreeMultimap operations test', () => {
245
245
 
246
246
  describe('TreeMultimap operations test recursively', () => {
247
247
  it('should perform various operations on a Binary Search Tree with numeric values', () => {
248
- const treeMultimap = new TreeMultimap({iterationType: IterationType.RECURSIVE});
248
+ const treeMultimap = new TreeMultimap({ iterationType: IterationType.RECURSIVE });
249
249
 
250
250
  expect(treeMultimap instanceof TreeMultimap);
251
251
  treeMultimap.add(11, 11);
@@ -449,23 +449,23 @@ describe('TreeMultimap operations test recursively', () => {
449
449
  it('should perform various operations on a Binary Search Tree with object values', () => {
450
450
  const objTreeMultimap = new TreeMultimap<{ key: number; keyA: number }>();
451
451
  expect(objTreeMultimap).toBeInstanceOf(TreeMultimap);
452
- objTreeMultimap.add(11, {key: 11, keyA: 11});
453
- objTreeMultimap.add(3, {key: 3, keyA: 3});
452
+ objTreeMultimap.add(11, { key: 11, keyA: 11 });
453
+ objTreeMultimap.add(3, { key: 3, keyA: 3 });
454
454
  const values = [
455
- {key: 15, keyA: 15},
456
- {key: 1, keyA: 1},
457
- {key: 8, keyA: 8},
458
- {key: 13, keyA: 13},
459
- {key: 16, keyA: 16},
460
- {key: 2, keyA: 2},
461
- {key: 6, keyA: 6},
462
- {key: 9, keyA: 9},
463
- {key: 12, keyA: 12},
464
- {key: 14, keyA: 14},
465
- {key: 4, keyA: 4},
466
- {key: 7, keyA: 7},
467
- {key: 10, keyA: 10},
468
- {key: 5, keyA: 5}
455
+ { key: 15, keyA: 15 },
456
+ { key: 1, keyA: 1 },
457
+ { key: 8, keyA: 8 },
458
+ { key: 13, keyA: 13 },
459
+ { key: 16, keyA: 16 },
460
+ { key: 2, keyA: 2 },
461
+ { key: 6, keyA: 6 },
462
+ { key: 9, keyA: 9 },
463
+ { key: 12, keyA: 12 },
464
+ { key: 14, keyA: 14 },
465
+ { key: 4, keyA: 4 },
466
+ { key: 7, keyA: 7 },
467
+ { key: 10, keyA: 10 },
468
+ { key: 5, keyA: 5 }
469
469
  ];
470
470
 
471
471
  objTreeMultimap.addMany(
@@ -1,4 +1,4 @@
1
- import {AbstractEdge, AbstractGraph, AbstractVertex, VertexKey} from '../../../../src';
1
+ import { AbstractEdge, AbstractGraph, AbstractVertex, VertexKey } from '../../../../src';
2
2
 
3
3
  class MyVertex<V = any> extends AbstractVertex<V> {
4
4
  data?: V;
@@ -22,12 +22,12 @@ class MyEdge<E = any> extends AbstractEdge<E> {
22
22
  }
23
23
  }
24
24
 
25
- class MyGraph<V = any, E = any, VO extends MyVertex<V> = MyVertex<V>, EO extends MyEdge<E> = MyEdge<E>> extends AbstractGraph<
26
- V,
27
- E,
28
- VO,
29
- EO
30
- > {
25
+ class MyGraph<
26
+ V = any,
27
+ E = any,
28
+ VO extends MyVertex<V> = MyVertex<V>,
29
+ EO extends MyEdge<E> = MyEdge<E>
30
+ > extends AbstractGraph<V, E, VO, EO> {
31
31
  createVertex(key: VertexKey, value?: V): VO {
32
32
  return new MyVertex(key, value) as VO;
33
33
  }
@@ -1,4 +1,4 @@
1
- import {DirectedEdge, DirectedGraph, DirectedVertex, VertexKey} from '../../../../src';
1
+ import { DirectedEdge, DirectedGraph, DirectedVertex, VertexKey } from '../../../../src';
2
2
 
3
3
  describe('DirectedGraph Operation Test', () => {
4
4
  let graph: DirectedGraph;
@@ -126,12 +126,12 @@ class MyEdge<E = any> extends DirectedEdge<E> {
126
126
  }
127
127
  }
128
128
 
129
- class MyDirectedGraph<V = any, E = any, VO extends MyVertex<V> = MyVertex<V>, EO extends MyEdge<E> = MyEdge<E>> extends DirectedGraph<
130
- V,
131
- E,
132
- VO,
133
- EO
134
- > {
129
+ class MyDirectedGraph<
130
+ V = any,
131
+ E = any,
132
+ VO extends MyVertex<V> = MyVertex<V>,
133
+ EO extends MyEdge<E> = MyEdge<E>
134
+ > extends DirectedGraph<V, E, VO, EO> {
135
135
  createVertex(key: VertexKey, value: V): VO {
136
136
  return new MyVertex(key, value) as VO;
137
137
  }
@@ -319,7 +319,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
319
319
  const fordResult1 = myGraph.bellmanFord(1);
320
320
  expect(fordResult1).toBeTruthy();
321
321
  expect(fordResult1.hasNegativeCycle).toBeUndefined();
322
- const {distMap, preMap, paths, min, minPath} = fordResult1;
322
+ const { distMap, preMap, paths, min, minPath } = fordResult1;
323
323
  expect(distMap).toBeInstanceOf(Map);
324
324
  expect(distMap.size).toBe(9);
325
325
  expect(distMap.get(vertex1)).toBe(0);
@@ -343,7 +343,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
343
343
  const floydResult = myGraph.floydWarshall();
344
344
  expect(floydResult).toBeTruthy();
345
345
  if (floydResult) {
346
- const {costs, predecessor} = floydResult;
346
+ const { costs, predecessor } = floydResult;
347
347
  expect(costs).toBeInstanceOf(Array);
348
348
  expect(costs.length).toBe(9);
349
349
  expect(costs[0]).toEqual([32, 12, 35, 14, 70, Infinity, 61, Infinity, 19]);
@@ -351,9 +351,29 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
351
351
  expect(costs[2]).toEqual([3, 15, 38, 17, 35, Infinity, 64, Infinity, 22]);
352
352
  expect(costs[3]).toEqual([123, 135, 120, 137, 155, Infinity, 47, Infinity, 126]);
353
353
  expect(costs[4]).toEqual([133, 145, 130, 147, 165, Infinity, 57, Infinity, 136]);
354
- expect(costs[5]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
354
+ expect(costs[5]).toEqual([
355
+ Infinity,
356
+ Infinity,
357
+ Infinity,
358
+ Infinity,
359
+ Infinity,
360
+ Infinity,
361
+ Infinity,
362
+ Infinity,
363
+ Infinity
364
+ ]);
355
365
  expect(costs[6]).toEqual([76, 88, 73, 90, 108, Infinity, 137, Infinity, 79]);
356
- expect(costs[7]).toEqual([Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity]);
366
+ expect(costs[7]).toEqual([
367
+ Infinity,
368
+ Infinity,
369
+ Infinity,
370
+ Infinity,
371
+ Infinity,
372
+ Infinity,
373
+ Infinity,
374
+ Infinity,
375
+ Infinity
376
+ ]);
357
377
  expect(costs[8]).toEqual([173, 185, 170, 187, 205, Infinity, 97, Infinity, 176]);
358
378
 
359
379
  expect(predecessor).toBeInstanceOf(Array);
@@ -369,7 +389,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
369
389
 
370
390
  expect(dijkstraRes12tt).toBeTruthy();
371
391
  if (dijkstraRes12tt) {
372
- const {distMap, minDist, minPath, paths} = dijkstraRes12tt;
392
+ const { distMap, minDist, minPath, paths } = dijkstraRes12tt;
373
393
  expect(distMap).toBeInstanceOf(Map);
374
394
  expect(distMap.size).toBe(9);
375
395
  expect(distMap.get(vertex1)).toBe(0);
@@ -420,7 +440,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
420
440
 
421
441
  expect(dijkstraRes1ntt).toBeTruthy();
422
442
  if (dijkstraRes1ntt) {
423
- const {distMap, minDist, minPath, paths} = dijkstraRes1ntt;
443
+ const { distMap, minDist, minPath, paths } = dijkstraRes1ntt;
424
444
  expect(distMap).toBeInstanceOf(Map);
425
445
  expect(distMap.size).toBe(9);
426
446
  expect(distMap.get(vertex1)).toBe(0);
@@ -482,7 +502,7 @@ describe('Inherit from DirectedGraph and perform operations test2.', () => {
482
502
  const dijkstraWithoutHeapRes1ntt = myGraph.dijkstraWithoutHeap(1, null, true, true);
483
503
  expect(dijkstraWithoutHeapRes1ntt).toBeTruthy();
484
504
  if (dijkstraWithoutHeapRes1ntt) {
485
- const {distMap, minDist, minPath, paths} = dijkstraWithoutHeapRes1ntt;
505
+ const { distMap, minDist, minPath, paths } = dijkstraWithoutHeapRes1ntt;
486
506
  expect(distMap).toBeInstanceOf(Map);
487
507
  expect(distMap.size).toBe(9);
488
508
  expect(distMap.get(vertex1)).toBe(0);
@@ -1,4 +1,4 @@
1
- import {MapEdge, MapGraph, MapVertex} from '../../../../src';
1
+ import { MapEdge, MapGraph, MapVertex } from '../../../../src';
2
2
 
3
3
  describe('MapGraph Operation Test', () => {
4
4
  it('dijkstra shortest path', () => {
@@ -1,4 +1,4 @@
1
- import {DirectedGraph, UndirectedGraph} from '../../../../src';
1
+ import { DirectedGraph, UndirectedGraph } from '../../../../src';
2
2
 
3
3
  describe('Overall Graph Operation Test', () => {
4
4
  it('Overall DirectedGraph Operation Test', () => {
@@ -1,4 +1,4 @@
1
- import {UndirectedEdge, UndirectedGraph, UndirectedVertex} from '../../../../src';
1
+ import { UndirectedEdge, UndirectedGraph, UndirectedVertex } from '../../../../src';
2
2
  import saltyVertexes from './salty-vertexes.json';
3
3
  import saltyEdges from './salty-edges.json';
4
4
 
@@ -1,4 +1,4 @@
1
- import {CoordinateMap} from '../../../../src';
1
+ import { CoordinateMap } from '../../../../src';
2
2
 
3
3
  describe('CoordinateMap', () => {
4
4
  it('should set and get values correctly', () => {
@@ -1,4 +1,4 @@
1
- import {CoordinateSet} from '../../../../src';
1
+ import { CoordinateSet } from '../../../../src';
2
2
 
3
3
  describe('CoordinateSet', () => {
4
4
  it('should add and check values correctly', () => {
@@ -1,6 +1,5 @@
1
- import {HashMap} from '../../../../src';
2
- import {getRandomInt, getRandomIntArray} from "../../../utils";
3
-
1
+ import { HashMap } from '../../../../src';
2
+ import { getRandomInt, getRandomIntArray } from '../../../utils';
4
3
 
5
4
  describe('HashMap', () => {
6
5
  let hashMap: HashMap<string, number>;
@@ -66,7 +65,6 @@ describe('HashMap', () => {
66
65
  // expect(entries).toContainEqual(['three', 3]);
67
66
  });
68
67
 
69
-
70
68
  it('should resize the table when load factor is exceeded', () => {
71
69
  // Set a small initial capacity for testing resizing
72
70
  hashMap = new HashMap<string, number>();
@@ -84,7 +82,6 @@ describe('HashMap', () => {
84
82
  });
85
83
 
86
84
  it('should allow using a custom hash function', () => {
87
-
88
85
  hashMap = new HashMap<string, number>();
89
86
 
90
87
  hashMap.set('one', 1);
@@ -115,14 +112,14 @@ describe('HashMap', () => {
115
112
  });
116
113
 
117
114
  it('should handle object keys correctly', () => {
118
- const keyObj = {id: 1};
115
+ const keyObj = { id: 1 };
119
116
  hashMap.set(keyObj, 'objectValue');
120
117
  expect(hashMap.get(keyObj)).toBe('objectValue');
121
118
  });
122
119
 
123
120
  it('should handle number keys correctly', () => {
124
- hashMap.set(999, {a: '999Value'});
125
- expect(hashMap.get(999)).toEqual({a: '999Value'});
121
+ hashMap.set(999, { a: '999Value' });
122
+ expect(hashMap.get(999)).toEqual({ a: '999Value' });
126
123
  });
127
124
 
128
125
  it('should update the value for an existing key', () => {
@@ -156,7 +153,10 @@ describe('HashMap', () => {
156
153
  for (const value of hashMap) {
157
154
  values.push(value);
158
155
  }
159
- expect(values).toEqual([['key1', 'value1'], ['key2', 'value2']]);
156
+ expect(values).toEqual([
157
+ ['key1', 'value1'],
158
+ ['key2', 'value2']
159
+ ]);
160
160
  });
161
161
 
162
162
  // test('should delete element at specific index', () => {
@@ -212,7 +212,6 @@ describe('HashMap', () => {
212
212
  hashMap.set('key2', 'value2');
213
213
  const iterator = hashMap.reverseBegin;
214
214
  expect(iterator.next().current).toEqual(['key1', 'value1']);
215
-
216
215
  });
217
216
 
218
217
  test('should return the last element', () => {
@@ -230,5 +229,4 @@ describe('HashMap', () => {
230
229
  hashMap.set('key2', 'value2');
231
230
  expect(hashMap.getAt(1)).toEqual(['key2', 'value2']);
232
231
  });
233
- })
234
-
232
+ });
@@ -1,4 +1,4 @@
1
- import {HashTable, HashTableNode} from '../../../../src';
1
+ import { HashTable, HashTableNode } from '../../../../src';
2
2
 
3
3
  describe('HashNode', () => {
4
4
  it('should create a HashNode with key and value', () => {
@@ -1,5 +1,5 @@
1
- import {FibonacciHeap, MaxHeap, MinHeap} from '../../../../src';
2
- import {logBigOMetricsWrap} from '../../../utils';
1
+ import { FibonacciHeap, MaxHeap, MinHeap } from '../../../../src';
2
+ import { logBigOMetricsWrap } from '../../../utils';
3
3
 
4
4
  describe('Heap Operation Test', () => {
5
5
  it('should numeric heap work well', function () {
@@ -22,34 +22,46 @@ describe('Heap Operation Test', () => {
22
22
  });
23
23
 
24
24
  it('should object heap work well', function () {
25
- const minHeap = new MinHeap<{ a: string; key: number }>({comparator: (a, b) => a.key - b.key});
26
- minHeap.add({key: 1, a: 'a1'});
27
- minHeap.add({key: 6, a: 'a6'});
28
- minHeap.add({key: 2, a: 'a2'});
29
- minHeap.add({key: 0, a: 'a0'});
30
-
31
- expect(minHeap.peek()).toEqual({a: 'a0', key: 0});
32
- expect(minHeap.toArray().map(item => ({a: item.a}))).toEqual([{a: 'a0'}, {a: 'a1'}, {a: 'a2'}, {a: 'a6'}]);
25
+ const minHeap = new MinHeap<{ a: string; key: number }>({ comparator: (a, b) => a.key - b.key });
26
+ minHeap.add({ key: 1, a: 'a1' });
27
+ minHeap.add({ key: 6, a: 'a6' });
28
+ minHeap.add({ key: 2, a: 'a2' });
29
+ minHeap.add({ key: 0, a: 'a0' });
30
+
31
+ expect(minHeap.peek()).toEqual({ a: 'a0', key: 0 });
32
+ expect(minHeap.toArray().map(item => ({ a: item.a }))).toEqual([
33
+ { a: 'a0' },
34
+ { a: 'a1' },
35
+ { a: 'a2' },
36
+ { a: 'a6' }
37
+ ]);
33
38
  let i = 0;
34
- const expectPolled = [{a: 'a0'}, {a: 'a1'}, {a: 'a2'}, {a: 'a6'}];
39
+ const expectPolled = [{ a: 'a0' }, { a: 'a1' }, { a: 'a2' }, { a: 'a6' }];
35
40
  while (minHeap.size > 0) {
36
- expect({a: minHeap.poll()?.a}).toEqual(expectPolled[i]);
41
+ expect({ a: minHeap.poll()?.a }).toEqual(expectPolled[i]);
37
42
  i++;
38
43
  }
39
44
 
40
- const maxHeap = new MaxHeap<{ key: number; a: string }>({comparator: (a, b) => b.key - a.key});
41
- maxHeap.add({key: 1, a: 'a1'});
42
- maxHeap.add({key: 6, a: 'a6'});
43
- maxHeap.add({key: 5, a: 'a5'});
44
- maxHeap.add({key: 2, a: 'a2'});
45
- maxHeap.add({key: 0, a: 'a0'});
46
- maxHeap.add({key: 9, a: 'a9'});
47
- expect(maxHeap.peek()).toEqual({a: 'a9', key: 9});
48
- expect(maxHeap.toArray().map(item => ({a: item.a}))).toEqual([{a: 'a9'}, {a: 'a2'}, {a: 'a6'}, {a: 'a1'}, {a: 'a0'}, {a: 'a5'}]);
49
- const maxExpectPolled = [{a: 'a9'}, {a: 'a6'}, {a: 'a5'}, {a: 'a2'}, {a: 'a1'}, {a: 'a0'}];
45
+ const maxHeap = new MaxHeap<{ key: number; a: string }>({ comparator: (a, b) => b.key - a.key });
46
+ maxHeap.add({ key: 1, a: 'a1' });
47
+ maxHeap.add({ key: 6, a: 'a6' });
48
+ maxHeap.add({ key: 5, a: 'a5' });
49
+ maxHeap.add({ key: 2, a: 'a2' });
50
+ maxHeap.add({ key: 0, a: 'a0' });
51
+ maxHeap.add({ key: 9, a: 'a9' });
52
+ expect(maxHeap.peek()).toEqual({ a: 'a9', key: 9 });
53
+ expect(maxHeap.toArray().map(item => ({ a: item.a }))).toEqual([
54
+ { a: 'a9' },
55
+ { a: 'a2' },
56
+ { a: 'a6' },
57
+ { a: 'a1' },
58
+ { a: 'a0' },
59
+ { a: 'a5' }
60
+ ]);
61
+ const maxExpectPolled = [{ a: 'a9' }, { a: 'a6' }, { a: 'a5' }, { a: 'a2' }, { a: 'a1' }, { a: 'a0' }];
50
62
  let maxI = 0;
51
63
  while (maxHeap.size > 0) {
52
- expect({a: maxHeap.poll()?.a}).toEqual(maxExpectPolled[maxI]);
64
+ expect({ a: maxHeap.poll()?.a }).toEqual(maxExpectPolled[maxI]);
53
65
  maxI++;
54
66
  }
55
67
  });
@@ -1,11 +1,11 @@
1
- import {Comparator, MaxHeap} from '../../../../src';
1
+ import { Comparator, MaxHeap } from '../../../../src';
2
2
 
3
3
  describe('MaxHeap', () => {
4
4
  const numberComparator: Comparator<number> = (a, b) => b - a;
5
5
  let maxHeap: MaxHeap<number>;
6
6
 
7
7
  beforeEach(() => {
8
- maxHeap = new MaxHeap({comparator: numberComparator});
8
+ maxHeap = new MaxHeap({ comparator: numberComparator });
9
9
  });
10
10
 
11
11
  it('add and poll elements in descending order', () => {
@@ -1,11 +1,11 @@
1
- import {Comparator, MinHeap} from '../../../../src';
1
+ import { Comparator, MinHeap } from '../../../../src';
2
2
 
3
3
  describe('MinHeap', () => {
4
4
  const numberComparator: Comparator<number> = (a, b) => a - b;
5
5
  let minHeap: MinHeap<number>;
6
6
 
7
7
  beforeEach(() => {
8
- minHeap = new MinHeap({comparator: numberComparator});
8
+ minHeap = new MinHeap({ comparator: numberComparator });
9
9
  });
10
10
 
11
11
  it('add and poll elements in ascending order', () => {
@@ -1,4 +1,4 @@
1
- import {DoublyLinkedList, DoublyLinkedListNode} from '../../../../src';
1
+ import { DoublyLinkedList, DoublyLinkedListNode } from '../../../../src';
2
2
 
3
3
  describe('DoublyLinkedListNode', () => {
4
4
  it('should DoublyLinkedListNode', () => {
@@ -370,9 +370,9 @@ describe('DoublyLinkedList Operation Test', () => {
370
370
  });
371
371
 
372
372
  it('should insert and manipulate objects with numeric properties', () => {
373
- const obj1 = {keyA: 10};
374
- const obj2 = {keyA: 20};
375
- const obj3 = {keyA: 30};
373
+ const obj1 = { keyA: 10 };
374
+ const obj2 = { keyA: 20 };
375
+ const obj3 = { keyA: 30 };
376
376
 
377
377
  objectList.push(obj1);
378
378
  objectList.push(obj2);
@@ -380,7 +380,7 @@ describe('DoublyLinkedList Operation Test', () => {
380
380
 
381
381
  expect(objectList.toArray()).toEqual([obj1, obj2, obj3]);
382
382
 
383
- const newObj = {keyA: 25}; // Corrected newObj value
383
+ const newObj = { keyA: 25 }; // Corrected newObj value
384
384
  const insertSuccess = objectList.insertBefore(obj2, newObj);
385
385
  expect(insertSuccess).toBe(true);
386
386
 
@@ -1,4 +1,4 @@
1
- import {SinglyLinkedList, SinglyLinkedListNode} from '../../../../src';
1
+ import { SinglyLinkedList, SinglyLinkedListNode } from '../../../../src';
2
2
 
3
3
  describe('SinglyLinkedListNode', () => {
4
4
  it('should SinglyLinkedList', () => {
@@ -366,9 +366,9 @@ describe('SinglyLinkedList Operation Test', () => {
366
366
  });
367
367
 
368
368
  it('should insert and manipulate objects with numeric properties', () => {
369
- const obj1 = {keyA: 1};
370
- const obj2 = {keyA: 2};
371
- const obj3 = {keyA: 3};
369
+ const obj1 = { keyA: 1 };
370
+ const obj2 = { keyA: 2 };
371
+ const obj3 = { keyA: 3 };
372
372
 
373
373
  objectList.push(obj1);
374
374
  objectList.push(obj2);
@@ -376,7 +376,7 @@ describe('SinglyLinkedList Operation Test', () => {
376
376
 
377
377
  expect(objectList.toArray()).toEqual([obj1, obj2, obj3]);
378
378
 
379
- const newObj = {keyA: 2.5}; // Corrected newObj value
379
+ const newObj = { keyA: 2.5 }; // Corrected newObj value
380
380
  const insertSuccess = objectList.insertBefore(obj2, newObj);
381
381
  expect(insertSuccess).toBe(true);
382
382
 
@@ -1,4 +1,4 @@
1
- import {SkipList} from '../../../../src';
1
+ import { SkipList } from '../../../../src';
2
2
 
3
3
  describe('SkipList', () => {
4
4
  let skipList: SkipList<number, string>;
@@ -1,10 +1,10 @@
1
- import {MatrixNTI2D} from '../../../../src';
1
+ import { MatrixNTI2D } from '../../../../src';
2
2
 
3
3
  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);
@@ -1,5 +1,5 @@
1
- import {Matrix2D, Vector2D} from '../../../../src';
2
- import {isDebugTest} from '../../../config';
1
+ import { Matrix2D, Vector2D } from '../../../../src';
2
+ import { isDebugTest } from '../../../config';
3
3
 
4
4
  const isDebug = isDebugTest;
5
5
  describe('Matrix2D', () => {
@@ -288,7 +288,7 @@ describe('Matrix2D', () => {
288
288
  const vector = new Vector2D(2, 3);
289
289
  const result = Matrix2D.multiplyByVector(matrix, vector);
290
290
  isDebug && console.log(JSON.stringify(result));
291
- expect(result).toEqual({x: 17, y: 35, w: 1});
291
+ expect(result).toEqual({ x: 17, y: 35, w: 1 });
292
292
  });
293
293
 
294
294
  it('should correctly create a view matrix', () => {
@@ -1,5 +1,5 @@
1
- import {Character, Navigator, NavigatorParams, Turning} from '../../../../src';
2
- import {isDebugTest} from '../../../config';
1
+ import { Character, Navigator, NavigatorParams, Turning } from '../../../../src';
2
+ import { isDebugTest } from '../../../config';
3
3
 
4
4
  const isDebug = isDebugTest;
5
5
  const exampleMatrix: number[][] = [
@@ -1,4 +1,4 @@
1
- import {Vector2D} from '../../../../src';
1
+ import { Vector2D } from '../../../../src';
2
2
 
3
3
  describe('Vector2D', () => {
4
4
  it('should create a vector with default values', () => {
@@ -1,4 +1,4 @@
1
- import {MaxPriorityQueue} from '../../../../src';
1
+ import { MaxPriorityQueue } from '../../../../src';
2
2
 
3
3
  describe('MaxPriorityQueue Operation Test', () => {
4
4
  it('should add elements and maintain heap property', () => {
@@ -16,9 +16,9 @@ describe('MaxPriorityQueue Operation Test', () => {
16
16
  });
17
17
 
18
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});
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
22
 
23
23
  expect(priorityQueue.poll()?.keyA).toBe(7);
24
24
  expect(priorityQueue.poll()?.keyA).toBe(5);
@@ -52,7 +52,7 @@ describe('MaxPriorityQueue Operation Test', () => {
52
52
 
53
53
  it('should correctly heapify an array', () => {
54
54
  const array = [5, 3, 7, 1];
55
- const heap = MaxPriorityQueue.heapify<number>({nodes: array, comparator: (a, b) => b - a});
55
+ const heap = MaxPriorityQueue.heapify<number>({ nodes: array, comparator: (a, b) => b - a });
56
56
  heap.refill(array);
57
57
 
58
58
  expect(heap.poll()).toBe(7);
@@ -62,8 +62,8 @@ describe('MaxPriorityQueue Operation Test', () => {
62
62
  });
63
63
 
64
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});
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
67
 
68
68
  expect(maxPQ.poll()?.keyA).toBe(7);
69
69
  expect(maxPQ.poll()?.keyA).toBe(5);
@@ -1,4 +1,4 @@
1
- import {MinPriorityQueue} from '../../../../src';
1
+ import { MinPriorityQueue } from '../../../../src';
2
2
 
3
3
  describe('MinPriorityQueue Operation Test', () => {
4
4
  it('should check if a node exists in the queue', () => {