data-structure-typed 1.33.7 → 1.33.9

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 (149) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +25 -14
  3. package/package.json +22 -22
  4. package/.prettierrc.js +0 -16
  5. package/coverage/coverage-final.json +0 -68
  6. package/coverage/coverage-summary.json +0 -69
  7. package/docs/.nojekyll +0 -1
  8. package/docs/index.html +0 -875
  9. package/docs/modules.html +0 -336
  10. package/jest.config.js +0 -8
  11. package/src/data-structures/binary-tree/aa-tree.ts +0 -1
  12. package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -1608
  13. package/src/data-structures/binary-tree/avl-tree.ts +0 -307
  14. package/src/data-structures/binary-tree/b-tree.ts +0 -1
  15. package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -76
  16. package/src/data-structures/binary-tree/binary-tree.ts +0 -47
  17. package/src/data-structures/binary-tree/bst.ts +0 -537
  18. package/src/data-structures/binary-tree/index.ts +0 -12
  19. package/src/data-structures/binary-tree/rb-tree.ts +0 -366
  20. package/src/data-structures/binary-tree/segment-tree.ts +0 -260
  21. package/src/data-structures/binary-tree/splay-tree.ts +0 -1
  22. package/src/data-structures/binary-tree/tree-multiset.ts +0 -700
  23. package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
  24. package/src/data-structures/graph/abstract-graph.ts +0 -1040
  25. package/src/data-structures/graph/directed-graph.ts +0 -470
  26. package/src/data-structures/graph/index.ts +0 -4
  27. package/src/data-structures/graph/map-graph.ts +0 -129
  28. package/src/data-structures/graph/undirected-graph.ts +0 -274
  29. package/src/data-structures/hash/coordinate-map.ts +0 -67
  30. package/src/data-structures/hash/coordinate-set.ts +0 -56
  31. package/src/data-structures/hash/hash-map.ts +0 -203
  32. package/src/data-structures/hash/hash-table.ts +0 -277
  33. package/src/data-structures/hash/index.ts +0 -7
  34. package/src/data-structures/hash/pair.ts +0 -1
  35. package/src/data-structures/hash/tree-map.ts +0 -1
  36. package/src/data-structures/hash/tree-set.ts +0 -1
  37. package/src/data-structures/heap/heap.ts +0 -212
  38. package/src/data-structures/heap/index.ts +0 -3
  39. package/src/data-structures/heap/max-heap.ts +0 -31
  40. package/src/data-structures/heap/min-heap.ts +0 -32
  41. package/src/data-structures/index.ts +0 -11
  42. package/src/data-structures/linked-list/doubly-linked-list.ts +0 -636
  43. package/src/data-structures/linked-list/index.ts +0 -3
  44. package/src/data-structures/linked-list/singly-linked-list.ts +0 -501
  45. package/src/data-structures/linked-list/skip-linked-list.ts +0 -166
  46. package/src/data-structures/matrix/index.ts +0 -4
  47. package/src/data-structures/matrix/matrix.ts +0 -27
  48. package/src/data-structures/matrix/matrix2d.ts +0 -213
  49. package/src/data-structures/matrix/navigator.ts +0 -121
  50. package/src/data-structures/matrix/vector2d.ts +0 -316
  51. package/src/data-structures/priority-queue/index.ts +0 -3
  52. package/src/data-structures/priority-queue/max-priority-queue.ts +0 -56
  53. package/src/data-structures/priority-queue/min-priority-queue.ts +0 -57
  54. package/src/data-structures/priority-queue/priority-queue.ts +0 -359
  55. package/src/data-structures/queue/deque.ts +0 -297
  56. package/src/data-structures/queue/index.ts +0 -2
  57. package/src/data-structures/queue/queue.ts +0 -191
  58. package/src/data-structures/stack/index.ts +0 -1
  59. package/src/data-structures/stack/stack.ts +0 -98
  60. package/src/data-structures/tree/index.ts +0 -1
  61. package/src/data-structures/tree/tree.ts +0 -69
  62. package/src/data-structures/trie/index.ts +0 -1
  63. package/src/data-structures/trie/trie.ts +0 -225
  64. package/src/index.ts +0 -4
  65. package/src/interfaces/abstract-binary-tree.ts +0 -189
  66. package/src/interfaces/abstract-graph.ts +0 -31
  67. package/src/interfaces/avl-tree.ts +0 -25
  68. package/src/interfaces/binary-tree.ts +0 -6
  69. package/src/interfaces/bst.ts +0 -31
  70. package/src/interfaces/directed-graph.ts +0 -20
  71. package/src/interfaces/doubly-linked-list.ts +0 -1
  72. package/src/interfaces/heap.ts +0 -1
  73. package/src/interfaces/index.ts +0 -15
  74. package/src/interfaces/navigator.ts +0 -1
  75. package/src/interfaces/priority-queue.ts +0 -1
  76. package/src/interfaces/rb-tree.ts +0 -9
  77. package/src/interfaces/segment-tree.ts +0 -1
  78. package/src/interfaces/singly-linked-list.ts +0 -1
  79. package/src/interfaces/tree-multiset.ts +0 -7
  80. package/src/interfaces/undirected-graph.ts +0 -6
  81. package/src/types/data-structures/abstract-binary-tree.ts +0 -50
  82. package/src/types/data-structures/abstract-graph.ts +0 -11
  83. package/src/types/data-structures/avl-tree.ts +0 -5
  84. package/src/types/data-structures/binary-tree.ts +0 -5
  85. package/src/types/data-structures/bst.ts +0 -13
  86. package/src/types/data-structures/directed-graph.ts +0 -8
  87. package/src/types/data-structures/doubly-linked-list.ts +0 -1
  88. package/src/types/data-structures/hash.ts +0 -1
  89. package/src/types/data-structures/heap.ts +0 -5
  90. package/src/types/data-structures/index.ts +0 -16
  91. package/src/types/data-structures/map-graph.ts +0 -1
  92. package/src/types/data-structures/navigator.ts +0 -13
  93. package/src/types/data-structures/priority-queue.ts +0 -9
  94. package/src/types/data-structures/rb-tree.ts +0 -8
  95. package/src/types/data-structures/segment-tree.ts +0 -1
  96. package/src/types/data-structures/singly-linked-list.ts +0 -1
  97. package/src/types/data-structures/tree-multiset.ts +0 -6
  98. package/src/types/helpers.ts +0 -1
  99. package/src/types/index.ts +0 -3
  100. package/src/types/utils/index.ts +0 -2
  101. package/src/types/utils/utils.ts +0 -6
  102. package/src/types/utils/validate-type.ts +0 -35
  103. package/src/utils/index.ts +0 -1
  104. package/src/utils/utils.ts +0 -79
  105. package/test/integration/avl-tree.test.ts +0 -108
  106. package/test/integration/bst.test.ts +0 -380
  107. package/test/integration/heap.test.js +0 -16
  108. package/test/integration/index.html +0 -44
  109. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -108
  110. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +0 -142
  111. package/test/unit/data-structures/binary-tree/bst.test.ts +0 -380
  112. package/test/unit/data-structures/binary-tree/overall.test.ts +0 -65
  113. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +0 -43
  114. package/test/unit/data-structures/binary-tree/segment-tree.test.ts +0 -50
  115. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +0 -461
  116. package/test/unit/data-structures/graph/abstract-graph.test.ts +0 -5
  117. package/test/unit/data-structures/graph/directed-graph.test.ts +0 -519
  118. package/test/unit/data-structures/graph/index.ts +0 -2
  119. package/test/unit/data-structures/graph/map-graph.test.ts +0 -45
  120. package/test/unit/data-structures/graph/overall.test.ts +0 -49
  121. package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -59
  122. package/test/unit/data-structures/hash/coordinate-map.test.ts +0 -54
  123. package/test/unit/data-structures/hash/coordinate-set.test.ts +0 -41
  124. package/test/unit/data-structures/hash/hash-map.test.ts +0 -104
  125. package/test/unit/data-structures/hash/hash-table.test.ts +0 -184
  126. package/test/unit/data-structures/heap/heap.test.ts +0 -55
  127. package/test/unit/data-structures/heap/max-heap.test.ts +0 -44
  128. package/test/unit/data-structures/heap/min-heap.test.ts +0 -82
  129. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +0 -364
  130. package/test/unit/data-structures/linked-list/index.ts +0 -4
  131. package/test/unit/data-structures/linked-list/linked-list.test.ts +0 -35
  132. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +0 -451
  133. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +0 -13
  134. package/test/unit/data-structures/linked-list/skip-list.test.ts +0 -55
  135. package/test/unit/data-structures/matrix/matrix.test.ts +0 -54
  136. package/test/unit/data-structures/matrix/matrix2d.test.ts +0 -138
  137. package/test/unit/data-structures/matrix/navigator.test.ts +0 -79
  138. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +0 -106
  139. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +0 -105
  140. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -27
  141. package/test/unit/data-structures/queue/deque.test.ts +0 -130
  142. package/test/unit/data-structures/queue/queue.test.ts +0 -199
  143. package/test/unit/data-structures/stack/stack.test.ts +0 -67
  144. package/test/unit/data-structures/tree/tree.test.ts +0 -39
  145. package/test/unit/data-structures/trie/trie.test.ts +0 -95
  146. package/test/utils/index.ts +0 -2
  147. package/test/utils/magnitude.ts +0 -21
  148. package/test/utils/number.ts +0 -3
  149. package/tsconfig.json +0 -29
@@ -1,67 +0,0 @@
1
- import {Stack} from '../../../../src';
2
-
3
- describe('Stack', () => {
4
- let stack: Stack<number>;
5
-
6
- beforeEach(() => {
7
- stack = new Stack<number>();
8
- });
9
-
10
- it('should be empty when initialized', () => {
11
- expect(stack.isEmpty()).toBe(true);
12
- });
13
-
14
- it('should push elements onto the stack', () => {
15
- stack.push(1);
16
- stack.push(2);
17
- stack.push(3);
18
- expect(stack.size()).toBe(3);
19
- });
20
-
21
- it('should peek at the top element without removing it', () => {
22
- stack.push(1);
23
- stack.push(2);
24
- stack.push(3);
25
- expect(stack.peek()).toBe(3);
26
- expect(stack.size()).toBe(3);
27
- });
28
-
29
- it('should pop elements from the stack', () => {
30
- stack.push(1);
31
- stack.push(2);
32
- stack.push(3);
33
- const poppedElement = stack.pop();
34
- expect(poppedElement).toBe(3);
35
- expect(stack.size()).toBe(2);
36
- });
37
-
38
- it('should return null when popping from an empty stack', () => {
39
- const poppedElement = stack.pop();
40
- expect(poppedElement).toBeNull();
41
- });
42
-
43
- it('should convert the stack to an array', () => {
44
- stack.push(1);
45
- stack.push(2);
46
- stack.push(3);
47
- const stackArray = stack.toArray();
48
- expect(stackArray).toEqual([1, 2, 3]);
49
- });
50
-
51
- it('should clear all elements from the stack', () => {
52
- stack.push(1);
53
- stack.push(2);
54
- stack.push(3);
55
- stack.clear();
56
- expect(stack.size()).toBe(0);
57
- expect(stack.isEmpty()).toBe(true);
58
- });
59
-
60
- it('should clone the stack', () => {
61
- stack.push(1);
62
- stack.push(2);
63
- const clonedStack = stack.clone();
64
- expect(clonedStack.size()).toBe(2);
65
- expect(clonedStack.pop()).toBe(2);
66
- });
67
- });
@@ -1,39 +0,0 @@
1
- import {TreeNode} from '../../../../src';
2
-
3
- describe('TreeNode', () => {
4
- it('should create a TreeNode with the given id and value', () => {
5
- const node = new TreeNode<string>('1', 'Node 1');
6
- expect(node.id).toBe('1');
7
- expect(node.value).toBe('Node 1');
8
- expect(node.children).toEqual([]);
9
- });
10
-
11
- it('should add children to the TreeNode', () => {
12
- const parentNode = new TreeNode<string>('1', 'Parent Node');
13
- const child1 = new TreeNode<string>('2', 'Child 1');
14
- const child2 = new TreeNode<string>('3', 'Child 2');
15
-
16
- parentNode.addChildren([child1, child2]);
17
-
18
- expect(parentNode.children).toEqual([child1, child2]);
19
- });
20
-
21
- it('should calculate the height of the tree correctly', () => {
22
- const rootNode = new TreeNode<string>('1', 'Root Node');
23
- const child1 = new TreeNode<string>('2', 'Child 1');
24
- const child2 = new TreeNode<string>('3', 'Child 2');
25
- const grandchild1 = new TreeNode<string>('4', 'Grandchild 1');
26
- const grandchild2 = new TreeNode<string>('5', 'Grandchild 2');
27
-
28
- rootNode.addChildren([child1, child2]);
29
- child1.addChildren([grandchild1]);
30
- child2.addChildren([grandchild2]);
31
-
32
- expect(rootNode.getHeight()).toBe(3); // Height of the tree should be 3
33
- });
34
-
35
- it('should handle nodes without children when calculating height', () => {
36
- const rootNode = new TreeNode<string>('1', 'Root Node');
37
- expect(rootNode.getHeight()).toBe(1); // Height of a single node should be 1
38
- });
39
- });
@@ -1,95 +0,0 @@
1
- import {Trie, TrieNode} from '../../../../src';
2
-
3
- describe('TrieNode', () => {
4
- it('should create a TrieNode with the given value', () => {
5
- const node = new TrieNode('a');
6
- expect(node.val).toBe('a');
7
- expect(node.isEnd).toBe(false);
8
- expect(node.children.size).toBe(0);
9
- });
10
-
11
- it('should add a child to TrieNode', () => {
12
- const parentNode = new TrieNode('a');
13
- const childNode = new TrieNode('b');
14
- parentNode.children.set('b', childNode);
15
-
16
- expect(parentNode.children.size).toBe(1);
17
- expect(parentNode.children.get('b')).toBe(childNode);
18
- });
19
-
20
- it('should set isEnd property correctly', () => {
21
- const node = new TrieNode('a');
22
- node.isEnd = true;
23
- expect(node.isEnd).toBe(true);
24
- });
25
- });
26
-
27
- describe('Trie', () => {
28
- it('should create an empty Trie', () => {
29
- const trie = new Trie();
30
- expect(trie.root.val).toBe('');
31
- expect(trie.root.children.size).toBe(0);
32
- });
33
-
34
- it('should add words to Trie', () => {
35
- const trie = new Trie();
36
- trie.add('apple');
37
- trie.add('app');
38
- expect(trie.has('apple')).toBe(true);
39
- expect(trie.has('app')).toBe(true);
40
- expect(trie.has('banana')).toBe(false);
41
- });
42
-
43
- it('should check if a string is an absolute prefix', () => {
44
- const trie = new Trie();
45
- trie.add('apple');
46
- trie.add('app');
47
- expect(trie.isAbsPrefix('appl')).toBe(true);
48
- expect(trie.isAbsPrefix('apples')).toBe(false);
49
- });
50
-
51
- it('should check if a string is a prefix', () => {
52
- const trie = new Trie();
53
- trie.add('apple');
54
- trie.add('app');
55
- expect(trie.isPrefix('app')).toBe(true);
56
- expect(trie.isPrefix('banana')).toBe(false);
57
- });
58
-
59
- it('should check if a string is a common prefix', () => {
60
- const trie = new Trie();
61
- trie.add('apple');
62
- trie.add('app');
63
- expect(trie.isCommonPrefix('ap')).toBe(true);
64
- expect(trie.isCommonPrefix('app')).toBe(true);
65
- expect(trie.isCommonPrefix('b')).toBe(false);
66
- });
67
-
68
- it('should get the longest common prefix', () => {
69
- const trie = new Trie();
70
- trie.add('apple');
71
- trie.add('app');
72
- expect(trie.getLongestCommonPrefix()).toBe('app');
73
- });
74
-
75
- it('should get all words with a given prefix', () => {
76
- const trie = new Trie();
77
- trie.add('apple');
78
- trie.add('app');
79
- trie.add('application');
80
- const words = trie.getAll('app');
81
- expect(words).toEqual(['apple', 'application', 'app']);
82
- });
83
-
84
- it('should remove words from Trie', () => {
85
- const trie = new Trie();
86
- trie.add('apple');
87
- trie.add('app');
88
- expect(trie.has('apple')).toBe(true);
89
- trie.remove('apple');
90
- expect(trie.has('apple')).toBe(false);
91
- expect(trie.has('app')).toBe(true);
92
- trie.remove('app');
93
- expect(trie.has('app')).toBe(false);
94
- });
95
- });
@@ -1,2 +0,0 @@
1
- export * from './number';
2
- export * from './magnitude';
@@ -1,21 +0,0 @@
1
- const orderReducedBy = 2; // reduction of magnitude's order compared to the baseline magnitude
2
-
3
- export const magnitude = {
4
- CONSTANT: Math.floor(Number.MAX_SAFE_INTEGER / Math.pow(10, orderReducedBy)),
5
- LOG_N: Math.pow(10, 9 - orderReducedBy),
6
- LINEAR: Math.pow(10, 6 - orderReducedBy),
7
- N_LOG_N: Math.pow(10, 5 - orderReducedBy),
8
- SQUARED: Math.pow(10, 4 - orderReducedBy),
9
- CUBED: Math.pow(10, 3 - orderReducedBy),
10
- FACTORIAL: 20 - orderReducedBy
11
- };
12
-
13
- export const bigO = {
14
- CONSTANT: magnitude.CONSTANT / 100000,
15
- LOG_N: Math.log2(magnitude.LOG_N) / 1000,
16
- LINEAR: magnitude.LINEAR / 1000,
17
- N_LOG_N: (magnitude.N_LOG_N * Math.log2(magnitude.LOG_N)) / 1000,
18
- SQUARED: Math.pow(magnitude.SQUARED, 2) / 1000,
19
- CUBED: Math.pow(magnitude.SQUARED, 3) / 1000,
20
- FACTORIAL: 10000
21
- };
@@ -1,3 +0,0 @@
1
- export function getRandomInt(min: number, max: number) {
2
- return Math.floor(Math.random() * (max - min + 1)) + min;
3
- }
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./lib",
4
- "declaration": true,
5
- "module": "ES6",
6
- "target": "ES6",
7
- "lib": [
8
- "ESNext"
9
- ],
10
- "strict": true,
11
- "esModuleInterop": true,
12
- "moduleResolution": "node",
13
- "skipLibCheck": true,
14
- "downlevelIteration": true,
15
- "experimentalDecorators": true,
16
- "typeRoots": [
17
- "node_modules/@types"
18
- ]
19
- },
20
-
21
- "include": ["src/**/*.ts", "src/**/*.js"],
22
- "exclude": [
23
- "node_modules",
24
- "lib",
25
- "dist",
26
- "umd"
27
- ]
28
- }
29
-