data-structure-typed
Advanced tools
Comparing version 1.34.4 to 1.34.5
@@ -11,3 +11,3 @@ # Changelog | ||
## [v1.34.3](https://github.com/zrwusa/data-structure-typed/compare/v1.34.1...main) (upcoming) | ||
## [v1.34.5](https://github.com/zrwusa/data-structure-typed/compare/v1.34.1...main) (upcoming) | ||
@@ -14,0 +14,0 @@ ## [v1.34.1](https://github.com/zrwusa/data-structure-typed/compare/v1.33.4...v1.34.1) (6 October 2023) |
{ | ||
"name": "data-structure-typed", | ||
"version": "1.34.4", | ||
"version": "1.34.5", | ||
"description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,2 @@ | ||
import {MinPriorityQueue, PriorityQueue} from '../../../../src'; | ||
import {MinPriorityQueue} from '../../../../src'; | ||
@@ -63,44 +63,2 @@ describe('MinPriorityQueue Operation Test', () => { | ||
}); | ||
it('should PriorityQueue poll, pee, heapify, toArray work well', function () { | ||
const minPQ = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => a - b}); | ||
expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]); | ||
minPQ.poll(); | ||
minPQ.poll(); | ||
minPQ.poll(); | ||
expect(minPQ.toArray()).toEqual([4, 5, 6]); | ||
expect(minPQ.peek()).toBe(4); | ||
expect( | ||
PriorityQueue.heapify({ | ||
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], | ||
comparator: (a, b) => a - b | ||
}).toArray() | ||
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); | ||
}); | ||
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () { | ||
const maxPriorityQueue = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => b - a}); | ||
expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]); | ||
maxPriorityQueue.poll(); | ||
maxPriorityQueue.poll(); | ||
maxPriorityQueue.poll(); | ||
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]); | ||
expect(maxPriorityQueue.peek()).toBe(3); | ||
expect( | ||
PriorityQueue.heapify({ | ||
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], | ||
comparator: (a, b) => a - b | ||
}).toArray() | ||
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); | ||
}); | ||
it('should PriorityQueue clone, sort, getNodes, DFS work well', function () { | ||
const minPQ1 = new PriorityQueue<number>({nodes: [2, 5, 8, 3, 1, 6, 7, 4], comparator: (a, b) => a - b}); | ||
const clonedPriorityQueue = minPQ1.clone(); | ||
expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes()); | ||
expect(clonedPriorityQueue.sort()).toEqual([1, 2, 3, 4, 5, 6, 7, 8]); | ||
expect(minPQ1.DFS('in')).toEqual([4, 3, 2, 5, 1, 8, 6, 7]); | ||
expect(minPQ1.DFS('post')).toEqual([4, 3, 5, 2, 8, 7, 6, 1]); | ||
expect(minPQ1.DFS('pre')).toEqual([1, 2, 3, 4, 5, 6, 8, 7]); | ||
}); | ||
}); |
@@ -18,2 +18,44 @@ import {PriorityQueue} from '../../../../src'; | ||
}); | ||
it('should PriorityQueue poll, pee, heapify, toArray work well', function () { | ||
const minPQ = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => a - b}); | ||
expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]); | ||
minPQ.poll(); | ||
minPQ.poll(); | ||
minPQ.poll(); | ||
expect(minPQ.toArray()).toEqual([4, 5, 6]); | ||
expect(minPQ.peek()).toBe(4); | ||
expect( | ||
PriorityQueue.heapify({ | ||
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], | ||
comparator: (a, b) => a - b | ||
}).toArray() | ||
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); | ||
}); | ||
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () { | ||
const maxPriorityQueue = new PriorityQueue<number>({nodes: [5, 2, 3, 4, 6, 1], comparator: (a, b) => b - a}); | ||
expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]); | ||
maxPriorityQueue.poll(); | ||
maxPriorityQueue.poll(); | ||
maxPriorityQueue.poll(); | ||
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]); | ||
expect(maxPriorityQueue.peek()).toBe(3); | ||
expect( | ||
PriorityQueue.heapify({ | ||
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10], | ||
comparator: (a, b) => a - b | ||
}).toArray() | ||
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]); | ||
}); | ||
it('should PriorityQueue clone, sort, getNodes, DFS work well', function () { | ||
const minPQ1 = new PriorityQueue<number>({nodes: [2, 5, 8, 3, 1, 6, 7, 4], comparator: (a, b) => a - b}); | ||
const clonedPriorityQueue = minPQ1.clone(); | ||
expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes()); | ||
expect(clonedPriorityQueue.sort()).toEqual([1, 2, 3, 4, 5, 6, 7, 8]); | ||
expect(minPQ1.DFS('in')).toEqual([4, 3, 2, 5, 1, 8, 6, 7]); | ||
expect(minPQ1.DFS('post')).toEqual([4, 3, 5, 2, 8, 7, 6, 1]); | ||
expect(minPQ1.DFS('pre')).toEqual([1, 2, 3, 4, 5, 6, 8, 7]); | ||
}); | ||
}); | ||
@@ -29,1 +71,2 @@ | ||
}); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2263883