data-structure-typed 1.47.5 → 1.47.6
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.
- package/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +8 -8
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +23 -15
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +65 -28
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +66 -82
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +38 -37
- package/dist/cjs/data-structures/binary-tree/bst.js +56 -40
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +11 -7
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +26 -17
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +16 -16
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +31 -22
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +19 -21
- package/dist/cjs/data-structures/heap/heap.js +52 -34
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -5
- package/dist/cjs/data-structures/heap/max-heap.js +2 -2
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -5
- package/dist/cjs/data-structures/heap/min-heap.js +2 -2
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +9 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +2 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +8 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -5
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +2 -2
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -5
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +2 -2
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -5
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +2 -2
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +1 -0
- package/dist/cjs/data-structures/queue/deque.js +3 -0
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +1 -0
- package/dist/cjs/data-structures/queue/queue.js +3 -0
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +2 -1
- package/dist/cjs/data-structures/stack/stack.js +10 -2
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +3 -1
- package/dist/cjs/types/common.d.ts +2 -0
- package/dist/cjs/types/common.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +2 -2
- package/dist/cjs/types/data-structures/heap/heap.d.ts +4 -1
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +2 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +8 -8
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +26 -16
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +65 -28
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +66 -83
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +38 -37
- package/dist/mjs/data-structures/binary-tree/bst.js +59 -41
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +11 -7
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +30 -19
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +16 -16
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +34 -23
- package/dist/mjs/data-structures/graph/abstract-graph.js +1 -1
- package/dist/mjs/data-structures/heap/heap.d.ts +19 -21
- package/dist/mjs/data-structures/heap/heap.js +53 -35
- package/dist/mjs/data-structures/heap/max-heap.d.ts +2 -5
- package/dist/mjs/data-structures/heap/max-heap.js +2 -2
- package/dist/mjs/data-structures/heap/min-heap.d.ts +2 -5
- package/dist/mjs/data-structures/heap/min-heap.js +2 -2
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +9 -1
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -1
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +8 -1
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -5
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +2 -2
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -5
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +2 -2
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +2 -5
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +2 -2
- package/dist/mjs/data-structures/queue/deque.d.ts +1 -0
- package/dist/mjs/data-structures/queue/deque.js +3 -0
- package/dist/mjs/data-structures/queue/queue.d.ts +1 -0
- package/dist/mjs/data-structures/queue/queue.js +3 -0
- package/dist/mjs/data-structures/stack/stack.d.ts +2 -1
- package/dist/mjs/data-structures/stack/stack.js +10 -2
- package/dist/mjs/interfaces/binary-tree.d.ts +3 -1
- package/dist/mjs/types/common.d.ts +2 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +2 -2
- package/dist/mjs/types/data-structures/heap/heap.d.ts +4 -1
- package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +2 -1
- package/dist/umd/data-structure-typed.js +307 -229
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +27 -17
- package/src/data-structures/binary-tree/binary-tree.ts +114 -97
- package/src/data-structures/binary-tree/bst.ts +67 -47
- package/src/data-structures/binary-tree/rb-tree.ts +34 -20
- package/src/data-structures/binary-tree/tree-multimap.ts +43 -25
- package/src/data-structures/graph/abstract-graph.ts +1 -1
- package/src/data-structures/heap/heap.ts +57 -39
- package/src/data-structures/heap/max-heap.ts +5 -5
- package/src/data-structures/heap/min-heap.ts +5 -5
- package/src/data-structures/linked-list/doubly-linked-list.ts +10 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +9 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +4 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +12 -12
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +4 -0
- package/src/data-structures/queue/queue.ts +4 -0
- package/src/data-structures/stack/stack.ts +12 -3
- package/src/interfaces/binary-tree.ts +13 -1
- package/src/types/common.ts +5 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -3
- package/src/types/data-structures/heap/heap.ts +3 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +3 -1
- package/test/performance/data-structures/comparison/comparison.test.ts +7 -6
- package/test/performance/data-structures/heap/heap.test.ts +2 -2
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +6 -6
- package/test/unit/data-structures/binary-tree/bst.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +2 -2
- package/test/unit/data-structures/heap/max-heap.test.ts +1 -1
- package/test/unit/data-structures/heap/min-heap.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +4 -3
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +9 -10
- package/test/unit/data-structures/stack/stack.test.ts +2 -2
- package/test/unit/unrestricted-interconversion.test.ts +100 -0
- package/test/integration/conversion.test.ts +0 -0
|
@@ -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);
|
|
@@ -23,7 +23,7 @@ describe('Heap Operation Test', () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('should object heap work well', function () {
|
|
26
|
-
const minHeap = new MinHeap<{ a: string; key: number }>({ comparator: (a, b) => a.key - b.key });
|
|
26
|
+
const minHeap = new MinHeap<{ a: string; key: number }>([], { comparator: (a, b) => a.key - b.key });
|
|
27
27
|
minHeap.add({ key: 1, a: 'a1' });
|
|
28
28
|
minHeap.add({ key: 6, a: 'a6' });
|
|
29
29
|
minHeap.add({ key: 2, a: 'a2' });
|
|
@@ -43,7 +43,7 @@ describe('Heap Operation Test', () => {
|
|
|
43
43
|
i++;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const maxHeap = new MaxHeap<{ key: number; a: string }>({ comparator: (a, b) => b.key - a.key });
|
|
46
|
+
const maxHeap = new MaxHeap<{ key: number; a: string }>([], { comparator: (a, b) => b.key - a.key });
|
|
47
47
|
maxHeap.add({ key: 1, a: 'a1' });
|
|
48
48
|
maxHeap.add({ key: 6, a: 'a6' });
|
|
49
49
|
maxHeap.add({ key: 5, a: 'a5' });
|
|
@@ -5,7 +5,7 @@ describe('MaxHeap', () => {
|
|
|
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', () => {
|
|
@@ -5,7 +5,7 @@ describe('MinHeap', () => {
|
|
|
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', () => {
|
|
@@ -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
|
|
|
@@ -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>(
|
|
55
|
+
const heap = MaxPriorityQueue.heapify<number>(array, { comparator: (a, b) => b - a });
|
|
56
56
|
heap.refill(array);
|
|
57
57
|
|
|
58
58
|
expect(heap.poll()).toBe(7);
|
|
@@ -63,7 +63,8 @@ describe('MaxPriorityQueue Operation Test', () => {
|
|
|
63
63
|
|
|
64
64
|
it('should correctly heapify an object array', () => {
|
|
65
65
|
const elements = [{ keyA: 5 }, { keyA: 3 }, { keyA: 7 }, { keyA: 1 }];
|
|
66
|
-
|
|
66
|
+
debugger
|
|
67
|
+
const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>(elements, { comparator: (a, b) => b.keyA - a.keyA });
|
|
67
68
|
|
|
68
69
|
expect(maxPQ.poll()?.keyA).toBe(7);
|
|
69
70
|
expect(maxPQ.poll()?.keyA).toBe(5);
|
|
@@ -5,7 +5,7 @@ import { isDebugTest } from '../../../config';
|
|
|
5
5
|
const isDebug = isDebugTest;
|
|
6
6
|
describe('PriorityQueue Operation Test', () => {
|
|
7
7
|
it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
|
|
8
|
-
const minPQ = new PriorityQueue<number>({ comparator: (a, b) => a - b });
|
|
8
|
+
const minPQ = new PriorityQueue<number>([], { comparator: (a, b) => a - b });
|
|
9
9
|
minPQ.refill([5, 2, 3, 4, 6, 1]);
|
|
10
10
|
expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);
|
|
11
11
|
minPQ.poll();
|
|
@@ -14,15 +14,14 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
14
14
|
expect(minPQ.toArray()).toEqual([4, 5, 6]);
|
|
15
15
|
expect(minPQ.peek()).toBe(4);
|
|
16
16
|
expect(
|
|
17
|
-
PriorityQueue.heapify({
|
|
18
|
-
elements: [3, 2, 1, 5, 6, 7, 8, 9, 10],
|
|
17
|
+
PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], {
|
|
19
18
|
comparator: (a, b) => a - b
|
|
20
19
|
}).toArray()
|
|
21
|
-
).toEqual([1,
|
|
20
|
+
).toEqual([1, 3, 2, 5, 6, 7, 8, 9, 10]);
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
|
|
25
|
-
const maxPriorityQueue = new PriorityQueue<number>({ comparator: (a, b) => b - a });
|
|
24
|
+
const maxPriorityQueue = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
|
|
26
25
|
maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]);
|
|
27
26
|
expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);
|
|
28
27
|
maxPriorityQueue.poll();
|
|
@@ -31,15 +30,15 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
31
30
|
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
|
|
32
31
|
expect(maxPriorityQueue.peek()).toBe(3);
|
|
33
32
|
expect(
|
|
34
|
-
PriorityQueue.heapify({
|
|
35
|
-
|
|
33
|
+
PriorityQueue.heapify([3, 2, 1, 5, 6, 7, 8, 9, 10], {
|
|
34
|
+
|
|
36
35
|
comparator: (a, b) => a - b
|
|
37
36
|
}).toArray()
|
|
38
|
-
).toEqual([1,
|
|
37
|
+
).toEqual([1, 3, 2, 5, 6, 7, 8, 9, 10]);
|
|
39
38
|
});
|
|
40
39
|
|
|
41
40
|
it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
|
|
42
|
-
const minPQ1 = new PriorityQueue<number>({ comparator: (a, b) => a - b });
|
|
41
|
+
const minPQ1 = new PriorityQueue<number>([], { comparator: (a, b) => a - b });
|
|
43
42
|
minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]);
|
|
44
43
|
const clonedPriorityQueue = minPQ1.clone();
|
|
45
44
|
expect(clonedPriorityQueue.elements).toEqual(minPQ1.elements);
|
|
@@ -52,7 +51,7 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
52
51
|
|
|
53
52
|
describe('Priority Queue Performance Test', () => {
|
|
54
53
|
it('should numeric heap work well', function () {
|
|
55
|
-
const pq = new PriorityQueue({ comparator: (a, b) => b - a });
|
|
54
|
+
const pq = new PriorityQueue<number>([], { comparator: (a, b) => b - a });
|
|
56
55
|
|
|
57
56
|
const tS = performance.now();
|
|
58
57
|
|
|
@@ -83,7 +83,7 @@ describe('Stack iterative methods', () => {
|
|
|
83
83
|
result.push(element);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
expect(result).toEqual([
|
|
86
|
+
expect(result).toEqual([1, 2, 3]); // iteration should start from the top of the stack
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
test('should apply forEach to the stack', () => {
|
|
@@ -92,7 +92,7 @@ describe('Stack iterative methods', () => {
|
|
|
92
92
|
result.push(element);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
expect(result).toEqual([
|
|
95
|
+
expect(result).toEqual([1, 2, 3]);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
test('should filter elements in the stack', () => {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AVLTree,
|
|
3
|
+
BinaryTree,
|
|
4
|
+
BST,
|
|
5
|
+
Deque,
|
|
6
|
+
DoublyLinkedList,
|
|
7
|
+
MaxHeap,
|
|
8
|
+
MaxPriorityQueue,
|
|
9
|
+
MinHeap,
|
|
10
|
+
MinPriorityQueue,
|
|
11
|
+
Queue,
|
|
12
|
+
RedBlackTree,
|
|
13
|
+
SinglyLinkedList,
|
|
14
|
+
Stack,
|
|
15
|
+
TreeMultimap
|
|
16
|
+
} from '../../src';
|
|
17
|
+
import { isDebugTest } from "../config";
|
|
18
|
+
|
|
19
|
+
const isDebug = isDebugTest;
|
|
20
|
+
const orgArr: number[] = [6, 1, 2, 7, 5, 3, 4, 9, 8];
|
|
21
|
+
const entries: [number, number][] = [[6, 6], [1, 1], [2, 2], [7, 7], [5, 5], [3, 3], [4, 4], [9, 9], [8, 8]];
|
|
22
|
+
|
|
23
|
+
describe('conversions', () => {
|
|
24
|
+
it('Array to Queue', () => {
|
|
25
|
+
const q = new Queue<number>(orgArr);
|
|
26
|
+
isDebug && q.print();
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('Array to Deque', () => {
|
|
30
|
+
const dq = new Deque<number>(orgArr);
|
|
31
|
+
isDebug && dq.print();
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('Array to SinglyLinkedList', () => {
|
|
35
|
+
const sl = new SinglyLinkedList<number>(orgArr);
|
|
36
|
+
isDebug && sl.print();
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('Array to DoublyLinkedList', () => {
|
|
40
|
+
const dl = new DoublyLinkedList<number>(orgArr);
|
|
41
|
+
isDebug && dl.print();
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('Array to Stack', () => {
|
|
45
|
+
const stack = new Stack<number>(orgArr);
|
|
46
|
+
isDebug && stack.print();
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('Array to MinHeap', () => {
|
|
50
|
+
const minHeap = new MinHeap<number>(orgArr);
|
|
51
|
+
isDebug && minHeap.print();
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('Array to MaxHeap', () => {
|
|
55
|
+
const maxHeap = new MaxHeap<number>(orgArr);
|
|
56
|
+
isDebug && maxHeap.print();
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('Array to MinPriorityQueue', () => {
|
|
60
|
+
const minPQ = new MinPriorityQueue<number>(orgArr);
|
|
61
|
+
isDebug && minPQ.print();
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('Array to MaxPriorityQueue', () => {
|
|
65
|
+
const maxPQ = new MaxPriorityQueue<number>(orgArr);
|
|
66
|
+
isDebug && maxPQ.print();
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('Entry Array to BinaryTree', () => {
|
|
70
|
+
const biTree = new BinaryTree<number>(entries);
|
|
71
|
+
isDebug && biTree.print();
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('Entry Array to BST', () => {
|
|
75
|
+
const bst = new BST<number>(orgArr);
|
|
76
|
+
expect(bst.size).toBe(9)
|
|
77
|
+
isDebug && bst.print();
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('Entry Array to RedBlackTree', () => {
|
|
81
|
+
const rbTree = new RedBlackTree<number>(orgArr);
|
|
82
|
+
expect(rbTree.size).toBe(9)
|
|
83
|
+
isDebug && rbTree.print();
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('Entry Array to AVLTree', () => {
|
|
87
|
+
const avl = new AVLTree<number>(orgArr);
|
|
88
|
+
expect(avl.size).toBe(9)
|
|
89
|
+
isDebug && avl.print();
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('Entry Array to TreeMultimap', () => {
|
|
93
|
+
const treeMulti = new TreeMultimap<number>(orgArr);
|
|
94
|
+
expect(treeMulti.size).toBe(9)
|
|
95
|
+
isDebug && treeMulti.print();
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
File without changes
|