data-structure-typed 2.5.1 → 2.5.3
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 +5 -1
- package/MIGRATION.md +169 -0
- package/README.md +135 -23
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +6460 -1591
- package/dist/cjs/graph.cjs +440 -20
- package/dist/cjs/hash.cjs +125 -22
- package/dist/cjs/heap.cjs +196 -47
- package/dist/cjs/index.cjs +8486 -2429
- package/dist/cjs/linked-list.cjs +456 -31
- package/dist/cjs/matrix.cjs +79 -9
- package/dist/cjs/priority-queue.cjs +193 -44
- package/dist/cjs/queue.cjs +391 -2
- package/dist/cjs/stack.cjs +92 -6
- package/dist/cjs/trie.cjs +122 -28
- package/dist/cjs-legacy/binary-tree.cjs +6484 -1612
- package/dist/cjs-legacy/graph.cjs +440 -20
- package/dist/cjs-legacy/hash.cjs +125 -22
- package/dist/cjs-legacy/heap.cjs +196 -47
- package/dist/cjs-legacy/index.cjs +8654 -2594
- package/dist/cjs-legacy/linked-list.cjs +456 -31
- package/dist/cjs-legacy/matrix.cjs +79 -9
- package/dist/cjs-legacy/priority-queue.cjs +193 -44
- package/dist/cjs-legacy/queue.cjs +391 -2
- package/dist/cjs-legacy/stack.cjs +92 -6
- package/dist/cjs-legacy/trie.cjs +122 -28
- package/dist/esm/binary-tree.mjs +6460 -1591
- package/dist/esm/graph.mjs +440 -20
- package/dist/esm/hash.mjs +125 -22
- package/dist/esm/heap.mjs +196 -47
- package/dist/esm/index.mjs +8486 -2430
- package/dist/esm/linked-list.mjs +456 -31
- package/dist/esm/matrix.mjs +79 -9
- package/dist/esm/priority-queue.mjs +193 -44
- package/dist/esm/queue.mjs +391 -2
- package/dist/esm/stack.mjs +92 -6
- package/dist/esm/trie.mjs +122 -28
- package/dist/esm-legacy/binary-tree.mjs +6484 -1612
- package/dist/esm-legacy/graph.mjs +440 -20
- package/dist/esm-legacy/hash.mjs +125 -22
- package/dist/esm-legacy/heap.mjs +196 -47
- package/dist/esm-legacy/index.mjs +8654 -2595
- package/dist/esm-legacy/linked-list.mjs +456 -31
- package/dist/esm-legacy/matrix.mjs +79 -9
- package/dist/esm-legacy/priority-queue.mjs +193 -44
- package/dist/esm-legacy/queue.mjs +391 -2
- package/dist/esm-legacy/stack.mjs +92 -6
- package/dist/esm-legacy/trie.mjs +122 -28
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +112 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +214 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +294 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +155 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +48 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1370 -323
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1329 -316
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +1116 -295
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1330 -326
- package/dist/types/data-structures/graph/directed-graph.d.ts +80 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +72 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +95 -6
- package/dist/types/data-structures/heap/heap.d.ts +154 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +143 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +144 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +64 -0
- package/dist/types/data-structures/queue/deque.d.ts +142 -0
- package/dist/types/data-structures/queue/queue.d.ts +109 -0
- package/dist/types/data-structures/stack/stack.d.ts +82 -2
- package/dist/types/data-structures/trie/trie.d.ts +96 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/data-structure-typed.js +8623 -2564
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +696 -194
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
- package/docs-site-docusaurus/docs/api/classes/BST.md +639 -189
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +148 -160
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +105 -91
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +104 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +51 -51
- package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
- package/docs-site-docusaurus/docs/api/classes/Queue.md +112 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +708 -206
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +79 -79
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +236 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +232 -32
- package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -5
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -3
- package/docs-site-docusaurus/docs/guide/faq.md +233 -0
- package/docs-site-docusaurus/docs/guide/guides.md +43 -58
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +75 -176
- package/docs-site-docusaurus/docs/guide/overview.md +132 -11
- package/docs-site-docusaurus/docs/guide/performance.md +2 -0
- package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
- package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
- package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
- package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
- package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
- package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
- package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
- package/docs-site-docusaurus/docusaurus.config.ts +1 -1
- package/docs-site-docusaurus/src/pages/index.tsx +55 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/llms.txt +37 -0
- package/package.json +65 -56
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MaxHeap\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/heap/max-heap.ts:73](https://github.com/zrwusa/data-structure-typed/blob/
|
|
9
|
+
Defined in: [data-structures/heap/max-heap.ts:73](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/max-heap.ts#L73)
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
@@ -97,7 +97,7 @@ Notes and typical use-cases are documented in [Heap](Heap.md).
|
|
|
97
97
|
new MaxHeap<E, R>(elements?, options?): MaxHeap<E, R>;
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
Defined in: [data-structures/heap/max-heap.ts:79](https://github.com/zrwusa/data-structure-typed/blob/
|
|
100
|
+
Defined in: [data-structures/heap/max-heap.ts:79](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/max-heap.ts#L79)
|
|
101
101
|
|
|
102
102
|
Create a max-heap. For objects, supply a custom comparator.
|
|
103
103
|
|
|
@@ -133,7 +133,7 @@ Optional configuration.
|
|
|
133
133
|
get comparator(): Comparator<E>;
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
136
|
+
Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
|
|
137
137
|
|
|
138
138
|
Get the comparator used to order elements.
|
|
139
139
|
|
|
@@ -161,7 +161,7 @@ Comparator function.
|
|
|
161
161
|
get elements(): E[];
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/
|
|
164
|
+
Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
|
|
165
165
|
|
|
166
166
|
Get the backing array of the heap.
|
|
167
167
|
|
|
@@ -189,7 +189,7 @@ Internal elements array.
|
|
|
189
189
|
get leaf(): E | undefined;
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
192
|
+
Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
|
|
193
193
|
|
|
194
194
|
Get the last leaf element.
|
|
195
195
|
|
|
@@ -217,7 +217,7 @@ Last element or undefined.
|
|
|
217
217
|
get size(): number;
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
220
|
+
Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
|
|
221
221
|
|
|
222
222
|
Get the number of elements.
|
|
223
223
|
|
|
@@ -260,7 +260,7 @@ Heap size.
|
|
|
260
260
|
get toElementFn(): ((rawElement) => E) | undefined;
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
263
|
+
Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L48)
|
|
264
264
|
|
|
265
265
|
Exposes the current `toElementFn`, if configured.
|
|
266
266
|
|
|
@@ -286,7 +286,7 @@ The converter function or `undefined` when not set.
|
|
|
286
286
|
iterator: IterableIterator<E>;
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
289
|
+
Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L61)
|
|
290
290
|
|
|
291
291
|
Returns an iterator over the structure's elements.
|
|
292
292
|
|
|
@@ -320,7 +320,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
320
320
|
add(element): boolean;
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
323
|
+
Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
|
|
324
324
|
|
|
325
325
|
Insert an element.
|
|
326
326
|
|
|
@@ -342,7 +342,7 @@ True.
|
|
|
342
342
|
|
|
343
343
|
#### Remarks
|
|
344
344
|
|
|
345
|
-
Time O(
|
|
345
|
+
Time O(log N) amortized, Space O(1)
|
|
346
346
|
|
|
347
347
|
#### Example
|
|
348
348
|
|
|
@@ -375,7 +375,7 @@ Time O(1) amortized, Space O(1)
|
|
|
375
375
|
addMany(elements): boolean[];
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
378
|
+
Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
|
|
379
379
|
|
|
380
380
|
Insert many elements from an iterable.
|
|
381
381
|
|
|
@@ -421,7 +421,7 @@ Time O(N log N), Space O(1)
|
|
|
421
421
|
clear(): void;
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
424
|
+
Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
|
|
425
425
|
|
|
426
426
|
Remove all elements.
|
|
427
427
|
|
|
@@ -458,7 +458,7 @@ Time O(1), Space O(1)
|
|
|
458
458
|
clone(): this;
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
461
|
+
Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
|
|
462
462
|
|
|
463
463
|
Deep clone this heap.
|
|
464
464
|
|
|
@@ -497,7 +497,7 @@ Time O(N), Space O(N)
|
|
|
497
497
|
delete(element): boolean;
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
500
|
+
Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
|
|
501
501
|
|
|
502
502
|
Delete one occurrence of an element.
|
|
503
503
|
|
|
@@ -536,13 +536,41 @@ Time O(N), Space O(1)
|
|
|
536
536
|
|
|
537
537
|
***
|
|
538
538
|
|
|
539
|
-
### deleteBy()
|
|
539
|
+
### ~~deleteBy()~~
|
|
540
540
|
|
|
541
541
|
```ts
|
|
542
542
|
deleteBy(predicate): boolean;
|
|
543
543
|
```
|
|
544
544
|
|
|
545
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
545
|
+
Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
|
|
546
|
+
|
|
547
|
+
#### Parameters
|
|
548
|
+
|
|
549
|
+
##### predicate
|
|
550
|
+
|
|
551
|
+
(`element`, `index`, `heap`) => `boolean`
|
|
552
|
+
|
|
553
|
+
#### Returns
|
|
554
|
+
|
|
555
|
+
`boolean`
|
|
556
|
+
|
|
557
|
+
#### Deprecated
|
|
558
|
+
|
|
559
|
+
Use `deleteWhere` instead. Will be removed in a future major version.
|
|
560
|
+
|
|
561
|
+
#### Inherited from
|
|
562
|
+
|
|
563
|
+
[`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
|
|
564
|
+
|
|
565
|
+
***
|
|
566
|
+
|
|
567
|
+
### deleteWhere()
|
|
568
|
+
|
|
569
|
+
```ts
|
|
570
|
+
deleteWhere(predicate): boolean;
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
|
|
546
574
|
|
|
547
575
|
Delete the first element that matches a predicate.
|
|
548
576
|
|
|
@@ -566,7 +594,7 @@ Time O(N), Space O(1)
|
|
|
566
594
|
|
|
567
595
|
#### Inherited from
|
|
568
596
|
|
|
569
|
-
[`Heap`](Heap.md).[`
|
|
597
|
+
[`Heap`](Heap.md).[`deleteWhere`](Heap.md#deletewhere)
|
|
570
598
|
|
|
571
599
|
***
|
|
572
600
|
|
|
@@ -576,7 +604,7 @@ Time O(N), Space O(1)
|
|
|
576
604
|
dfs(order?): E[];
|
|
577
605
|
```
|
|
578
606
|
|
|
579
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
607
|
+
Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
|
|
580
608
|
|
|
581
609
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
582
610
|
|
|
@@ -621,7 +649,7 @@ Time O(N), Space O(H)
|
|
|
621
649
|
every(predicate, thisArg?): boolean;
|
|
622
650
|
```
|
|
623
651
|
|
|
624
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
652
|
+
Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L87)
|
|
625
653
|
|
|
626
654
|
Tests whether all elements satisfy the predicate.
|
|
627
655
|
|
|
@@ -661,7 +689,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
661
689
|
filter(callback, thisArg?): this;
|
|
662
690
|
```
|
|
663
691
|
|
|
664
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
692
|
+
Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
|
|
665
693
|
|
|
666
694
|
Filter elements into a new heap of the same class.
|
|
667
695
|
|
|
@@ -714,7 +742,7 @@ Time O(N log N), Space O(N)
|
|
|
714
742
|
find<S>(predicate, thisArg?): S | undefined;
|
|
715
743
|
```
|
|
716
744
|
|
|
717
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
745
|
+
Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L163)
|
|
718
746
|
|
|
719
747
|
Finds the first element that satisfies the predicate and returns it.
|
|
720
748
|
|
|
@@ -760,7 +788,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
760
788
|
find(predicate, thisArg?): E | undefined;
|
|
761
789
|
```
|
|
762
790
|
|
|
763
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
791
|
+
Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L164)
|
|
764
792
|
|
|
765
793
|
Finds the first element that satisfies the predicate and returns it.
|
|
766
794
|
|
|
@@ -802,7 +830,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
802
830
|
fix(): boolean[];
|
|
803
831
|
```
|
|
804
832
|
|
|
805
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
833
|
+
Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
|
|
806
834
|
|
|
807
835
|
Restore heap order bottom-up (heapify in-place).
|
|
808
836
|
|
|
@@ -828,7 +856,7 @@ Time O(N), Space O(1)
|
|
|
828
856
|
forEach(callbackfn, thisArg?): void;
|
|
829
857
|
```
|
|
830
858
|
|
|
831
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
859
|
+
Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L133)
|
|
832
860
|
|
|
833
861
|
Invokes a callback for each element in iteration order.
|
|
834
862
|
|
|
@@ -868,7 +896,7 @@ Time O(n), Space O(1).
|
|
|
868
896
|
has(element): boolean;
|
|
869
897
|
```
|
|
870
898
|
|
|
871
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
899
|
+
Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
|
|
872
900
|
|
|
873
901
|
Check if an equal element exists in the heap.
|
|
874
902
|
|
|
@@ -913,7 +941,7 @@ Time O(N), Space O(1)
|
|
|
913
941
|
isEmpty(): boolean;
|
|
914
942
|
```
|
|
915
943
|
|
|
916
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
944
|
+
Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
|
|
917
945
|
|
|
918
946
|
Check whether the heap is empty.
|
|
919
947
|
|
|
@@ -954,7 +982,7 @@ map<EM, RM>(
|
|
|
954
982
|
thisArg?): Heap<EM, RM>;
|
|
955
983
|
```
|
|
956
984
|
|
|
957
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
985
|
+
Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
|
|
958
986
|
|
|
959
987
|
Map elements into a new heap of possibly different element type.
|
|
960
988
|
|
|
@@ -1021,7 +1049,7 @@ Time O(N log N), Space O(N)
|
|
|
1021
1049
|
mapSame(callback, thisArg?): this;
|
|
1022
1050
|
```
|
|
1023
1051
|
|
|
1024
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1052
|
+
Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
|
|
1025
1053
|
|
|
1026
1054
|
Map elements into a new heap of the same element type.
|
|
1027
1055
|
|
|
@@ -1061,7 +1089,7 @@ Time O(N log N), Space O(N)
|
|
|
1061
1089
|
peek(): E | undefined;
|
|
1062
1090
|
```
|
|
1063
1091
|
|
|
1064
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1092
|
+
Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
|
|
1065
1093
|
|
|
1066
1094
|
Get the current top element without removing it.
|
|
1067
1095
|
|
|
@@ -1146,28 +1174,23 @@ Time O(1), Space O(1)
|
|
|
1146
1174
|
|
|
1147
1175
|
***
|
|
1148
1176
|
|
|
1149
|
-
### poll()
|
|
1177
|
+
### ~~poll()~~
|
|
1150
1178
|
|
|
1151
1179
|
```ts
|
|
1152
1180
|
poll(): E | undefined;
|
|
1153
1181
|
```
|
|
1154
1182
|
|
|
1155
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1156
|
-
|
|
1157
|
-
Remove and return the top element.
|
|
1183
|
+
Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
|
|
1158
1184
|
|
|
1159
1185
|
#### Returns
|
|
1160
1186
|
|
|
1161
1187
|
`E` \| `undefined`
|
|
1162
1188
|
|
|
1163
|
-
|
|
1189
|
+
#### Deprecated
|
|
1164
1190
|
|
|
1191
|
+
Use `pop` instead. Will be removed in a future major version.
|
|
1165
1192
|
*
|
|
1166
1193
|
|
|
1167
|
-
#### Remarks
|
|
1168
|
-
|
|
1169
|
-
Time O(log N), Space O(1)
|
|
1170
|
-
|
|
1171
1194
|
#### Example
|
|
1172
1195
|
|
|
1173
1196
|
```ts
|
|
@@ -1203,13 +1226,39 @@ Time O(log N), Space O(1)
|
|
|
1203
1226
|
|
|
1204
1227
|
***
|
|
1205
1228
|
|
|
1229
|
+
### pop()
|
|
1230
|
+
|
|
1231
|
+
```ts
|
|
1232
|
+
pop(): E | undefined;
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1235
|
+
Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
|
|
1236
|
+
|
|
1237
|
+
Remove and return the top element (min or max depending on comparator).
|
|
1238
|
+
|
|
1239
|
+
#### Returns
|
|
1240
|
+
|
|
1241
|
+
`E` \| `undefined`
|
|
1242
|
+
|
|
1243
|
+
The removed top element, or undefined if empty.
|
|
1244
|
+
|
|
1245
|
+
#### Remarks
|
|
1246
|
+
|
|
1247
|
+
Time O(log N) amortized, Space O(1)
|
|
1248
|
+
|
|
1249
|
+
#### Inherited from
|
|
1250
|
+
|
|
1251
|
+
[`Heap`](Heap.md).[`pop`](Heap.md#pop)
|
|
1252
|
+
|
|
1253
|
+
***
|
|
1254
|
+
|
|
1206
1255
|
### print()
|
|
1207
1256
|
|
|
1208
1257
|
```ts
|
|
1209
1258
|
print(): void;
|
|
1210
1259
|
```
|
|
1211
1260
|
|
|
1212
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1261
|
+
Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L269)
|
|
1213
1262
|
|
|
1214
1263
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1215
1264
|
|
|
@@ -1267,7 +1316,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1267
1316
|
reduce(callbackfn): E;
|
|
1268
1317
|
```
|
|
1269
1318
|
|
|
1270
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1319
|
+
Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L194)
|
|
1271
1320
|
|
|
1272
1321
|
##### Parameters
|
|
1273
1322
|
|
|
@@ -1289,7 +1338,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:193](https://github.c
|
|
|
1289
1338
|
reduce(callbackfn, initialValue): E;
|
|
1290
1339
|
```
|
|
1291
1340
|
|
|
1292
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1341
|
+
Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L195)
|
|
1293
1342
|
|
|
1294
1343
|
##### Parameters
|
|
1295
1344
|
|
|
@@ -1315,7 +1364,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1315
1364
|
reduce<U>(callbackfn, initialValue): U;
|
|
1316
1365
|
```
|
|
1317
1366
|
|
|
1318
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1367
|
+
Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L196)
|
|
1319
1368
|
|
|
1320
1369
|
##### Type Parameters
|
|
1321
1370
|
|
|
@@ -1343,47 +1392,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1343
1392
|
|
|
1344
1393
|
***
|
|
1345
1394
|
|
|
1346
|
-
### refill()
|
|
1347
|
-
|
|
1348
|
-
```ts
|
|
1349
|
-
refill(elements): boolean[];
|
|
1350
|
-
```
|
|
1351
|
-
|
|
1352
|
-
Defined in: [data-structures/heap/heap.ts:638](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/heap/heap.ts#L638)
|
|
1353
|
-
|
|
1354
|
-
Replace the backing array and rebuild the heap.
|
|
1355
|
-
|
|
1356
|
-
#### Parameters
|
|
1357
|
-
|
|
1358
|
-
##### elements
|
|
1359
|
-
|
|
1360
|
-
`Iterable`\<`E`\>
|
|
1361
|
-
|
|
1362
|
-
Iterable used to refill the heap.
|
|
1363
|
-
|
|
1364
|
-
#### Returns
|
|
1365
|
-
|
|
1366
|
-
`boolean`[]
|
|
1367
|
-
|
|
1368
|
-
Array of per-node results from fixing steps.
|
|
1369
|
-
|
|
1370
|
-
#### Remarks
|
|
1371
|
-
|
|
1372
|
-
Time O(N), Space O(N)
|
|
1373
|
-
|
|
1374
|
-
#### Inherited from
|
|
1375
|
-
|
|
1376
|
-
[`Heap`](Heap.md).[`refill`](Heap.md#refill)
|
|
1377
|
-
|
|
1378
|
-
***
|
|
1379
|
-
|
|
1380
1395
|
### setEquality()
|
|
1381
1396
|
|
|
1382
1397
|
```ts
|
|
1383
1398
|
setEquality(equals): this;
|
|
1384
1399
|
```
|
|
1385
1400
|
|
|
1386
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1401
|
+
Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
|
|
1387
1402
|
|
|
1388
1403
|
Set the equality comparator used by has/delete operations.
|
|
1389
1404
|
|
|
@@ -1417,7 +1432,7 @@ Time O(1), Space O(1)
|
|
|
1417
1432
|
some(predicate, thisArg?): boolean;
|
|
1418
1433
|
```
|
|
1419
1434
|
|
|
1420
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1435
|
+
Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L110)
|
|
1421
1436
|
|
|
1422
1437
|
Tests whether at least one element satisfies the predicate.
|
|
1423
1438
|
|
|
@@ -1457,7 +1472,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1457
1472
|
sort(): E[];
|
|
1458
1473
|
```
|
|
1459
1474
|
|
|
1460
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1475
|
+
Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
|
|
1461
1476
|
|
|
1462
1477
|
Return all elements in ascending order by repeatedly polling.
|
|
1463
1478
|
|
|
@@ -1494,7 +1509,7 @@ Time O(N log N), Space O(N)
|
|
|
1494
1509
|
toArray(): E[];
|
|
1495
1510
|
```
|
|
1496
1511
|
|
|
1497
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1512
|
+
Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L246)
|
|
1498
1513
|
|
|
1499
1514
|
Materializes the elements into a new array.
|
|
1500
1515
|
|
|
@@ -1520,7 +1535,7 @@ Time O(n), Space O(n).
|
|
|
1520
1535
|
toVisual(): E[];
|
|
1521
1536
|
```
|
|
1522
1537
|
|
|
1523
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1538
|
+
Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L258)
|
|
1524
1539
|
|
|
1525
1540
|
Returns a representation of the structure suitable for quick visualization.
|
|
1526
1541
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1547,7 +1562,7 @@ Time O(n), Space O(n).
|
|
|
1547
1562
|
values(): IterableIterator<E>;
|
|
1548
1563
|
```
|
|
1549
1564
|
|
|
1550
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1565
|
+
Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L72)
|
|
1551
1566
|
|
|
1552
1567
|
Returns an iterator over the values (alias of the default iterator).
|
|
1553
1568
|
|
|
@@ -1576,7 +1591,7 @@ static from<T, R, S>(
|
|
|
1576
1591
|
options?): S;
|
|
1577
1592
|
```
|
|
1578
1593
|
|
|
1579
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1594
|
+
Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
|
|
1580
1595
|
|
|
1581
1596
|
Create a heap of the same class from an iterable.
|
|
1582
1597
|
|
|
@@ -1634,7 +1649,7 @@ Time O(N), Space O(N)
|
|
|
1634
1649
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1635
1650
|
```
|
|
1636
1651
|
|
|
1637
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1652
|
+
Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
|
|
1638
1653
|
|
|
1639
1654
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1640
1655
|
|
|
@@ -1687,7 +1702,7 @@ Time O(N), Space O(N)
|
|
|
1687
1702
|
protected optional _toElementFn?: (rawElement) => E;
|
|
1688
1703
|
```
|
|
1689
1704
|
|
|
1690
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1705
|
+
Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L39)
|
|
1691
1706
|
|
|
1692
1707
|
The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
1693
1708
|
|
|
@@ -1717,7 +1732,7 @@ Time O(1), Space O(1).
|
|
|
1717
1732
|
protected _createInstance(options?): this;
|
|
1718
1733
|
```
|
|
1719
1734
|
|
|
1720
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1735
|
+
Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
|
|
1721
1736
|
|
|
1722
1737
|
(Protected) Create an empty instance of the same concrete class.
|
|
1723
1738
|
|
|
@@ -1751,7 +1766,7 @@ Time O(1), Space O(1)
|
|
|
1751
1766
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1752
1767
|
```
|
|
1753
1768
|
|
|
1754
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1769
|
+
Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
|
|
1755
1770
|
|
|
1756
1771
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1757
1772
|
|
|
@@ -1801,7 +1816,7 @@ Time O(N log N), Space O(N)
|
|
|
1801
1816
|
protected _getIterator(): IterableIterator<E>;
|
|
1802
1817
|
```
|
|
1803
1818
|
|
|
1804
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1819
|
+
Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
|
|
1805
1820
|
|
|
1806
1821
|
Internal iterator factory used by the default iterator.
|
|
1807
1822
|
|
|
@@ -1827,7 +1842,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1827
1842
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1828
1843
|
```
|
|
1829
1844
|
|
|
1830
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1845
|
+
Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
|
|
1831
1846
|
|
|
1832
1847
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1833
1848
|
|