data-structure-typed 1.44.0 → 1.45.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 (57) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +15 -15
  3. package/benchmark/report.html +30 -30
  4. package/benchmark/report.json +144 -198
  5. package/dist/cjs/data-structures/hash/hash-map.d.ts +230 -37
  6. package/dist/cjs/data-structures/hash/hash-map.js +430 -118
  7. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  8. package/dist/cjs/types/data-structures/graph/directed-graph.d.ts +0 -5
  9. package/dist/cjs/types/data-structures/graph/directed-graph.js +0 -7
  10. package/dist/cjs/types/data-structures/graph/directed-graph.js.map +1 -1
  11. package/dist/cjs/types/data-structures/hash/hash-map.d.ts +15 -1
  12. package/dist/cjs/types/data-structures/hash/index.d.ts +6 -0
  13. package/dist/cjs/types/data-structures/hash/index.js +20 -0
  14. package/dist/cjs/types/data-structures/hash/index.js.map +1 -1
  15. package/dist/cjs/utils/utils.d.ts +3 -0
  16. package/dist/cjs/utils/utils.js +15 -1
  17. package/dist/cjs/utils/utils.js.map +1 -1
  18. package/dist/mjs/data-structures/hash/hash-map.d.ts +230 -37
  19. package/dist/mjs/data-structures/hash/hash-map.js +435 -123
  20. package/dist/mjs/types/data-structures/graph/directed-graph.d.ts +0 -5
  21. package/dist/mjs/types/data-structures/graph/directed-graph.js +1 -6
  22. package/dist/mjs/types/data-structures/hash/hash-map.d.ts +15 -1
  23. package/dist/mjs/types/data-structures/hash/index.d.ts +6 -0
  24. package/dist/mjs/types/data-structures/hash/index.js +6 -1
  25. package/dist/mjs/utils/utils.d.ts +3 -0
  26. package/dist/mjs/utils/utils.js +11 -0
  27. package/dist/umd/data-structure-typed.js +532 -217
  28. package/dist/umd/data-structure-typed.min.js +1 -1
  29. package/dist/umd/data-structure-typed.min.js.map +1 -1
  30. package/package.json +9 -7
  31. package/src/data-structures/hash/hash-map.ts +432 -125
  32. package/src/types/data-structures/graph/directed-graph.ts +0 -6
  33. package/src/types/data-structures/hash/hash-map.ts +17 -1
  34. package/src/types/data-structures/hash/index.ts +7 -0
  35. package/src/utils/utils.ts +13 -0
  36. package/test/integration/all-in-one.ts +110 -0
  37. package/test/performance/reportor.ts +2 -2
  38. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
  39. package/test/unit/data-structures/binary-tree/bst.test.ts +6 -6
  40. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  41. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +14 -14
  42. package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +2 -2
  43. package/test/unit/data-structures/graph/abstract-graph.test.ts +2 -1
  44. package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
  45. package/test/unit/data-structures/hash/hash-map.test.ts +151 -20
  46. package/test/unit/data-structures/heap/heap.test.ts +8 -8
  47. package/test/unit/data-structures/heap/max-heap.test.ts +4 -4
  48. package/test/unit/data-structures/heap/min-heap.test.ts +4 -4
  49. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
  50. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +2 -2
  51. package/test/unit/data-structures/linked-list/skip-list.test.ts +4 -4
  52. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +2 -2
  53. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +8 -2
  54. package/test/unit/data-structures/queue/deque.test.ts +25 -25
  55. package/test/unit/data-structures/trie/trie.test.ts +9 -9
  56. package/test/utils/array.ts +1 -1
  57. package/test/utils/number.ts +1 -1
@@ -22,7 +22,7 @@ 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});
25
+ const minHeap = new MinHeap<{ a: string; key: number }>({comparator: (a, b) => a.key - b.key});
26
26
  minHeap.add({key: 1, a: 'a1'});
27
27
  minHeap.add({key: 6, a: 'a6'});
28
28
  minHeap.add({key: 2, a: 'a2'});
@@ -37,7 +37,7 @@ describe('Heap Operation Test', () => {
37
37
  i++;
38
38
  }
39
39
 
40
- const maxHeap = new MaxHeap<{key: number; a: string}>({comparator: (a, b) => b.key - a.key});
40
+ const maxHeap = new MaxHeap<{ key: number; a: string }>({comparator: (a, b) => b.key - a.key});
41
41
  maxHeap.add({key: 1, a: 'a1'});
42
42
  maxHeap.add({key: 6, a: 'a6'});
43
43
  maxHeap.add({key: 5, a: 'a5'});
@@ -62,13 +62,13 @@ describe('FibonacciHeap', () => {
62
62
  heap = new FibonacciHeap<number>();
63
63
  });
64
64
 
65
- test('push & peek', () => {
65
+ it('push & peek', () => {
66
66
  heap.push(10);
67
67
  heap.push(5);
68
68
  expect(heap.peek()).toBe(5);
69
69
  });
70
70
 
71
- test('pop', () => {
71
+ it('pop', () => {
72
72
  heap.push(10);
73
73
  heap.push(5);
74
74
  heap.push(15);
@@ -77,11 +77,11 @@ describe('FibonacciHeap', () => {
77
77
  expect(heap.pop()).toBe(15);
78
78
  });
79
79
 
80
- test('pop on an empty heap', () => {
80
+ it('pop on an empty heap', () => {
81
81
  expect(heap.pop()).toBeUndefined();
82
82
  });
83
83
 
84
- test('size', () => {
84
+ it('size', () => {
85
85
  expect(heap.size).toBe(0);
86
86
  heap.push(10);
87
87
  expect(heap.size).toBe(1);
@@ -89,7 +89,7 @@ describe('FibonacciHeap', () => {
89
89
  expect(heap.size).toBe(0);
90
90
  });
91
91
 
92
- test('clear', () => {
92
+ it('clear', () => {
93
93
  heap.push(10);
94
94
  heap.push(5);
95
95
  heap.clear();
@@ -97,7 +97,7 @@ describe('FibonacciHeap', () => {
97
97
  expect(heap.peek()).toBeUndefined();
98
98
  });
99
99
 
100
- test('custom comparator', () => {
100
+ it('custom comparator', () => {
101
101
  const maxHeap = new FibonacciHeap<number>((a, b) => b - a);
102
102
  maxHeap.push(10);
103
103
  maxHeap.push(5);
@@ -8,7 +8,7 @@ describe('MaxHeap', () => {
8
8
  maxHeap = new MaxHeap({comparator: numberComparator});
9
9
  });
10
10
 
11
- test('add and poll elements in descending order', () => {
11
+ it('add and poll elements in descending order', () => {
12
12
  maxHeap.add(3);
13
13
  maxHeap.add(1);
14
14
  maxHeap.add(4);
@@ -20,7 +20,7 @@ describe('MaxHeap', () => {
20
20
  expect(maxHeap.poll()).toBe(1);
21
21
  });
22
22
 
23
- test('peek at the top element without removing it', () => {
23
+ it('peek at the top element without removing it', () => {
24
24
  maxHeap.add(3);
25
25
  maxHeap.add(1);
26
26
  maxHeap.add(4);
@@ -30,7 +30,7 @@ describe('MaxHeap', () => {
30
30
  expect(maxHeap.size).toBe(4);
31
31
  });
32
32
 
33
- test('sort elements in descending order', () => {
33
+ it('sort elements in descending order', () => {
34
34
  maxHeap.add(3);
35
35
  maxHeap.add(1);
36
36
  maxHeap.add(4);
@@ -40,7 +40,7 @@ describe('MaxHeap', () => {
40
40
  expect(sortedArray).toEqual([4, 3, 2, 1]);
41
41
  });
42
42
 
43
- test('check if the heap is empty', () => {
43
+ it('check if the heap is empty', () => {
44
44
  expect(maxHeap.isEmpty()).toBe(true);
45
45
 
46
46
  maxHeap.add(5);
@@ -8,7 +8,7 @@ describe('MinHeap', () => {
8
8
  minHeap = new MinHeap({comparator: numberComparator});
9
9
  });
10
10
 
11
- test('add and poll elements in ascending order', () => {
11
+ it('add and poll elements in ascending order', () => {
12
12
  minHeap.add(3);
13
13
  minHeap.add(1);
14
14
  minHeap.add(4);
@@ -20,7 +20,7 @@ describe('MinHeap', () => {
20
20
  expect(minHeap.poll()).toBe(4);
21
21
  });
22
22
 
23
- test('peek at the top element without removing it', () => {
23
+ it('peek at the top element without removing it', () => {
24
24
  minHeap.add(3);
25
25
  minHeap.add(1);
26
26
  minHeap.add(4);
@@ -30,7 +30,7 @@ describe('MinHeap', () => {
30
30
  expect(minHeap.size).toBe(4);
31
31
  });
32
32
 
33
- test('sort elements in ascending order', () => {
33
+ it('sort elements in ascending order', () => {
34
34
  minHeap.add(3);
35
35
  minHeap.add(1);
36
36
  minHeap.add(4);
@@ -40,7 +40,7 @@ describe('MinHeap', () => {
40
40
  expect(sortedArray).toEqual([1, 2, 3, 4]);
41
41
  });
42
42
 
43
- test('check if the heap is empty', () => {
43
+ it('check if the heap is empty', () => {
44
44
  expect(minHeap.isEmpty()).toBe(true);
45
45
 
46
46
  minHeap.add(5);
@@ -60,7 +60,7 @@ describe('DoublyLinkedList Operation Test', () => {
60
60
 
61
61
  describe('DoublyLinkedList Operation Test', () => {
62
62
  let list: DoublyLinkedList<number>;
63
- let objectList: DoublyLinkedList<{keyA: number}>;
63
+ let objectList: DoublyLinkedList<{ keyA: number }>;
64
64
 
65
65
  beforeEach(() => {
66
66
  list = new DoublyLinkedList();
@@ -11,10 +11,10 @@ describe('SinglyLinkedListNode', () => {
11
11
 
12
12
  describe('SinglyLinkedList Operation Test', () => {
13
13
  let list: SinglyLinkedList<number>;
14
- let objectList: SinglyLinkedList<{keyA: number}>;
14
+ let objectList: SinglyLinkedList<{ keyA: number }>;
15
15
  beforeEach(() => {
16
16
  list = new SinglyLinkedList<number>();
17
- objectList = new SinglyLinkedList<{keyA: number}>();
17
+ objectList = new SinglyLinkedList<{ keyA: number }>();
18
18
  });
19
19
 
20
20
  describe('push', () => {
@@ -65,21 +65,21 @@ describe('SkipList', () => {
65
65
  skipList.add(4, 'Four');
66
66
  });
67
67
 
68
- test('getFirst() should return the getFirst element', () => {
68
+ it('getFirst() should return the getFirst element', () => {
69
69
  expect(skipList.getFirst()).toBe('One');
70
70
  });
71
71
 
72
- test('getLast() should return the getLast element', () => {
72
+ it('getLast() should return the getLast element', () => {
73
73
  expect(skipList.getLast()).toBe('Four');
74
74
  });
75
75
 
76
- test('higher(key) should return the getFirst element greater than the given key', () => {
76
+ it('higher(key) should return the getFirst element greater than the given key', () => {
77
77
  expect(skipList.higher(2)).toBe('Three');
78
78
  expect(skipList.higher(3)).toBe('Four');
79
79
  expect(skipList.higher(4)).toBeUndefined();
80
80
  });
81
81
 
82
- test('lower(key) should return the getLast element less than the given key', () => {
82
+ it('lower(key) should return the getLast element less than the given key', () => {
83
83
  expect(skipList.lower(2)).toBe('One');
84
84
  expect(skipList.lower(1)).toBe(null);
85
85
  });
@@ -16,7 +16,7 @@ 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});
19
+ const priorityQueue = new MaxPriorityQueue<{ keyA: number }>({comparator: (a, b) => b.keyA - a.keyA});
20
20
  priorityQueue.refill([{keyA: 5}, {keyA: 3}, {keyA: 1}]);
21
21
  priorityQueue.add({keyA: 7});
22
22
 
@@ -63,7 +63,7 @@ describe('MaxPriorityQueue Operation Test', () => {
63
63
 
64
64
  it('should correctly heapify an object array', () => {
65
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});
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);
@@ -13,7 +13,10 @@ describe('PriorityQueue Operation Test', () => {
13
13
  minPQ.poll();
14
14
  expect(minPQ.toArray()).toEqual([4, 5, 6]);
15
15
  expect(minPQ.peek()).toBe(4);
16
- expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
16
+ expect(PriorityQueue.heapify({
17
+ nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
18
+ comparator: (a, b) => a - b
19
+ }).toArray()).toEqual([
17
20
  1, 2, 3, 5, 6, 7, 8, 9, 10
18
21
  ]);
19
22
  });
@@ -27,7 +30,10 @@ describe('PriorityQueue Operation Test', () => {
27
30
  maxPriorityQueue.poll();
28
31
  expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
29
32
  expect(maxPriorityQueue.peek()).toBe(3);
30
- expect(PriorityQueue.heapify({nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], comparator: (a, b) => a - b}).toArray()).toEqual([
33
+ expect(PriorityQueue.heapify({
34
+ nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
35
+ comparator: (a, b) => a - b
36
+ }).toArray()).toEqual([
31
37
  1, 2, 3, 5, 6, 7, 8, 9, 10
32
38
  ]);
33
39
  });
@@ -155,12 +155,12 @@ describe('Deque', () => {
155
155
  deque = new Deque<number>();
156
156
  });
157
157
 
158
- test('should initialize an empty deque', () => {
158
+ it('should initialize an empty deque', () => {
159
159
  expect(deque.size).toBe(0);
160
160
  expect(deque.isEmpty()).toBe(true);
161
161
  });
162
162
 
163
- test('should add elements to the front and back', () => {
163
+ it('should add elements to the front and back', () => {
164
164
  deque.addFirst(1);
165
165
  deque.addLast(2);
166
166
 
@@ -169,7 +169,7 @@ describe('Deque', () => {
169
169
  expect(deque.getLast()).toBe(2);
170
170
  });
171
171
 
172
- test('should remove elements from the front and back', () => {
172
+ it('should remove elements from the front and back', () => {
173
173
  deque.addFirst(1);
174
174
  deque.addLast(2);
175
175
 
@@ -181,7 +181,7 @@ describe('Deque', () => {
181
181
  expect(lastElement).toBe(2);
182
182
  });
183
183
 
184
- test('should get elements by index', () => {
184
+ it('should get elements by index', () => {
185
185
  deque.addLast(1);
186
186
  deque.addLast(2);
187
187
  deque.addLast(3);
@@ -191,13 +191,13 @@ describe('Deque', () => {
191
191
  expect(deque.getAt(2)).toBe(3);
192
192
  });
193
193
 
194
- test('should return null for out-of-bounds index', () => {
194
+ it('should return null for out-of-bounds index', () => {
195
195
  expect(deque.getAt(0)).toBe(undefined);
196
196
  expect(deque.getAt(1)).toBe(undefined);
197
197
  expect(deque.getAt(-1)).toBe(undefined);
198
198
  });
199
199
 
200
- test('should check if the deque is empty', () => {
200
+ it('should check if the deque is empty', () => {
201
201
  expect(deque.isEmpty()).toBe(true);
202
202
 
203
203
  deque.addLast(1);
@@ -215,12 +215,12 @@ describe('ArrayDeque', () => {
215
215
  deque = new ArrayDeque<number>();
216
216
  });
217
217
 
218
- test('should initialize an empty deque', () => {
218
+ it('should initialize an empty deque', () => {
219
219
  expect(deque.size).toBe(0);
220
220
  expect(deque.isEmpty()).toBe(true);
221
221
  });
222
222
 
223
- test('should add elements to the front and back', () => {
223
+ it('should add elements to the front and back', () => {
224
224
  deque.addFirst(1);
225
225
  deque.addLast(2);
226
226
 
@@ -229,7 +229,7 @@ describe('ArrayDeque', () => {
229
229
  expect(deque.getLast()).toBe(2);
230
230
  });
231
231
 
232
- test('should remove elements from the front and back', () => {
232
+ it('should remove elements from the front and back', () => {
233
233
  deque.addFirst(1);
234
234
  deque.addLast(2);
235
235
 
@@ -241,7 +241,7 @@ describe('ArrayDeque', () => {
241
241
  expect(lastElement).toBe(2);
242
242
  });
243
243
 
244
- test('should get elements by index', () => {
244
+ it('should get elements by index', () => {
245
245
  deque.addLast(1);
246
246
  deque.addLast(2);
247
247
  deque.addLast(3);
@@ -251,13 +251,13 @@ describe('ArrayDeque', () => {
251
251
  expect(deque.get(2)).toBe(3);
252
252
  });
253
253
 
254
- test('should return null for out-of-bounds index', () => {
254
+ it('should return null for out-of-bounds index', () => {
255
255
  expect(deque.get(0)).toBe(null);
256
256
  expect(deque.get(1)).toBe(null);
257
257
  expect(deque.get(-1)).toBe(null);
258
258
  });
259
259
 
260
- test('should check if the deque is empty', () => {
260
+ it('should check if the deque is empty', () => {
261
261
  expect(deque.isEmpty()).toBe(true);
262
262
 
263
263
  deque.addLast(1);
@@ -267,7 +267,7 @@ describe('ArrayDeque', () => {
267
267
  expect(deque.isEmpty()).toBe(true);
268
268
  });
269
269
 
270
- test('should set elements at a specific index', () => {
270
+ it('should set elements at a specific index', () => {
271
271
  deque.addLast(1);
272
272
  deque.addLast(2);
273
273
  deque.addLast(3);
@@ -279,7 +279,7 @@ describe('ArrayDeque', () => {
279
279
  expect(deque.get(2)).toBe(3);
280
280
  });
281
281
 
282
- test('should insert elements at a specific index', () => {
282
+ it('should insert elements at a specific index', () => {
283
283
  deque.addLast(1);
284
284
  deque.addLast(2);
285
285
  deque.addLast(3);
@@ -293,7 +293,7 @@ describe('ArrayDeque', () => {
293
293
  expect(deque.get(3)).toBe(3);
294
294
  });
295
295
 
296
- test('should delete elements at a specific index', () => {
296
+ it('should delete elements at a specific index', () => {
297
297
  deque.addLast(1);
298
298
  deque.addLast(2);
299
299
  deque.addLast(3);
@@ -314,7 +314,7 @@ describe('ObjectDeque', () => {
314
314
  deque = new ObjectDeque<number>();
315
315
  });
316
316
 
317
- test('should add elements to the front of the deque', () => {
317
+ it('should add elements to the front of the deque', () => {
318
318
  deque.addFirst(1);
319
319
  deque.addFirst(2);
320
320
 
@@ -323,7 +323,7 @@ describe('ObjectDeque', () => {
323
323
  expect(deque.getLast()).toBe(1);
324
324
  });
325
325
 
326
- test('should add elements to the end of the deque', () => {
326
+ it('should add elements to the end of the deque', () => {
327
327
  deque.addLast(1);
328
328
  deque.addLast(2);
329
329
 
@@ -332,7 +332,7 @@ describe('ObjectDeque', () => {
332
332
  expect(deque.getLast()).toBe(2);
333
333
  });
334
334
 
335
- test('should remove elements from the front of the deque', () => {
335
+ it('should remove elements from the front of the deque', () => {
336
336
  deque.addLast(1);
337
337
  deque.addLast(2);
338
338
 
@@ -343,7 +343,7 @@ describe('ObjectDeque', () => {
343
343
  expect(deque.getFirst()).toBe(2);
344
344
  });
345
345
 
346
- test('should remove elements from the end of the deque', () => {
346
+ it('should remove elements from the end of the deque', () => {
347
347
  deque.addLast(1);
348
348
  deque.addLast(2);
349
349
 
@@ -354,7 +354,7 @@ describe('ObjectDeque', () => {
354
354
  expect(deque.getLast()).toBe(2);
355
355
  });
356
356
 
357
- test('should return the element at the front of the deque without removing it', () => {
357
+ it('should return the element at the front of the deque without removing it', () => {
358
358
  deque.addFirst(1);
359
359
  deque.addFirst(2);
360
360
 
@@ -362,7 +362,7 @@ describe('ObjectDeque', () => {
362
362
  expect(deque.size).toBe(2);
363
363
  });
364
364
 
365
- test('should return the element at the end of the deque without removing it', () => {
365
+ it('should return the element at the end of the deque without removing it', () => {
366
366
  deque.addLast(1);
367
367
  deque.addLast(2);
368
368
 
@@ -370,7 +370,7 @@ describe('ObjectDeque', () => {
370
370
  expect(deque.size).toBe(2);
371
371
  });
372
372
 
373
- test('should return the correct size of the deque', () => {
373
+ it('should return the correct size of the deque', () => {
374
374
  deque.addFirst(1);
375
375
  deque.addLast(2);
376
376
  deque.addLast(3);
@@ -378,7 +378,7 @@ describe('ObjectDeque', () => {
378
378
  expect(deque.size).toBe(3);
379
379
  });
380
380
 
381
- test('should check if the deque is empty', () => {
381
+ it('should check if the deque is empty', () => {
382
382
  expect(deque.isEmpty()).toBe(true);
383
383
 
384
384
  deque.addFirst(1);
@@ -386,7 +386,7 @@ describe('ObjectDeque', () => {
386
386
  expect(deque.isEmpty()).toBe(false);
387
387
  });
388
388
 
389
- test('should set elements at a specific index', () => {
389
+ it('should set elements at a specific index', () => {
390
390
  deque.addFirst(1);
391
391
  deque.addLast(2);
392
392
  deque.addLast(3);
@@ -396,7 +396,7 @@ describe('ObjectDeque', () => {
396
396
  expect(deque.getLast()).toBe(3);
397
397
  });
398
398
 
399
- test('should insert elements at a specific index', () => {
399
+ it('should insert elements at a specific index', () => {
400
400
  deque.addFirst(1);
401
401
  deque.addLast(2);
402
402
  deque.addLast(3);
@@ -761,7 +761,7 @@ describe('Trie operations', () => {
761
761
  trie = new Trie();
762
762
  });
763
763
 
764
- test('Add and Find Words', () => {
764
+ it('Add and Find Words', () => {
765
765
  trie.add('apple');
766
766
  trie.add('banana');
767
767
  expect(trie.has('apple')).toBe(true);
@@ -769,7 +769,7 @@ describe('Trie operations', () => {
769
769
  expect(trie.has('cherry')).toBe(false);
770
770
  });
771
771
 
772
- test('Remove Words', () => {
772
+ it('Remove Words', () => {
773
773
  trie.add('apple');
774
774
  trie.add('banana');
775
775
  expect(trie.delete('apple')).toBe(true);
@@ -777,39 +777,39 @@ describe('Trie operations', () => {
777
777
  expect(trie.delete('cherry')).toBe(false);
778
778
  });
779
779
 
780
- test('Case Sensitivity', () => {
780
+ it('Case Sensitivity', () => {
781
781
  const caseInsensitiveTrie = new Trie(['apple', 'Banana'], false);
782
782
  expect(caseInsensitiveTrie.has('APPLE')).toBe(true);
783
783
  expect(caseInsensitiveTrie.has('banana')).toBe(true);
784
784
  expect(caseInsensitiveTrie.has('Cherry')).toBe(false);
785
785
  });
786
786
 
787
- test('Pure Prefix Check', () => {
787
+ it('Pure Prefix Check', () => {
788
788
  trie.add('apple');
789
789
  expect(trie.hasPurePrefix('appl')).toBe(true);
790
790
  expect(trie.hasPurePrefix('apple')).toBe(false);
791
791
  });
792
792
 
793
- test('Prefix Check', () => {
793
+ it('Prefix Check', () => {
794
794
  trie.add('apple');
795
795
  expect(trie.hasPrefix('app')).toBe(true);
796
796
  expect(trie.hasPrefix('ban')).toBe(false);
797
797
  });
798
798
 
799
- test('Common Prefix Check', () => {
799
+ it('Common Prefix Check', () => {
800
800
  trie.add('apple');
801
801
  trie.add('appetizer');
802
802
  expect(trie.hasCommonPrefix('app')).toBe(true);
803
803
  expect(trie.hasCommonPrefix('apple')).toBe(false);
804
804
  });
805
805
 
806
- test('Longest Common Prefix', () => {
806
+ it('Longest Common Prefix', () => {
807
807
  trie.add('apple');
808
808
  trie.add('appetizer');
809
809
  expect(trie.getLongestCommonPrefix()).toBe('app');
810
810
  });
811
811
 
812
- test('Get Words by Prefix', () => {
812
+ it('Get Words by Prefix', () => {
813
813
  trie.add('apple');
814
814
  trie.add('appetizer');
815
815
  trie.add('banana');
@@ -817,7 +817,7 @@ describe('Trie operations', () => {
817
817
  expect(words).toEqual(['apple', 'appetizer']);
818
818
  });
819
819
 
820
- test('Tree Height', () => {
820
+ it('Tree Height', () => {
821
821
  trie.add('apple');
822
822
  trie.add('banana');
823
823
  expect(trie.getHeight()).toBe(6); // Assuming 'apple' and 'banana' are the longest words.
@@ -1,6 +1,6 @@
1
1
  import {getRandomInt} from './number';
2
2
 
3
- export function getRandomIntArray(length: number, min: number = -1000, max: number = 1000, isDistinct = true) {
3
+ export function getRandomIntArray(length: number = 1000, min: number = -1000, max: number = 1000, isDistinct = true) {
4
4
  if (isDistinct) {
5
5
  const set = new Set<number>();
6
6
  const ans: number[] = [];
@@ -1,4 +1,4 @@
1
- export function getRandomInt(min: number, max: number) {
1
+ export function getRandomInt(min: number = 0, max: number = 1000) {
2
2
  return Math.floor(Math.random() * (max - min + 1)) + min;
3
3
  }
4
4