data-structure-typed 1.38.9 → 1.39.0

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 (81) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +9 -9
  3. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +8 -0
  4. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +17 -0
  5. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  6. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +3 -3
  7. package/dist/cjs/data-structures/graph/abstract-graph.js +4 -4
  8. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  9. package/dist/cjs/data-structures/graph/directed-graph.d.ts +4 -4
  10. package/dist/cjs/data-structures/graph/directed-graph.js +6 -6
  11. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +3 -3
  12. package/dist/cjs/data-structures/graph/undirected-graph.js +4 -4
  13. package/dist/cjs/data-structures/heap/heap.d.ts +10 -5
  14. package/dist/cjs/data-structures/heap/heap.js +10 -10
  15. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  16. package/dist/cjs/data-structures/heap/max-heap.d.ts +4 -1
  17. package/dist/cjs/data-structures/heap/max-heap.js +9 -7
  18. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  19. package/dist/cjs/data-structures/heap/min-heap.d.ts +4 -1
  20. package/dist/cjs/data-structures/heap/min-heap.js +9 -7
  21. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  22. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +4 -1
  23. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +9 -7
  24. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  25. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +4 -1
  26. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +9 -7
  27. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  28. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +5 -2
  29. package/dist/cjs/data-structures/priority-queue/priority-queue.js +2 -2
  30. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  31. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +8 -0
  32. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +17 -0
  33. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +3 -3
  34. package/dist/mjs/data-structures/graph/abstract-graph.js +4 -4
  35. package/dist/mjs/data-structures/graph/directed-graph.d.ts +4 -4
  36. package/dist/mjs/data-structures/graph/directed-graph.js +6 -6
  37. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +3 -3
  38. package/dist/mjs/data-structures/graph/undirected-graph.js +4 -4
  39. package/dist/mjs/data-structures/heap/heap.d.ts +10 -5
  40. package/dist/mjs/data-structures/heap/heap.js +10 -10
  41. package/dist/mjs/data-structures/heap/max-heap.d.ts +4 -1
  42. package/dist/mjs/data-structures/heap/max-heap.js +9 -7
  43. package/dist/mjs/data-structures/heap/min-heap.d.ts +4 -1
  44. package/dist/mjs/data-structures/heap/min-heap.js +9 -7
  45. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +4 -1
  46. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +9 -7
  47. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +4 -1
  48. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +9 -7
  49. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +5 -2
  50. package/dist/mjs/data-structures/priority-queue/priority-queue.js +2 -2
  51. package/dist/umd/data-structure-typed.min.js +1 -1
  52. package/dist/umd/data-structure-typed.min.js.map +1 -1
  53. package/package.json +5 -5
  54. package/src/data-structures/binary-tree/binary-indexed-tree.ts +20 -0
  55. package/src/data-structures/graph/abstract-graph.ts +5 -5
  56. package/src/data-structures/graph/directed-graph.ts +6 -6
  57. package/src/data-structures/graph/undirected-graph.ts +4 -4
  58. package/src/data-structures/heap/heap.ts +12 -12
  59. package/src/data-structures/heap/max-heap.ts +8 -6
  60. package/src/data-structures/heap/min-heap.ts +8 -6
  61. package/src/data-structures/priority-queue/max-priority-queue.ts +8 -6
  62. package/src/data-structures/priority-queue/min-priority-queue.ts +8 -6
  63. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  64. package/test/integration/bst.test.ts +1 -1
  65. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +1 -1
  66. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +35 -0
  67. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +1 -1
  68. package/test/unit/data-structures/binary-tree/bst.test.ts +3 -3
  69. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  70. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +1 -1
  71. package/test/unit/data-structures/graph/directed-graph.test.ts +3 -3
  72. package/test/unit/data-structures/graph/overall.test.ts +2 -2
  73. package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
  74. package/test/unit/data-structures/heap/heap.test.ts +2 -2
  75. package/test/unit/data-structures/heap/max-heap.test.ts +1 -1
  76. package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
  77. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
  78. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +2 -2
  79. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +3 -3
  80. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +10 -10
  81. package/test/utils/big-o.ts +1 -1
@@ -3,7 +3,7 @@ import {getRandomInt} from '../../../utils';
3
3
 
4
4
  describe('PriorityQueue Operation Test', () => {
5
5
  it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
6
- const minPQ = new PriorityQueue<number>((a, b) => a - b);
6
+ const minPQ = new PriorityQueue<number>({comparator: (a, b) => a - b});
7
7
  minPQ.refill([5, 2, 3, 4, 6, 1]);
8
8
  expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);
9
9
  minPQ.poll();
@@ -11,13 +11,13 @@ describe('PriorityQueue Operation Test', () => {
11
11
  minPQ.poll();
12
12
  expect(minPQ.toArray()).toEqual([4, 5, 6]);
13
13
  expect(minPQ.peek()).toBe(4);
14
- expect(PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], (a, b) => a - b).toArray()).toEqual([
15
- 1, 2, 3, 5, 6, 7, 8, 9, 10
16
- ]);
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
17
  });
18
18
 
19
19
  it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
20
- const maxPriorityQueue = new PriorityQueue<number>((a, b) => b - a);
20
+ const maxPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => b - a});
21
21
  maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]);
22
22
  expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);
23
23
  maxPriorityQueue.poll();
@@ -25,13 +25,13 @@ describe('PriorityQueue Operation Test', () => {
25
25
  maxPriorityQueue.poll();
26
26
  expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
27
27
  expect(maxPriorityQueue.peek()).toBe(3);
28
- expect(PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], (a, b) => a - b).toArray()).toEqual([
29
- 1, 2, 3, 5, 6, 7, 8, 9, 10
30
- ]);
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
31
  });
32
32
 
33
33
  it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
34
- const minPQ1 = new PriorityQueue<number>((a, b) => a - b);
34
+ const minPQ1 = new PriorityQueue<number>({comparator: (a, b) => a - b});
35
35
  minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]);
36
36
  const clonedPriorityQueue = minPQ1.clone();
37
37
  expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes());
@@ -45,7 +45,7 @@ describe('PriorityQueue Operation Test', () => {
45
45
  describe('Priority Queue Performance Test', () => {
46
46
  it('should numeric heap work well', function () {
47
47
  const values = Array.from(new Array(10000), () => getRandomInt(1, 10000000));
48
- const minPriorityQueue = new PriorityQueue<number>((a, b) => a - b);
48
+ const minPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => a - b});
49
49
  minPriorityQueue.refill(values);
50
50
  const sorted = minPriorityQueue.sort();
51
51
  expect(sorted).toEqual(values.sort((a, b) => a - b));
@@ -26,7 +26,7 @@ export const bigO = {
26
26
 
27
27
  function findPotentialN(input: any): number {
28
28
  let longestArray: any[] = [];
29
- let mostProperties: {[key: string]: any} = {};
29
+ let mostProperties: { [key: string]: any } = {};
30
30
 
31
31
  function recurse(obj: any) {
32
32
  if (Array.isArray(obj)) {