data-structure-typed 1.44.1 → 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 (161) hide show
  1. package/.eslintrc.js +6 -6
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +15 -15
  4. package/benchmark/report.html +15 -15
  5. package/benchmark/report.json +121 -121
  6. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  11. package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
  12. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  13. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  14. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  15. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  16. package/dist/cjs/data-structures/hash/hash-map.d.ts +230 -37
  17. package/dist/cjs/data-structures/hash/hash-map.js +427 -115
  18. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  19. package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
  20. package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
  21. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  22. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  23. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  24. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  25. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  26. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  27. package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
  28. package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
  29. package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
  30. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  31. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  32. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  33. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  34. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  35. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  36. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  37. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +15 -1
  38. package/dist/cjs/types/data-structures/hash/index.d.ts +6 -0
  39. package/dist/cjs/types/data-structures/hash/index.js +20 -0
  40. package/dist/cjs/types/data-structures/hash/index.js.map +1 -1
  41. package/dist/cjs/utils/utils.d.ts +3 -0
  42. package/dist/cjs/utils/utils.js +15 -1
  43. package/dist/cjs/utils/utils.js.map +1 -1
  44. package/dist/mjs/data-structures/hash/hash-map.d.ts +230 -37
  45. package/dist/mjs/data-structures/hash/hash-map.js +433 -121
  46. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +15 -1
  47. package/dist/mjs/types/data-structures/hash/index.d.ts +6 -0
  48. package/dist/mjs/types/data-structures/hash/index.js +6 -1
  49. package/dist/mjs/utils/utils.d.ts +3 -0
  50. package/dist/mjs/utils/utils.js +11 -0
  51. package/dist/umd/data-structure-typed.js +533 -207
  52. package/dist/umd/data-structure-typed.min.js +1 -1
  53. package/dist/umd/data-structure-typed.min.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/data-structures/binary-tree/avl-tree.ts +7 -7
  56. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
  57. package/src/data-structures/binary-tree/binary-tree.ts +39 -31
  58. package/src/data-structures/binary-tree/bst.ts +12 -8
  59. package/src/data-structures/binary-tree/rb-tree.ts +17 -6
  60. package/src/data-structures/binary-tree/segment-tree.ts +1 -1
  61. package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
  62. package/src/data-structures/graph/abstract-graph.ts +46 -31
  63. package/src/data-structures/graph/directed-graph.ts +10 -5
  64. package/src/data-structures/graph/map-graph.ts +8 -8
  65. package/src/data-structures/graph/undirected-graph.ts +9 -9
  66. package/src/data-structures/hash/hash-map.ts +430 -123
  67. package/src/data-structures/hash/hash-table.ts +1 -1
  68. package/src/data-structures/hash/tree-map.ts +2 -1
  69. package/src/data-structures/hash/tree-set.ts +2 -1
  70. package/src/data-structures/heap/heap.ts +8 -5
  71. package/src/data-structures/heap/max-heap.ts +3 -3
  72. package/src/data-structures/heap/min-heap.ts +3 -3
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  74. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  75. package/src/data-structures/matrix/matrix.ts +2 -2
  76. package/src/data-structures/matrix/matrix2d.ts +1 -1
  77. package/src/data-structures/matrix/navigator.ts +3 -3
  78. package/src/data-structures/matrix/vector2d.ts +2 -1
  79. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
  80. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
  81. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  82. package/src/data-structures/queue/deque.ts +5 -4
  83. package/src/data-structures/queue/queue.ts +2 -2
  84. package/src/data-structures/tree/tree.ts +1 -1
  85. package/src/data-structures/trie/trie.ts +1 -1
  86. package/src/interfaces/binary-tree.ts +2 -2
  87. package/src/interfaces/graph.ts +1 -1
  88. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
  89. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  90. package/src/types/data-structures/binary-tree/bst.ts +2 -2
  91. package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
  92. package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
  93. package/src/types/data-structures/hash/hash-map.ts +17 -1
  94. package/src/types/data-structures/hash/index.ts +7 -0
  95. package/src/types/data-structures/matrix/navigator.ts +1 -1
  96. package/src/types/utils/utils.ts +1 -1
  97. package/src/types/utils/validate-type.ts +18 -4
  98. package/src/utils/utils.ts +16 -3
  99. package/test/config.ts +1 -1
  100. package/test/integration/all-in-one.ts +1 -1
  101. package/test/integration/avl-tree.test.ts +1 -1
  102. package/test/integration/bst.test.ts +19 -19
  103. package/test/integration/heap.test.js +1 -1
  104. package/test/integration/index.html +7 -7
  105. package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
  106. package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
  107. package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
  108. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +6 -6
  109. package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
  110. package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
  111. package/test/performance/data-structures/heap/heap.test.ts +5 -5
  112. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
  113. package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
  114. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
  115. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
  116. package/test/performance/data-structures/queue/deque.test.ts +5 -5
  117. package/test/performance/data-structures/queue/queue.test.ts +6 -6
  118. package/test/performance/data-structures/stack/stack.test.ts +6 -6
  119. package/test/performance/data-structures/trie/trie.test.ts +4 -4
  120. package/test/performance/reportor.ts +15 -13
  121. package/test/performance/types/reportor.ts +1 -1
  122. package/test/types/utils/json2html.ts +1 -1
  123. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +8 -8
  124. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
  125. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
  126. package/test/unit/data-structures/binary-tree/bst.test.ts +50 -46
  127. package/test/unit/data-structures/binary-tree/overall.test.ts +18 -18
  128. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +21 -21
  129. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
  130. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -37
  131. package/test/unit/data-structures/graph/abstract-graph.test.ts +9 -8
  132. package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
  133. package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
  134. package/test/unit/data-structures/graph/overall.test.ts +1 -1
  135. package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
  136. package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
  137. package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
  138. package/test/unit/data-structures/hash/hash-map.test.ts +150 -21
  139. package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
  140. package/test/unit/data-structures/heap/heap.test.ts +41 -29
  141. package/test/unit/data-structures/heap/max-heap.test.ts +6 -6
  142. package/test/unit/data-structures/heap/min-heap.test.ts +6 -6
  143. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
  144. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +7 -7
  145. package/test/unit/data-structures/linked-list/skip-list.test.ts +5 -5
  146. package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
  147. package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
  148. package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
  149. package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
  150. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
  151. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
  152. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -13
  153. package/test/unit/data-structures/queue/deque.test.ts +28 -28
  154. package/test/unit/data-structures/queue/queue.test.ts +3 -3
  155. package/test/unit/data-structures/stack/stack.test.ts +1 -1
  156. package/test/unit/data-structures/tree/tree.test.ts +1 -1
  157. package/test/unit/data-structures/trie/trie.test.ts +10 -10
  158. package/test/utils/array.ts +2 -2
  159. package/test/utils/big-o.ts +4 -4
  160. package/test/utils/json2html.ts +7 -3
  161. package/test/utils/number.ts +1 -1
@@ -1,10 +1,10 @@
1
- import {BST} from '../../../../src';
1
+ import { BST } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {getRandomIntArray, magnitude} from '../../../utils';
3
+ import { getRandomIntArray, magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
6
  const bst = new BST<number>();
7
- const {TEN_THOUSAND} = magnitude;
7
+ const { TEN_THOUSAND } = magnitude;
8
8
  const arr = getRandomIntArray(TEN_THOUSAND, 0, TEN_THOUSAND, true);
9
9
 
10
10
  suite
@@ -33,4 +33,4 @@ suite
33
33
  }
34
34
  });
35
35
 
36
- export {suite};
36
+ export { suite };
@@ -1,12 +1,12 @@
1
- import {RedBlackTree} from '../../../../src';
1
+ import { RedBlackTree } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {getRandomIntArray, magnitude} from '../../../utils';
4
- import {OrderedMap} from 'js-sdsl';
5
- import {isCompetitor} from '../../../config';
3
+ import { getRandomIntArray, magnitude } from '../../../utils';
4
+ import { OrderedMap } from 'js-sdsl';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
8
  const rbTree = new RedBlackTree();
9
- const {HUNDRED_THOUSAND} = magnitude;
9
+ const { HUNDRED_THOUSAND } = magnitude;
10
10
  const arr = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND, true);
11
11
  const competitor = new OrderedMap<number, number>();
12
12
 
@@ -41,4 +41,4 @@ suite
41
41
  }
42
42
  });
43
43
 
44
- export {suite};
44
+ export { suite };
@@ -1,9 +1,9 @@
1
- import {DirectedGraph} from '../../../../src';
1
+ import { DirectedGraph } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {getRandomIndex, getRandomWords, magnitude} from '../../../utils';
3
+ import { getRandomIndex, getRandomWords, magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
- const {THOUSAND} = magnitude;
6
+ const { THOUSAND } = magnitude;
7
7
  const graph = new DirectedGraph<number, number>();
8
8
  const vertexes = getRandomWords(THOUSAND);
9
9
 
@@ -46,4 +46,4 @@ suite
46
46
  // }
47
47
  });
48
48
 
49
- export {suite};
49
+ export { suite };
@@ -1,11 +1,11 @@
1
- import {HashMap} from '../../../../src';
2
- import {HashMap as CHashMap} from 'js-sdsl';
1
+ import { HashMap } from '../../../../src';
2
+ import { HashMap as CHashMap } from 'js-sdsl';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
- const {TEN_THOUSAND} = magnitude;
8
+ const { TEN_THOUSAND } = magnitude;
9
9
 
10
10
  suite.add(`${TEN_THOUSAND.toLocaleString()} set`, () => {
11
11
  const hm = new HashMap<number, number>();
@@ -45,4 +45,4 @@ if (isCompetitor) {
45
45
  }
46
46
  });
47
47
  }
48
- export {suite};
48
+ export { suite };
@@ -1,13 +1,13 @@
1
- import {FibonacciHeap, Heap} from '../../../../src';
1
+ import { FibonacciHeap, Heap } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {magnitude} from '../../../utils';
3
+ import { magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
- const {TEN_THOUSAND} = magnitude;
6
+ const { TEN_THOUSAND } = magnitude;
7
7
 
8
8
  suite
9
9
  .add(`${TEN_THOUSAND.toLocaleString()} add & pop`, () => {
10
- const heap = new Heap<number>({comparator: (a, b) => b - a});
10
+ const heap = new Heap<number>({ comparator: (a, b) => b - a });
11
11
 
12
12
  for (let i = 0; i < TEN_THOUSAND; i++) {
13
13
  heap.add(i);
@@ -27,4 +27,4 @@ suite
27
27
  }
28
28
  });
29
29
 
30
- export {suite};
30
+ export { suite };
@@ -1,11 +1,11 @@
1
- import {DoublyLinkedList, DoublyLinkedListNode} from '../../../../src';
2
- import {LinkList as CLinkedList} from 'js-sdsl';
1
+ import { DoublyLinkedList, DoublyLinkedListNode } from '../../../../src';
2
+ import { LinkList as CLinkedList } from 'js-sdsl';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
- const {LINEAR} = magnitude;
8
+ const { LINEAR } = magnitude;
9
9
 
10
10
  suite.add(`${LINEAR.toLocaleString()} unshift`, () => {
11
11
  const list = new DoublyLinkedList<number>();
@@ -48,4 +48,4 @@ suite
48
48
  }
49
49
  });
50
50
 
51
- export {suite};
51
+ export { suite };
@@ -1,9 +1,9 @@
1
- import {SinglyLinkedList, SinglyLinkedListNode} from '../../../../src';
1
+ import { SinglyLinkedList, SinglyLinkedListNode } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {magnitude} from '../../../utils';
3
+ import { magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
- const {TEN_THOUSAND} = magnitude;
6
+ const { TEN_THOUSAND } = magnitude;
7
7
 
8
8
  suite
9
9
  .add(`${TEN_THOUSAND.toLocaleString()} push & pop`, () => {
@@ -31,4 +31,4 @@ suite
31
31
  }
32
32
  });
33
33
 
34
- export {suite};
34
+ export { suite };
@@ -1,12 +1,14 @@
1
- import {MaxPriorityQueue} from '../../../../src';
1
+ import { MaxPriorityQueue } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {magnitude} from '../../../utils';
3
+ import { magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
- const {TEN_THOUSAND} = magnitude;
6
+ const { TEN_THOUSAND } = magnitude;
7
7
 
8
8
  suite.add(`${TEN_THOUSAND.toLocaleString()} refill & poll`, () => {
9
- const nodes = Array.from(new Set<number>(Array.from(new Array(TEN_THOUSAND), () => Math.floor(Math.random() * TEN_THOUSAND * 100))));
9
+ const nodes = Array.from(
10
+ new Set<number>(Array.from(new Array(TEN_THOUSAND), () => Math.floor(Math.random() * TEN_THOUSAND * 100)))
11
+ );
10
12
  const maxPQ = new MaxPriorityQueue<number>();
11
13
  maxPQ.refill(nodes);
12
14
  while (maxPQ.size > 0) {
@@ -14,4 +16,4 @@ suite.add(`${TEN_THOUSAND.toLocaleString()} refill & poll`, () => {
14
16
  }
15
17
  });
16
18
 
17
- export {suite};
19
+ export { suite };
@@ -1,14 +1,14 @@
1
- import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
2
- import {PriorityQueue} from '../../../../src';
1
+ import { PriorityQueue as CPriorityQueue } from 'js-sdsl';
2
+ import { PriorityQueue } from '../../../../src';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
- const {TEN_THOUSAND} = magnitude;
8
+ const { TEN_THOUSAND } = magnitude;
9
9
 
10
10
  suite.add(`${TEN_THOUSAND.toLocaleString()} add & pop`, () => {
11
- const pq = new PriorityQueue<number>({comparator: (a, b) => b - a});
11
+ const pq = new PriorityQueue<number>({ comparator: (a, b) => b - a });
12
12
 
13
13
  for (let i = 0; i < TEN_THOUSAND; i++) {
14
14
  pq.add(i);
@@ -32,4 +32,4 @@ if (isCompetitor) {
32
32
  });
33
33
  }
34
34
 
35
- export {suite};
35
+ export { suite };
@@ -1,11 +1,11 @@
1
- import {Deque} from '../../../../src';
2
- import {Deque as CDeque} from 'js-sdsl';
1
+ import { Deque } from '../../../../src';
2
+ import { Deque as CDeque } from 'js-sdsl';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  export const suite = new Benchmark.Suite();
8
- const {LINEAR} = magnitude;
8
+ const { LINEAR } = magnitude;
9
9
 
10
10
  suite.add(`${LINEAR.toLocaleString()} push`, () => {
11
11
  const deque = new Deque<number>();
@@ -1,11 +1,11 @@
1
- import {Queue} from '../../../../src';
2
- import {Queue as CQueue} from 'js-sdsl';
1
+ import { Queue } from '../../../../src';
2
+ import { Queue as CQueue } from 'js-sdsl';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
- const {LINEAR} = magnitude;
8
+ const { LINEAR } = magnitude;
9
9
 
10
10
  suite.add(`${LINEAR.toLocaleString()} push`, () => {
11
11
  const queue = new Queue<number>();
@@ -32,4 +32,4 @@ suite.add(`${LINEAR.toLocaleString()} push & shift`, () => {
32
32
  }
33
33
  });
34
34
 
35
- export {suite};
35
+ export { suite };
@@ -1,11 +1,11 @@
1
- import {Stack} from '../../../../src';
2
- import {Stack as CStack} from 'js-sdsl';
1
+ import { Stack } from '../../../../src';
2
+ import { Stack as CStack } from 'js-sdsl';
3
3
  import * as Benchmark from 'benchmark';
4
- import {magnitude} from '../../../utils';
5
- import {isCompetitor} from '../../../config';
4
+ import { magnitude } from '../../../utils';
5
+ import { isCompetitor } from '../../../config';
6
6
 
7
7
  const suite = new Benchmark.Suite();
8
- const {LINEAR} = magnitude;
8
+ const { LINEAR } = magnitude;
9
9
 
10
10
  suite.add(`${LINEAR.toLocaleString()} push`, () => {
11
11
  const stack = new Stack<number>();
@@ -46,4 +46,4 @@ if (isCompetitor) {
46
46
  });
47
47
  }
48
48
 
49
- export {suite};
49
+ export { suite };
@@ -1,9 +1,9 @@
1
- import {Trie} from '../../../../src';
1
+ import { Trie } from '../../../../src';
2
2
  import * as Benchmark from 'benchmark';
3
- import {getRandomWords, magnitude} from '../../../utils';
3
+ import { getRandomWords, magnitude } from '../../../utils';
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
- const {HUNDRED_THOUSAND} = magnitude;
6
+ const { HUNDRED_THOUSAND } = magnitude;
7
7
  const trie = new Trie();
8
8
  const randomWords = getRandomWords(HUNDRED_THOUSAND, false);
9
9
 
@@ -19,4 +19,4 @@ suite
19
19
  }
20
20
  });
21
21
 
22
- export {suite};
22
+ export { suite };
@@ -2,8 +2,8 @@ import * as Benchmark from 'benchmark';
2
2
  import * as path from 'path';
3
3
  import * as fs from 'fs';
4
4
  import * as fastGlob from 'fast-glob';
5
- import {Color, numberFix, render} from '../utils';
6
- import {PerformanceTest} from './types';
5
+ import { Color, numberFix, render } from '../utils';
6
+ import { PerformanceTest } from './types';
7
7
 
8
8
  const parentDirectory = path.resolve(__dirname, '../..');
9
9
  const reportDistPath = path.join(parentDirectory, 'benchmark');
@@ -11,22 +11,22 @@ const reportDistPath = path.join(parentDirectory, 'benchmark');
11
11
  const testDir = path.join(__dirname, 'data-structures');
12
12
  const testFiles = fastGlob.sync(path.join(testDir, '**', '*.test.ts'));
13
13
 
14
- const report: {[key: string]: any} = {};
14
+ const report: { [key: string]: any } = {};
15
15
 
16
16
  let completedCount = 0;
17
17
 
18
18
  const performanceTests: PerformanceTest[] = [];
19
- const {GREEN, BOLD, END, YELLOW, GRAY, CYAN, BG_YELLOW} = Color;
19
+ const { GREEN, BOLD, END, YELLOW, GRAY, CYAN, BG_YELLOW } = Color;
20
20
 
21
21
  testFiles.forEach((file: string) => {
22
22
  const testName = path.basename(file, '.test.ts');
23
23
  const testFunction = require(file);
24
- const {suite} = testFunction;
25
- if (suite) performanceTests.push({testName, suite, file});
24
+ const { suite } = testFunction;
25
+ if (suite) performanceTests.push({ testName, suite, file });
26
26
  });
27
27
 
28
28
  const composeReport = () => {
29
- if (!fs.existsSync(reportDistPath)) fs.mkdirSync(reportDistPath, {recursive: true});
29
+ if (!fs.existsSync(reportDistPath)) fs.mkdirSync(reportDistPath, { recursive: true });
30
30
 
31
31
  const filePath = path.join(reportDistPath, 'report.json');
32
32
  const htmlFilePath = path.join(reportDistPath, 'report.html');
@@ -85,9 +85,9 @@ const composeReport = () => {
85
85
  {
86
86
  '<>': 'tr',
87
87
  html: [
88
- {'<>': 'td', html: '${name}'},
89
- {'<>': 'td', html: '${periodMS}'},
90
- {'<>': 'td', html: '${mean}'}
88
+ { '<>': 'td', html: '${name}' },
89
+ { '<>': 'td', html: '${periodMS}' },
90
+ { '<>': 'td', html: '${mean}' }
91
91
  ]
92
92
  }
93
93
  ]
@@ -142,7 +142,7 @@ function replaceMarkdownContent(startMarker: string, endMarker: string, newText:
142
142
  }
143
143
 
144
144
  performanceTests.forEach(item => {
145
- const {suite, testName, file} = item;
145
+ const { suite, testName, file } = item;
146
146
  const relativeFilePath = path.relative(__dirname, file);
147
147
  const directory = path.dirname(relativeFilePath);
148
148
  const fileName = path.basename(relativeFilePath);
@@ -173,13 +173,15 @@ performanceTests.forEach(item => {
173
173
  console.log(
174
174
  // `Files: ${GREEN}${testFileCount}${END} `,
175
175
  // `Suites: ${GREEN}${performanceTests.length}${END} `,
176
- `Suites Progress: ${isDone ? GREEN : YELLOW}${completedCount}${END}/${isDone ? GREEN : YELLOW}${performanceTests.length}${END}`,
176
+ `Suites Progress: ${isDone ? GREEN : YELLOW}${completedCount}${END}/${isDone ? GREEN : YELLOW}${
177
+ performanceTests.length
178
+ }${END}`,
177
179
  `Time: ${isTimeWarn ? YELLOW : GREEN}${runTime}s${END}`
178
180
  );
179
181
  if (isDone) {
180
182
  composeReport();
181
183
  }
182
184
  })
183
- .run({async: false});
185
+ .run({ async: false });
184
186
  }
185
187
  });
@@ -1,3 +1,3 @@
1
1
  import * as Benchmark from 'benchmark';
2
2
 
3
- export type PerformanceTest = {testName: string; suite: Benchmark.Suite; file: string};
3
+ export type PerformanceTest = { testName: string; suite: Benchmark.Suite; file: string };
@@ -1 +1 @@
1
- export type Json2htmlOptions = {plainHtml?: boolean} & Partial<{[key: string]: any}>;
1
+ export type Json2htmlOptions = { plainHtml?: boolean } & Partial<{ [key: string]: any }>;
@@ -1,4 +1,4 @@
1
- import {AVLTree, AVLTreeNode, CP, IterationType} from '../../../../src';
1
+ import { AVLTree, AVLTreeNode, CP, IterationType } from '../../../../src';
2
2
 
3
3
  describe('AVL Tree Test', () => {
4
4
  it('should perform various operations on a AVL Tree', () => {
@@ -112,7 +112,7 @@ describe('AVL Tree Test', () => {
112
112
  describe('AVL Tree Test recursively', () => {
113
113
  it('should perform various operations on a AVL Tree', () => {
114
114
  const arr = [11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5];
115
- const tree = new AVLTree<number>({iterationType: IterationType.RECURSIVE});
115
+ const tree = new AVLTree<number>({ iterationType: IterationType.RECURSIVE });
116
116
 
117
117
  for (const i of arr) tree.add(i, i);
118
118
 
@@ -219,7 +219,7 @@ describe('AVL Tree Test recursively', () => {
219
219
  });
220
220
 
221
221
  describe('AVLTree APIs test', () => {
222
- const avl = new AVLTree<{id: number; text: string}>();
222
+ const avl = new AVLTree<{ id: number; text: string }>();
223
223
  beforeEach(() => {
224
224
  avl.clear();
225
225
  });
@@ -228,9 +228,9 @@ describe('AVLTree APIs test', () => {
228
228
  avl.add(1);
229
229
  const node2 = new AVLTreeNode(2);
230
230
  avl.add(node2);
231
- const node3 = new AVLTreeNode(3, {id: 3, text: 'text3'});
231
+ const node3 = new AVLTreeNode(3, { id: 3, text: 'text3' });
232
232
  avl.add(node3);
233
- avl.add(node3, {id: 3, text: 'text33'});
233
+ avl.add(node3, { id: 3, text: 'text33' });
234
234
 
235
235
  const bfsRes = avl.bfs(node => node.key);
236
236
  expect(bfsRes[0]).toBe(2);
@@ -268,7 +268,7 @@ describe('AVLTree', () => {
268
268
  });
269
269
 
270
270
  describe('BinaryTree APIs test', () => {
271
- const avl = new AVLTree<{id: number; text: string}>();
271
+ const avl = new AVLTree<{ id: number; text: string }>();
272
272
  beforeEach(() => {
273
273
  avl.clear();
274
274
  });
@@ -277,9 +277,9 @@ describe('AVLTree', () => {
277
277
  avl.add(1);
278
278
  const node2 = new AVLTreeNode(2);
279
279
  avl.add(node2);
280
- const node3 = new AVLTreeNode(3, {id: 3, text: 'text3'});
280
+ const node3 = new AVLTreeNode(3, { id: 3, text: 'text3' });
281
281
  avl.add(node3);
282
- avl.add(node3, {id: 3, text: 'text33'});
282
+ avl.add(node3, { id: 3, text: 'text33' });
283
283
 
284
284
  const bfsRes = avl.bfs(node => node);
285
285
  expect(bfsRes[0]?.key).toBe(2);
@@ -1,4 +1,4 @@
1
- import {BinaryIndexedTree} from '../../../../src';
1
+ import { BinaryIndexedTree } from '../../../../src';
2
2
  // import {isDebugTest} from '../../../config';
3
3
 
4
4
  // const isDebug = isDebugTest;
@@ -8,13 +8,13 @@ describe('BinaryIndexedTree simple', () => {
8
8
 
9
9
  beforeEach(() => {
10
10
  //Create a new BinaryIndexedTree instance before each test case
11
- bit = new BinaryIndexedTree({frequency: 0, max: 10}); // Modify the value of max as needed
11
+ bit = new BinaryIndexedTree({ frequency: 0, max: 10 }); // Modify the value of max as needed
12
12
  });
13
13
 
14
14
  it('should initialize correctly', () => {
15
15
  expect(bit.freq).toBe(0);
16
16
  expect(bit.max).toBe(10);
17
- expect(bit.freqMap).toEqual({0: 0}); // Modify the initialized record value according to the actual situation
17
+ expect(bit.freqMap).toEqual({ 0: 0 }); // Modify the initialized record value according to the actual situation
18
18
  // More initialization checks can be added
19
19
  });
20
20
 
@@ -54,7 +54,7 @@ describe('BinaryIndexedTree', () => {
54
54
  let bit: BinaryIndexedTree;
55
55
 
56
56
  beforeEach(function () {
57
- bit = new BinaryIndexedTree({frequency, max});
57
+ bit = new BinaryIndexedTree({ frequency, max });
58
58
  });
59
59
  it('should validate the index', function () {
60
60
  expect(() => bit.readSingle(-1)).toThrow('Index out of range');
@@ -73,7 +73,7 @@ describe('BinaryIndexedTree', () => {
73
73
  it('should frequency and max', function () {
74
74
  const frequency = 200;
75
75
  const max = 1000;
76
- const bit = new BinaryIndexedTree({frequency, max});
76
+ const bit = new BinaryIndexedTree({ frequency, max });
77
77
 
78
78
  expect(bit.freq).toBe(frequency);
79
79
  expect(bit.max).toBe(max);
@@ -123,7 +123,7 @@ describe('designated values', function () {
123
123
  let bit: BinaryIndexedTree;
124
124
 
125
125
  beforeEach(function () {
126
- bit = new BinaryIndexedTree({max: array.length});
126
+ bit = new BinaryIndexedTree({ max: array.length });
127
127
  array.forEach((value, i) => bit.writeSingle(i, value));
128
128
  });
129
129
 
@@ -182,7 +182,7 @@ describe('descending sequence', function () {
182
182
  let bit: BinaryIndexedTree;
183
183
 
184
184
  beforeEach(function () {
185
- bit = new BinaryIndexedTree({max: array.length});
185
+ bit = new BinaryIndexedTree({ max: array.length });
186
186
  array.forEach((value, i) => bit.writeSingle(i, value));
187
187
  });
188
188
 
@@ -219,7 +219,7 @@ describe('descending sequence', function () {
219
219
 
220
220
  describe('BinaryIndexedTree additional tests', () => {
221
221
  it('should handle read method correctly', () => {
222
- const bit = new BinaryIndexedTree({max: 10});
222
+ const bit = new BinaryIndexedTree({ max: 10 });
223
223
  bit.writeSingle(2, 10);
224
224
  bit.writeSingle(5, 20);
225
225
  bit.writeSingle(8, 30);
@@ -227,7 +227,7 @@ describe('BinaryIndexedTree additional tests', () => {
227
227
  });
228
228
 
229
229
  it('should handle consecutive operations', () => {
230
- const bit = new BinaryIndexedTree({max: 10});
230
+ const bit = new BinaryIndexedTree({ max: 10 });
231
231
  bit.writeSingle(2, 10);
232
232
  bit.update(2, 5);
233
233
  expect(bit.readSingle(2)).toBe(15);
@@ -237,7 +237,7 @@ describe('BinaryIndexedTree additional tests', () => {
237
237
  });
238
238
 
239
239
  it('should handle frequent increment updates', () => {
240
- const bit = new BinaryIndexedTree({max: 10});
240
+ const bit = new BinaryIndexedTree({ max: 10 });
241
241
  for (let i = 0; i < 10; i++) {
242
242
  bit.update(2, 5);
243
243
  }
@@ -245,7 +245,7 @@ describe('BinaryIndexedTree additional tests', () => {
245
245
  });
246
246
 
247
247
  it('should handle edge cases', () => {
248
- const bit = new BinaryIndexedTree({max: 10});
248
+ const bit = new BinaryIndexedTree({ max: 10 });
249
249
  bit.writeSingle(9, 100);
250
250
  expect(bit.readSingle(9)).toBe(100);
251
251
  expect(bit.lowerBound(200)).toBe(10);
@@ -291,7 +291,7 @@ describe('', () => {
291
291
 
292
292
  constructor(nums: number[]) {
293
293
  this._nums = nums;
294
- this._tree = new BinaryIndexedTree({max: nums.length + 1});
294
+ this._tree = new BinaryIndexedTree({ max: nums.length + 1 });
295
295
  for (let i = 0; i < nums.length; i++) {
296
296
  this._tree.update(i + 1, nums[i]);
297
297
  }