data-structure-typed 2.6.0 → 2.6.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.
- package/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
- package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
- package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
- package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
- package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +284 -3972
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -67,12 +67,7 @@ import { ERR, raise } from '../../common';
|
|
|
67
67
|
* while (cpuQueue.size > 0) {
|
|
68
68
|
* order.push(cpuQueue.poll()![1]);
|
|
69
69
|
* }
|
|
70
|
-
* console.log(order); // [
|
|
71
|
-
* // 'User interaction',
|
|
72
|
-
* // 'System process',
|
|
73
|
-
* // 'Network sync',
|
|
74
|
-
* // 'Background task'
|
|
75
|
-
* // ];
|
|
70
|
+
* console.log(order); // ['User interaction', 'System process', 'Network sync', 'Background task'];
|
|
76
71
|
*/
|
|
77
72
|
export class MaxPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
|
|
78
73
|
/**
|
|
@@ -18,10 +18,10 @@ import { PriorityQueue } from './priority-queue';
|
|
|
18
18
|
* // Shortest job first scheduling
|
|
19
19
|
* const jobs = new MinPriorityQueue<number>();
|
|
20
20
|
*
|
|
21
|
-
* jobs.add(8);
|
|
22
|
-
* jobs.add(2);
|
|
23
|
-
* jobs.add(5);
|
|
24
|
-
* jobs.add(1);
|
|
21
|
+
* jobs.add(8); // 8 seconds
|
|
22
|
+
* jobs.add(2); // 2 seconds
|
|
23
|
+
* jobs.add(5); // 5 seconds
|
|
24
|
+
* jobs.add(1); // 1 second
|
|
25
25
|
*
|
|
26
26
|
* // Shortest job first
|
|
27
27
|
* console.log(jobs.poll()); // 1;
|
|
@@ -48,12 +48,7 @@ import { PriorityQueue } from './priority-queue';
|
|
|
48
48
|
* while (timeline.size > 0) {
|
|
49
49
|
* order.push(timeline.poll()!.action);
|
|
50
50
|
* }
|
|
51
|
-
* console.log(order); // [
|
|
52
|
-
* // 'Request received',
|
|
53
|
-
* // 'Cache hit',
|
|
54
|
-
* // 'Processing done',
|
|
55
|
-
* // 'Timeout'
|
|
56
|
-
* // ];
|
|
51
|
+
* console.log(order); // ['Request received', 'Cache hit', 'Processing done', 'Timeout'];
|
|
57
52
|
* @example
|
|
58
53
|
* // Huffman coding frequency selection
|
|
59
54
|
* // Character frequencies for Huffman tree building
|
|
@@ -69,7 +64,7 @@ import { PriorityQueue } from './priority-queue';
|
|
|
69
64
|
* // Always pick two lowest frequencies
|
|
70
65
|
* const first = freq.poll()!;
|
|
71
66
|
* const second = freq.poll()!;
|
|
72
|
-
* console.log(first[1]); // 'd';
|
|
67
|
+
* console.log(first[1]); // 'd'; // freq 2
|
|
73
68
|
* console.log(second[1]); // 'a'; // freq 5
|
|
74
69
|
*
|
|
75
70
|
* // Combined node goes back
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
import type { PriorityQueueOptions } from '../../types';
|
|
10
9
|
import { Heap } from '../heap';
|
|
11
10
|
|
|
@@ -62,7 +61,7 @@ import { Heap } from '../heap';
|
|
|
62
61
|
* comparator: (a, b) => a[0] - b[0]
|
|
63
62
|
* });
|
|
64
63
|
*
|
|
65
|
-
* bandwidth.add([1, 'Video call']);
|
|
64
|
+
* bandwidth.add([1, 'Video call']); // highest priority
|
|
66
65
|
* bandwidth.add([3, 'File download']);
|
|
67
66
|
* bandwidth.add([2, 'Web browsing']);
|
|
68
67
|
* bandwidth.add([1, 'Voice call']);
|