data-structure-typed 2.5.2 → 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 +3 -1
- package/MIGRATION.md +169 -0
- package/README.md +60 -6
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +2417 -132
- package/dist/cjs/graph.cjs +248 -14
- package/dist/cjs/hash.cjs +62 -7
- package/dist/cjs/heap.cjs +103 -16
- package/dist/cjs/index.cjs +3046 -124
- package/dist/cjs/linked-list.cjs +219 -0
- package/dist/cjs/matrix.cjs +32 -0
- package/dist/cjs/priority-queue.cjs +101 -14
- package/dist/cjs/queue.cjs +215 -0
- package/dist/cjs/stack.cjs +44 -4
- package/dist/cjs/trie.cjs +44 -0
- package/dist/cjs-legacy/binary-tree.cjs +2406 -123
- package/dist/cjs-legacy/graph.cjs +248 -14
- package/dist/cjs-legacy/hash.cjs +62 -7
- package/dist/cjs-legacy/heap.cjs +103 -16
- package/dist/cjs-legacy/index.cjs +3105 -185
- package/dist/cjs-legacy/linked-list.cjs +219 -0
- package/dist/cjs-legacy/matrix.cjs +32 -0
- package/dist/cjs-legacy/priority-queue.cjs +101 -14
- package/dist/cjs-legacy/queue.cjs +215 -0
- package/dist/cjs-legacy/stack.cjs +44 -4
- package/dist/cjs-legacy/trie.cjs +44 -0
- package/dist/esm/binary-tree.mjs +2417 -132
- package/dist/esm/graph.mjs +248 -14
- package/dist/esm/hash.mjs +62 -7
- package/dist/esm/heap.mjs +103 -16
- package/dist/esm/index.mjs +3046 -124
- package/dist/esm/linked-list.mjs +219 -0
- package/dist/esm/matrix.mjs +32 -0
- package/dist/esm/priority-queue.mjs +101 -14
- package/dist/esm/queue.mjs +215 -0
- package/dist/esm/stack.mjs +44 -4
- package/dist/esm/trie.mjs +44 -0
- package/dist/esm-legacy/binary-tree.mjs +2406 -123
- package/dist/esm-legacy/graph.mjs +248 -14
- package/dist/esm-legacy/hash.mjs +62 -7
- package/dist/esm-legacy/heap.mjs +103 -16
- package/dist/esm-legacy/index.mjs +3105 -185
- package/dist/esm-legacy/linked-list.mjs +219 -0
- package/dist/esm-legacy/matrix.mjs +32 -0
- package/dist/esm-legacy/priority-queue.mjs +101 -14
- package/dist/esm-legacy/queue.mjs +215 -0
- package/dist/esm-legacy/stack.mjs +44 -4
- package/dist/esm-legacy/trie.mjs +44 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
- package/dist/types/data-structures/heap/heap.d.ts +98 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +82 -0
- package/dist/types/data-structures/queue/queue.d.ts +61 -0
- package/dist/types/data-structures/stack/stack.d.ts +42 -2
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/data-structure-typed.js +3105 -185
- package/dist/umd/data-structure-typed.min.js +4 -4
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
- package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
- 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 +143 -155
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
- 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 +38 -38
- 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 +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
- 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 +111 -59
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
- package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
- package/docs-site-docusaurus/docs/guide/faq.md +53 -0
- package/docs-site-docusaurus/docs/guide/guides.md +8 -9
- package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
- package/docs-site-docusaurus/docs/guide/overview.md +131 -17
- package/docs-site-docusaurus/src/pages/index.tsx +4 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/package.json +7 -6
- package/src/data-structures/binary-tree/avl-tree.ts +52 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
- package/src/data-structures/binary-tree/binary-tree.ts +167 -81
- package/src/data-structures/binary-tree/bst.ts +101 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
- package/src/data-structures/binary-tree/segment-tree.ts +24 -0
- package/src/data-structures/binary-tree/tree-map.ts +540 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
- package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
- package/src/data-structures/binary-tree/tree-set.ts +520 -3
- package/src/data-structures/graph/directed-graph.ts +41 -1
- package/src/data-structures/graph/undirected-graph.ts +37 -1
- package/src/data-structures/hash/hash-map.ts +67 -12
- package/src/data-structures/heap/heap.ts +107 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
- package/src/data-structures/matrix/matrix.ts +32 -0
- package/src/data-structures/queue/deque.ts +85 -0
- package/src/data-structures/queue/queue.ts +73 -0
- package/src/data-structures/stack/stack.ts +45 -5
- package/src/data-structures/trie/trie.ts +48 -0
- package/src/interfaces/binary-tree.ts +1 -9
- 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: MinPriorityQueue\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/priority-queue/min-priority-queue.ts:79](https://github.com/zrwusa/data-structure-typed/blob/
|
|
9
|
+
Defined in: [data-structures/priority-queue/min-priority-queue.ts:79](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/min-priority-queue.ts#L79)
|
|
10
10
|
|
|
11
11
|
Min-oriented priority queue (min-heap) built on [PriorityQueue](PriorityQueue.md).
|
|
12
12
|
The queue removes the smallest element first under the provided comparator.
|
|
@@ -107,7 +107,7 @@ Extra record/metadata associated with each element.
|
|
|
107
107
|
new MinPriorityQueue<E, R>(elements?, options?): MinPriorityQueue<E, R>;
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
Defined in: [data-structures/priority-queue/min-priority-queue.ts:86](https://github.com/zrwusa/data-structure-typed/blob/
|
|
110
|
+
Defined in: [data-structures/priority-queue/min-priority-queue.ts:86](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/min-priority-queue.ts#L86)
|
|
111
111
|
|
|
112
112
|
Creates a min-priority queue.
|
|
113
113
|
|
|
@@ -149,7 +149,7 @@ PriorityQueue<E, R>.constructor
|
|
|
149
149
|
get comparator(): Comparator<E>;
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
152
|
+
Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
|
|
153
153
|
|
|
154
154
|
Get the comparator used to order elements.
|
|
155
155
|
|
|
@@ -177,7 +177,7 @@ Comparator function.
|
|
|
177
177
|
get elements(): E[];
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/
|
|
180
|
+
Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
|
|
181
181
|
|
|
182
182
|
Get the backing array of the heap.
|
|
183
183
|
|
|
@@ -205,7 +205,7 @@ Internal elements array.
|
|
|
205
205
|
get leaf(): E | undefined;
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
208
|
+
Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
|
|
209
209
|
|
|
210
210
|
Get the last leaf element.
|
|
211
211
|
|
|
@@ -233,7 +233,7 @@ Last element or undefined.
|
|
|
233
233
|
get size(): number;
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
236
|
+
Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
|
|
237
237
|
|
|
238
238
|
Get the number of elements.
|
|
239
239
|
|
|
@@ -276,7 +276,7 @@ Heap size.
|
|
|
276
276
|
get toElementFn(): ((rawElement) => E) | undefined;
|
|
277
277
|
```
|
|
278
278
|
|
|
279
|
-
Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/
|
|
279
|
+
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)
|
|
280
280
|
|
|
281
281
|
Exposes the current `toElementFn`, if configured.
|
|
282
282
|
|
|
@@ -302,7 +302,7 @@ The converter function or `undefined` when not set.
|
|
|
302
302
|
iterator: IterableIterator<E>;
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/
|
|
305
|
+
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)
|
|
306
306
|
|
|
307
307
|
Returns an iterator over the structure's elements.
|
|
308
308
|
|
|
@@ -336,7 +336,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
336
336
|
add(element): boolean;
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
339
|
+
Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
|
|
340
340
|
|
|
341
341
|
Insert an element.
|
|
342
342
|
|
|
@@ -358,7 +358,7 @@ True.
|
|
|
358
358
|
|
|
359
359
|
#### Remarks
|
|
360
360
|
|
|
361
|
-
Time O(
|
|
361
|
+
Time O(log N) amortized, Space O(1)
|
|
362
362
|
|
|
363
363
|
#### Example
|
|
364
364
|
|
|
@@ -391,7 +391,7 @@ Time O(1) amortized, Space O(1)
|
|
|
391
391
|
addMany(elements): boolean[];
|
|
392
392
|
```
|
|
393
393
|
|
|
394
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
394
|
+
Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
|
|
395
395
|
|
|
396
396
|
Insert many elements from an iterable.
|
|
397
397
|
|
|
@@ -437,7 +437,7 @@ Time O(N log N), Space O(1)
|
|
|
437
437
|
clear(): void;
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
440
|
+
Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
|
|
441
441
|
|
|
442
442
|
Remove all elements.
|
|
443
443
|
|
|
@@ -474,7 +474,7 @@ Time O(1), Space O(1)
|
|
|
474
474
|
clone(): this;
|
|
475
475
|
```
|
|
476
476
|
|
|
477
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
477
|
+
Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
|
|
478
478
|
|
|
479
479
|
Deep clone this heap.
|
|
480
480
|
|
|
@@ -513,7 +513,7 @@ Time O(N), Space O(N)
|
|
|
513
513
|
delete(element): boolean;
|
|
514
514
|
```
|
|
515
515
|
|
|
516
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
516
|
+
Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
|
|
517
517
|
|
|
518
518
|
Delete one occurrence of an element.
|
|
519
519
|
|
|
@@ -552,13 +552,41 @@ Time O(N), Space O(1)
|
|
|
552
552
|
|
|
553
553
|
***
|
|
554
554
|
|
|
555
|
-
### deleteBy()
|
|
555
|
+
### ~~deleteBy()~~
|
|
556
556
|
|
|
557
557
|
```ts
|
|
558
558
|
deleteBy(predicate): boolean;
|
|
559
559
|
```
|
|
560
560
|
|
|
561
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
561
|
+
Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
|
|
562
|
+
|
|
563
|
+
#### Parameters
|
|
564
|
+
|
|
565
|
+
##### predicate
|
|
566
|
+
|
|
567
|
+
(`element`, `index`, `heap`) => `boolean`
|
|
568
|
+
|
|
569
|
+
#### Returns
|
|
570
|
+
|
|
571
|
+
`boolean`
|
|
572
|
+
|
|
573
|
+
#### Deprecated
|
|
574
|
+
|
|
575
|
+
Use `deleteWhere` instead. Will be removed in a future major version.
|
|
576
|
+
|
|
577
|
+
#### Inherited from
|
|
578
|
+
|
|
579
|
+
[`PriorityQueue`](PriorityQueue.md).[`deleteBy`](PriorityQueue.md#deleteby)
|
|
580
|
+
|
|
581
|
+
***
|
|
582
|
+
|
|
583
|
+
### deleteWhere()
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
deleteWhere(predicate): boolean;
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
|
|
562
590
|
|
|
563
591
|
Delete the first element that matches a predicate.
|
|
564
592
|
|
|
@@ -582,7 +610,7 @@ Time O(N), Space O(1)
|
|
|
582
610
|
|
|
583
611
|
#### Inherited from
|
|
584
612
|
|
|
585
|
-
[`PriorityQueue`](PriorityQueue.md).[`
|
|
613
|
+
[`PriorityQueue`](PriorityQueue.md).[`deleteWhere`](PriorityQueue.md#deletewhere)
|
|
586
614
|
|
|
587
615
|
***
|
|
588
616
|
|
|
@@ -592,7 +620,7 @@ Time O(N), Space O(1)
|
|
|
592
620
|
dfs(order?): E[];
|
|
593
621
|
```
|
|
594
622
|
|
|
595
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
623
|
+
Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
|
|
596
624
|
|
|
597
625
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
598
626
|
|
|
@@ -637,7 +665,7 @@ Time O(N), Space O(H)
|
|
|
637
665
|
every(predicate, thisArg?): boolean;
|
|
638
666
|
```
|
|
639
667
|
|
|
640
|
-
Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/
|
|
668
|
+
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)
|
|
641
669
|
|
|
642
670
|
Tests whether all elements satisfy the predicate.
|
|
643
671
|
|
|
@@ -677,7 +705,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
677
705
|
filter(callback, thisArg?): this;
|
|
678
706
|
```
|
|
679
707
|
|
|
680
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
708
|
+
Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
|
|
681
709
|
|
|
682
710
|
Filter elements into a new heap of the same class.
|
|
683
711
|
|
|
@@ -730,7 +758,7 @@ Time O(N log N), Space O(N)
|
|
|
730
758
|
find<S>(predicate, thisArg?): S | undefined;
|
|
731
759
|
```
|
|
732
760
|
|
|
733
|
-
Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/
|
|
761
|
+
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)
|
|
734
762
|
|
|
735
763
|
Finds the first element that satisfies the predicate and returns it.
|
|
736
764
|
|
|
@@ -776,7 +804,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
776
804
|
find(predicate, thisArg?): E | undefined;
|
|
777
805
|
```
|
|
778
806
|
|
|
779
|
-
Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/
|
|
807
|
+
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)
|
|
780
808
|
|
|
781
809
|
Finds the first element that satisfies the predicate and returns it.
|
|
782
810
|
|
|
@@ -818,7 +846,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
818
846
|
fix(): boolean[];
|
|
819
847
|
```
|
|
820
848
|
|
|
821
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
849
|
+
Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
|
|
822
850
|
|
|
823
851
|
Restore heap order bottom-up (heapify in-place).
|
|
824
852
|
|
|
@@ -844,7 +872,7 @@ Time O(N), Space O(1)
|
|
|
844
872
|
forEach(callbackfn, thisArg?): void;
|
|
845
873
|
```
|
|
846
874
|
|
|
847
|
-
Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/
|
|
875
|
+
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)
|
|
848
876
|
|
|
849
877
|
Invokes a callback for each element in iteration order.
|
|
850
878
|
|
|
@@ -884,7 +912,7 @@ Time O(n), Space O(1).
|
|
|
884
912
|
has(element): boolean;
|
|
885
913
|
```
|
|
886
914
|
|
|
887
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
915
|
+
Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
|
|
888
916
|
|
|
889
917
|
Check if an equal element exists in the heap.
|
|
890
918
|
|
|
@@ -929,7 +957,7 @@ Time O(N), Space O(1)
|
|
|
929
957
|
isEmpty(): boolean;
|
|
930
958
|
```
|
|
931
959
|
|
|
932
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
960
|
+
Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
|
|
933
961
|
|
|
934
962
|
Check whether the heap is empty.
|
|
935
963
|
|
|
@@ -970,7 +998,7 @@ map<EM, RM>(
|
|
|
970
998
|
thisArg?): Heap<EM, RM>;
|
|
971
999
|
```
|
|
972
1000
|
|
|
973
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1001
|
+
Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
|
|
974
1002
|
|
|
975
1003
|
Map elements into a new heap of possibly different element type.
|
|
976
1004
|
|
|
@@ -1037,7 +1065,7 @@ Time O(N log N), Space O(N)
|
|
|
1037
1065
|
mapSame(callback, thisArg?): this;
|
|
1038
1066
|
```
|
|
1039
1067
|
|
|
1040
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1068
|
+
Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
|
|
1041
1069
|
|
|
1042
1070
|
Map elements into a new heap of the same element type.
|
|
1043
1071
|
|
|
@@ -1077,7 +1105,7 @@ Time O(N log N), Space O(N)
|
|
|
1077
1105
|
peek(): E | undefined;
|
|
1078
1106
|
```
|
|
1079
1107
|
|
|
1080
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1108
|
+
Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
|
|
1081
1109
|
|
|
1082
1110
|
Get the current top element without removing it.
|
|
1083
1111
|
|
|
@@ -1162,28 +1190,23 @@ Time O(1), Space O(1)
|
|
|
1162
1190
|
|
|
1163
1191
|
***
|
|
1164
1192
|
|
|
1165
|
-
### poll()
|
|
1193
|
+
### ~~poll()~~
|
|
1166
1194
|
|
|
1167
1195
|
```ts
|
|
1168
1196
|
poll(): E | undefined;
|
|
1169
1197
|
```
|
|
1170
1198
|
|
|
1171
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1172
|
-
|
|
1173
|
-
Remove and return the top element.
|
|
1199
|
+
Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
|
|
1174
1200
|
|
|
1175
1201
|
#### Returns
|
|
1176
1202
|
|
|
1177
1203
|
`E` \| `undefined`
|
|
1178
1204
|
|
|
1179
|
-
|
|
1205
|
+
#### Deprecated
|
|
1180
1206
|
|
|
1207
|
+
Use `pop` instead. Will be removed in a future major version.
|
|
1181
1208
|
*
|
|
1182
1209
|
|
|
1183
|
-
#### Remarks
|
|
1184
|
-
|
|
1185
|
-
Time O(log N), Space O(1)
|
|
1186
|
-
|
|
1187
1210
|
#### Example
|
|
1188
1211
|
|
|
1189
1212
|
```ts
|
|
@@ -1219,13 +1242,39 @@ Time O(log N), Space O(1)
|
|
|
1219
1242
|
|
|
1220
1243
|
***
|
|
1221
1244
|
|
|
1245
|
+
### pop()
|
|
1246
|
+
|
|
1247
|
+
```ts
|
|
1248
|
+
pop(): E | undefined;
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
|
|
1252
|
+
|
|
1253
|
+
Remove and return the top element (min or max depending on comparator).
|
|
1254
|
+
|
|
1255
|
+
#### Returns
|
|
1256
|
+
|
|
1257
|
+
`E` \| `undefined`
|
|
1258
|
+
|
|
1259
|
+
The removed top element, or undefined if empty.
|
|
1260
|
+
|
|
1261
|
+
#### Remarks
|
|
1262
|
+
|
|
1263
|
+
Time O(log N) amortized, Space O(1)
|
|
1264
|
+
|
|
1265
|
+
#### Inherited from
|
|
1266
|
+
|
|
1267
|
+
[`PriorityQueue`](PriorityQueue.md).[`pop`](PriorityQueue.md#pop)
|
|
1268
|
+
|
|
1269
|
+
***
|
|
1270
|
+
|
|
1222
1271
|
### print()
|
|
1223
1272
|
|
|
1224
1273
|
```ts
|
|
1225
1274
|
print(): void;
|
|
1226
1275
|
```
|
|
1227
1276
|
|
|
1228
|
-
Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1277
|
+
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)
|
|
1229
1278
|
|
|
1230
1279
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1231
1280
|
|
|
@@ -1283,7 +1332,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1283
1332
|
reduce(callbackfn): E;
|
|
1284
1333
|
```
|
|
1285
1334
|
|
|
1286
|
-
Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1335
|
+
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)
|
|
1287
1336
|
|
|
1288
1337
|
##### Parameters
|
|
1289
1338
|
|
|
@@ -1305,7 +1354,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1305
1354
|
reduce(callbackfn, initialValue): E;
|
|
1306
1355
|
```
|
|
1307
1356
|
|
|
1308
|
-
Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1357
|
+
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)
|
|
1309
1358
|
|
|
1310
1359
|
##### Parameters
|
|
1311
1360
|
|
|
@@ -1331,7 +1380,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1331
1380
|
reduce<U>(callbackfn, initialValue): U;
|
|
1332
1381
|
```
|
|
1333
1382
|
|
|
1334
|
-
Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1383
|
+
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)
|
|
1335
1384
|
|
|
1336
1385
|
##### Type Parameters
|
|
1337
1386
|
|
|
@@ -1359,47 +1408,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1359
1408
|
|
|
1360
1409
|
***
|
|
1361
1410
|
|
|
1362
|
-
### refill()
|
|
1363
|
-
|
|
1364
|
-
```ts
|
|
1365
|
-
refill(elements): boolean[];
|
|
1366
|
-
```
|
|
1367
|
-
|
|
1368
|
-
Defined in: [data-structures/heap/heap.ts:687](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L687)
|
|
1369
|
-
|
|
1370
|
-
Replace the backing array and rebuild the heap.
|
|
1371
|
-
|
|
1372
|
-
#### Parameters
|
|
1373
|
-
|
|
1374
|
-
##### elements
|
|
1375
|
-
|
|
1376
|
-
`Iterable`\<`E`\>
|
|
1377
|
-
|
|
1378
|
-
Iterable used to refill the heap.
|
|
1379
|
-
|
|
1380
|
-
#### Returns
|
|
1381
|
-
|
|
1382
|
-
`boolean`[]
|
|
1383
|
-
|
|
1384
|
-
Array of per-node results from fixing steps.
|
|
1385
|
-
|
|
1386
|
-
#### Remarks
|
|
1387
|
-
|
|
1388
|
-
Time O(N), Space O(N)
|
|
1389
|
-
|
|
1390
|
-
#### Inherited from
|
|
1391
|
-
|
|
1392
|
-
[`PriorityQueue`](PriorityQueue.md).[`refill`](PriorityQueue.md#refill)
|
|
1393
|
-
|
|
1394
|
-
***
|
|
1395
|
-
|
|
1396
1411
|
### setEquality()
|
|
1397
1412
|
|
|
1398
1413
|
```ts
|
|
1399
1414
|
setEquality(equals): this;
|
|
1400
1415
|
```
|
|
1401
1416
|
|
|
1402
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1417
|
+
Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
|
|
1403
1418
|
|
|
1404
1419
|
Set the equality comparator used by has/delete operations.
|
|
1405
1420
|
|
|
@@ -1433,7 +1448,7 @@ Time O(1), Space O(1)
|
|
|
1433
1448
|
some(predicate, thisArg?): boolean;
|
|
1434
1449
|
```
|
|
1435
1450
|
|
|
1436
|
-
Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1451
|
+
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)
|
|
1437
1452
|
|
|
1438
1453
|
Tests whether at least one element satisfies the predicate.
|
|
1439
1454
|
|
|
@@ -1473,7 +1488,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1473
1488
|
sort(): E[];
|
|
1474
1489
|
```
|
|
1475
1490
|
|
|
1476
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1491
|
+
Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
|
|
1477
1492
|
|
|
1478
1493
|
Return all elements in ascending order by repeatedly polling.
|
|
1479
1494
|
|
|
@@ -1510,7 +1525,7 @@ Time O(N log N), Space O(N)
|
|
|
1510
1525
|
toArray(): E[];
|
|
1511
1526
|
```
|
|
1512
1527
|
|
|
1513
|
-
Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1528
|
+
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)
|
|
1514
1529
|
|
|
1515
1530
|
Materializes the elements into a new array.
|
|
1516
1531
|
|
|
@@ -1536,7 +1551,7 @@ Time O(n), Space O(n).
|
|
|
1536
1551
|
toVisual(): E[];
|
|
1537
1552
|
```
|
|
1538
1553
|
|
|
1539
|
-
Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1554
|
+
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)
|
|
1540
1555
|
|
|
1541
1556
|
Returns a representation of the structure suitable for quick visualization.
|
|
1542
1557
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1563,7 +1578,7 @@ Time O(n), Space O(n).
|
|
|
1563
1578
|
values(): IterableIterator<E>;
|
|
1564
1579
|
```
|
|
1565
1580
|
|
|
1566
|
-
Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1581
|
+
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)
|
|
1567
1582
|
|
|
1568
1583
|
Returns an iterator over the values (alias of the default iterator).
|
|
1569
1584
|
|
|
@@ -1592,7 +1607,7 @@ static from<T, R, S>(
|
|
|
1592
1607
|
options?): S;
|
|
1593
1608
|
```
|
|
1594
1609
|
|
|
1595
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1610
|
+
Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
|
|
1596
1611
|
|
|
1597
1612
|
Create a heap of the same class from an iterable.
|
|
1598
1613
|
|
|
@@ -1650,7 +1665,7 @@ Time O(N), Space O(N)
|
|
|
1650
1665
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1651
1666
|
```
|
|
1652
1667
|
|
|
1653
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1668
|
+
Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
|
|
1654
1669
|
|
|
1655
1670
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1656
1671
|
|
|
@@ -1703,7 +1718,7 @@ Time O(N), Space O(N)
|
|
|
1703
1718
|
protected optional _toElementFn?: (rawElement) => E;
|
|
1704
1719
|
```
|
|
1705
1720
|
|
|
1706
|
-
Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1721
|
+
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)
|
|
1707
1722
|
|
|
1708
1723
|
The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
1709
1724
|
|
|
@@ -1733,7 +1748,7 @@ Time O(1), Space O(1).
|
|
|
1733
1748
|
protected _createInstance(options?): this;
|
|
1734
1749
|
```
|
|
1735
1750
|
|
|
1736
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1751
|
+
Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
|
|
1737
1752
|
|
|
1738
1753
|
(Protected) Create an empty instance of the same concrete class.
|
|
1739
1754
|
|
|
@@ -1767,7 +1782,7 @@ Time O(1), Space O(1)
|
|
|
1767
1782
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1768
1783
|
```
|
|
1769
1784
|
|
|
1770
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1785
|
+
Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
|
|
1771
1786
|
|
|
1772
1787
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1773
1788
|
|
|
@@ -1817,7 +1832,7 @@ Time O(N log N), Space O(N)
|
|
|
1817
1832
|
protected _getIterator(): IterableIterator<E>;
|
|
1818
1833
|
```
|
|
1819
1834
|
|
|
1820
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1835
|
+
Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
|
|
1821
1836
|
|
|
1822
1837
|
Internal iterator factory used by the default iterator.
|
|
1823
1838
|
|
|
@@ -1843,7 +1858,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1843
1858
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1844
1859
|
```
|
|
1845
1860
|
|
|
1846
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1861
|
+
Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
|
|
1847
1862
|
|
|
1848
1863
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1849
1864
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: Navigator\<T\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/matrix/navigator.ts:31](https://github.com/zrwusa/data-structure-typed/blob/
|
|
9
|
+
Defined in: [data-structures/matrix/navigator.ts:31](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/matrix/navigator.ts#L31)
|
|
10
10
|
|
|
11
11
|
## Type Parameters
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ Defined in: [data-structures/matrix/navigator.ts:31](https://github.com/zrwusa/d
|
|
|
22
22
|
new Navigator<T>(-): Navigator<T>;
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Defined in: [data-structures/matrix/navigator.ts:43](https://github.com/zrwusa/data-structure-typed/blob/
|
|
25
|
+
Defined in: [data-structures/matrix/navigator.ts:43](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/matrix/navigator.ts#L43)
|
|
26
26
|
|
|
27
27
|
The constructor initializes the Navigator object with the given parameters and sets the current position as visited
|
|
28
28
|
in the matrix.
|
|
@@ -47,7 +47,7 @@ in the matrix.
|
|
|
47
47
|
check(direction): boolean;
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Defined in: [data-structures/matrix/navigator.ts:74](https://github.com/zrwusa/data-structure-typed/blob/
|
|
50
|
+
Defined in: [data-structures/matrix/navigator.ts:74](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/matrix/navigator.ts#L74)
|
|
51
51
|
|
|
52
52
|
The function checks if there is a valid move in the specified direction in a matrix.
|
|
53
53
|
|
|
@@ -74,7 +74,7 @@ a boolean value.
|
|
|
74
74
|
move(direction): void;
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
Defined in: [data-structures/matrix/navigator.ts:104](https://github.com/zrwusa/data-structure-typed/blob/
|
|
77
|
+
Defined in: [data-structures/matrix/navigator.ts:104](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/matrix/navigator.ts#L104)
|
|
78
78
|
|
|
79
79
|
The `move` function updates the current position based on the given direction and updates the matrix accordingly.
|
|
80
80
|
|
|
@@ -99,7 +99,7 @@ It can have one of the following values: 'up', 'right', 'down', or 'left'.
|
|
|
99
99
|
start(): void;
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
Defined in: [data-structures/matrix/navigator.ts:57](https://github.com/zrwusa/data-structure-typed/blob/
|
|
102
|
+
Defined in: [data-structures/matrix/navigator.ts:57](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/matrix/navigator.ts#L57)
|
|
103
103
|
|
|
104
104
|
The "start" function moves the character in its current direction until it encounters an obstacle, then it turns the
|
|
105
105
|
character and repeats the process.
|