data-structure-typed 2.5.1 → 2.5.2
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/README.md +75 -17
- package/dist/cjs/binary-tree.cjs +2723 -139
- package/dist/cjs/graph.cjs +192 -6
- package/dist/cjs/hash.cjs +63 -15
- package/dist/cjs/heap.cjs +93 -31
- package/dist/cjs/index.cjs +3514 -379
- package/dist/cjs/linked-list.cjs +237 -31
- package/dist/cjs/matrix.cjs +47 -9
- package/dist/cjs/priority-queue.cjs +92 -30
- package/dist/cjs/queue.cjs +176 -2
- package/dist/cjs/stack.cjs +48 -2
- package/dist/cjs/trie.cjs +78 -28
- package/dist/cjs-legacy/binary-tree.cjs +2725 -136
- package/dist/cjs-legacy/graph.cjs +192 -6
- package/dist/cjs-legacy/hash.cjs +63 -15
- package/dist/cjs-legacy/heap.cjs +93 -31
- package/dist/cjs-legacy/index.cjs +3389 -249
- package/dist/cjs-legacy/linked-list.cjs +237 -31
- package/dist/cjs-legacy/matrix.cjs +47 -9
- package/dist/cjs-legacy/priority-queue.cjs +92 -30
- package/dist/cjs-legacy/queue.cjs +176 -2
- package/dist/cjs-legacy/stack.cjs +48 -2
- package/dist/cjs-legacy/trie.cjs +78 -28
- package/dist/esm/binary-tree.mjs +2723 -139
- package/dist/esm/graph.mjs +192 -6
- package/dist/esm/hash.mjs +63 -15
- package/dist/esm/heap.mjs +93 -31
- package/dist/esm/index.mjs +3514 -380
- package/dist/esm/linked-list.mjs +237 -31
- package/dist/esm/matrix.mjs +47 -9
- package/dist/esm/priority-queue.mjs +92 -30
- package/dist/esm/queue.mjs +176 -2
- package/dist/esm/stack.mjs +48 -2
- package/dist/esm/trie.mjs +78 -28
- package/dist/esm-legacy/binary-tree.mjs +2725 -136
- package/dist/esm-legacy/graph.mjs +192 -6
- package/dist/esm-legacy/hash.mjs +63 -15
- package/dist/esm-legacy/heap.mjs +93 -31
- package/dist/esm-legacy/index.mjs +3389 -250
- package/dist/esm-legacy/linked-list.mjs +237 -31
- package/dist/esm-legacy/matrix.mjs +47 -9
- package/dist/esm-legacy/priority-queue.mjs +92 -30
- package/dist/esm-legacy/queue.mjs +176 -2
- package/dist/esm-legacy/stack.mjs +48 -2
- package/dist/esm-legacy/trie.mjs +78 -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 +48 -0
- 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 +102 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +195 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +76 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +528 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +531 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +435 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +505 -0
- 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 +44 -0
- package/dist/types/data-structures/heap/heap.d.ts +56 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +68 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +60 -0
- 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 +60 -0
- package/dist/types/data-structures/queue/queue.d.ts +48 -0
- package/dist/types/data-structures/stack/stack.d.ts +40 -0
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- 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 +3404 -265
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +650 -136
- 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 +591 -129
- 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 +107 -107
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- 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 +47 -47
- package/docs-site-docusaurus/docs/api/classes/Heap.md +45 -45
- 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 +49 -49
- 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 +45 -45
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Queue.md +60 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +660 -146
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +78 -78
- 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 +39 -39
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +165 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +161 -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 +2 -0
- package/docs-site-docusaurus/docs/guide/concepts.md +32 -1
- package/docs-site-docusaurus/docs/guide/faq.md +180 -0
- package/docs-site-docusaurus/docs/guide/guides.md +40 -54
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +2 -0
- package/docs-site-docusaurus/docs/guide/overview.md +7 -0
- 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 +51 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/llms.txt +37 -0
- package/package.json +64 -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 +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +38 -2
- 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
|
@@ -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/8292cb978daf85ebe846186c7c7572aece04fb7b/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/8292cb978daf85ebe846186c7c7572aece04fb7b/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:1184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1184)
|
|
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/8292cb978daf85ebe846186c7c7572aece04fb7b/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:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L244)
|
|
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:234](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L234)
|
|
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:
|
|
279
|
+
Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/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:
|
|
305
|
+
Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/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:338](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L338)
|
|
340
340
|
|
|
341
341
|
Insert an element.
|
|
342
342
|
|
|
@@ -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:388](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L388)
|
|
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:676](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L676)
|
|
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:1020](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1020)
|
|
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:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L779)
|
|
517
517
|
|
|
518
518
|
Delete one occurrence of an element.
|
|
519
519
|
|
|
@@ -558,7 +558,7 @@ Time O(N), Space O(1)
|
|
|
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:807](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L807)
|
|
562
562
|
|
|
563
563
|
Delete the first element that matches a predicate.
|
|
564
564
|
|
|
@@ -592,7 +592,7 @@ Time O(N), Space O(1)
|
|
|
592
592
|
dfs(order?): E[];
|
|
593
593
|
```
|
|
594
594
|
|
|
595
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
595
|
+
Defined in: [data-structures/heap/heap.ts:878](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L878)
|
|
596
596
|
|
|
597
597
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
598
598
|
|
|
@@ -637,7 +637,7 @@ Time O(N), Space O(H)
|
|
|
637
637
|
every(predicate, thisArg?): boolean;
|
|
638
638
|
```
|
|
639
639
|
|
|
640
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
640
|
+
Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L87)
|
|
641
641
|
|
|
642
642
|
Tests whether all elements satisfy the predicate.
|
|
643
643
|
|
|
@@ -677,7 +677,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
677
677
|
filter(callback, thisArg?): this;
|
|
678
678
|
```
|
|
679
679
|
|
|
680
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
680
|
+
Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1072)
|
|
681
681
|
|
|
682
682
|
Filter elements into a new heap of the same class.
|
|
683
683
|
|
|
@@ -730,7 +730,7 @@ Time O(N log N), Space O(N)
|
|
|
730
730
|
find<S>(predicate, thisArg?): S | undefined;
|
|
731
731
|
```
|
|
732
732
|
|
|
733
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
733
|
+
Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L163)
|
|
734
734
|
|
|
735
735
|
Finds the first element that satisfies the predicate and returns it.
|
|
736
736
|
|
|
@@ -776,7 +776,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
776
776
|
find(predicate, thisArg?): E | undefined;
|
|
777
777
|
```
|
|
778
778
|
|
|
779
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
779
|
+
Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L164)
|
|
780
780
|
|
|
781
781
|
Finds the first element that satisfies the predicate and returns it.
|
|
782
782
|
|
|
@@ -818,7 +818,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
818
818
|
fix(): boolean[];
|
|
819
819
|
```
|
|
820
820
|
|
|
821
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
821
|
+
Defined in: [data-structures/heap/heap.ts:909](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L909)
|
|
822
822
|
|
|
823
823
|
Restore heap order bottom-up (heapify in-place).
|
|
824
824
|
|
|
@@ -844,7 +844,7 @@ Time O(N), Space O(1)
|
|
|
844
844
|
forEach(callbackfn, thisArg?): void;
|
|
845
845
|
```
|
|
846
846
|
|
|
847
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
847
|
+
Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L133)
|
|
848
848
|
|
|
849
849
|
Invokes a callback for each element in iteration order.
|
|
850
850
|
|
|
@@ -884,7 +884,7 @@ Time O(n), Space O(1).
|
|
|
884
884
|
has(element): boolean;
|
|
885
885
|
```
|
|
886
886
|
|
|
887
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
887
|
+
Defined in: [data-structures/heap/heap.ts:730](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L730)
|
|
888
888
|
|
|
889
889
|
Check if an equal element exists in the heap.
|
|
890
890
|
|
|
@@ -929,7 +929,7 @@ Time O(N), Space O(1)
|
|
|
929
929
|
isEmpty(): boolean;
|
|
930
930
|
```
|
|
931
931
|
|
|
932
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
932
|
+
Defined in: [data-structures/heap/heap.ts:628](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L628)
|
|
933
933
|
|
|
934
934
|
Check whether the heap is empty.
|
|
935
935
|
|
|
@@ -970,7 +970,7 @@ map<EM, RM>(
|
|
|
970
970
|
thisArg?): Heap<EM, RM>;
|
|
971
971
|
```
|
|
972
972
|
|
|
973
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
973
|
+
Defined in: [data-structures/heap/heap.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1133)
|
|
974
974
|
|
|
975
975
|
Map elements into a new heap of possibly different element type.
|
|
976
976
|
|
|
@@ -1037,7 +1037,7 @@ Time O(N log N), Space O(N)
|
|
|
1037
1037
|
mapSame(callback, thisArg?): this;
|
|
1038
1038
|
```
|
|
1039
1039
|
|
|
1040
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1040
|
+
Defined in: [data-structures/heap/heap.ts:1157](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1157)
|
|
1041
1041
|
|
|
1042
1042
|
Map elements into a new heap of the same element type.
|
|
1043
1043
|
|
|
@@ -1077,7 +1077,7 @@ Time O(N log N), Space O(N)
|
|
|
1077
1077
|
peek(): E | undefined;
|
|
1078
1078
|
```
|
|
1079
1079
|
|
|
1080
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1080
|
+
Defined in: [data-structures/heap/heap.ts:579](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L579)
|
|
1081
1081
|
|
|
1082
1082
|
Get the current top element without removing it.
|
|
1083
1083
|
|
|
@@ -1168,7 +1168,7 @@ Time O(1), Space O(1)
|
|
|
1168
1168
|
poll(): E | undefined;
|
|
1169
1169
|
```
|
|
1170
1170
|
|
|
1171
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1171
|
+
Defined in: [data-structures/heap/heap.ts:468](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L468)
|
|
1172
1172
|
|
|
1173
1173
|
Remove and return the top element.
|
|
1174
1174
|
|
|
@@ -1225,7 +1225,7 @@ Time O(log N), Space O(1)
|
|
|
1225
1225
|
print(): void;
|
|
1226
1226
|
```
|
|
1227
1227
|
|
|
1228
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1228
|
+
Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L269)
|
|
1229
1229
|
|
|
1230
1230
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1231
1231
|
|
|
@@ -1283,7 +1283,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1283
1283
|
reduce(callbackfn): E;
|
|
1284
1284
|
```
|
|
1285
1285
|
|
|
1286
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1286
|
+
Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L194)
|
|
1287
1287
|
|
|
1288
1288
|
##### Parameters
|
|
1289
1289
|
|
|
@@ -1305,7 +1305,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:193](https://github.c
|
|
|
1305
1305
|
reduce(callbackfn, initialValue): E;
|
|
1306
1306
|
```
|
|
1307
1307
|
|
|
1308
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1308
|
+
Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L195)
|
|
1309
1309
|
|
|
1310
1310
|
##### Parameters
|
|
1311
1311
|
|
|
@@ -1331,7 +1331,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1331
1331
|
reduce<U>(callbackfn, initialValue): U;
|
|
1332
1332
|
```
|
|
1333
1333
|
|
|
1334
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1334
|
+
Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L196)
|
|
1335
1335
|
|
|
1336
1336
|
##### Type Parameters
|
|
1337
1337
|
|
|
@@ -1365,7 +1365,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1365
1365
|
refill(elements): boolean[];
|
|
1366
1366
|
```
|
|
1367
1367
|
|
|
1368
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
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
1369
|
|
|
1370
1370
|
Replace the backing array and rebuild the heap.
|
|
1371
1371
|
|
|
@@ -1399,7 +1399,7 @@ Time O(N), Space O(N)
|
|
|
1399
1399
|
setEquality(equals): this;
|
|
1400
1400
|
```
|
|
1401
1401
|
|
|
1402
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1402
|
+
Defined in: [data-structures/heap/heap.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L835)
|
|
1403
1403
|
|
|
1404
1404
|
Set the equality comparator used by has/delete operations.
|
|
1405
1405
|
|
|
@@ -1433,7 +1433,7 @@ Time O(1), Space O(1)
|
|
|
1433
1433
|
some(predicate, thisArg?): boolean;
|
|
1434
1434
|
```
|
|
1435
1435
|
|
|
1436
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1436
|
+
Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L110)
|
|
1437
1437
|
|
|
1438
1438
|
Tests whether at least one element satisfies the predicate.
|
|
1439
1439
|
|
|
@@ -1473,7 +1473,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1473
1473
|
sort(): E[];
|
|
1474
1474
|
```
|
|
1475
1475
|
|
|
1476
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1476
|
+
Defined in: [data-structures/heap/heap.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L963)
|
|
1477
1477
|
|
|
1478
1478
|
Return all elements in ascending order by repeatedly polling.
|
|
1479
1479
|
|
|
@@ -1510,7 +1510,7 @@ Time O(N log N), Space O(N)
|
|
|
1510
1510
|
toArray(): E[];
|
|
1511
1511
|
```
|
|
1512
1512
|
|
|
1513
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1513
|
+
Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L246)
|
|
1514
1514
|
|
|
1515
1515
|
Materializes the elements into a new array.
|
|
1516
1516
|
|
|
@@ -1536,7 +1536,7 @@ Time O(n), Space O(n).
|
|
|
1536
1536
|
toVisual(): E[];
|
|
1537
1537
|
```
|
|
1538
1538
|
|
|
1539
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1539
|
+
Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L258)
|
|
1540
1540
|
|
|
1541
1541
|
Returns a representation of the structure suitable for quick visualization.
|
|
1542
1542
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1563,7 +1563,7 @@ Time O(n), Space O(n).
|
|
|
1563
1563
|
values(): IterableIterator<E>;
|
|
1564
1564
|
```
|
|
1565
1565
|
|
|
1566
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1566
|
+
Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L72)
|
|
1567
1567
|
|
|
1568
1568
|
Returns an iterator over the values (alias of the default iterator).
|
|
1569
1569
|
|
|
@@ -1592,7 +1592,7 @@ static from<T, R, S>(
|
|
|
1592
1592
|
options?): S;
|
|
1593
1593
|
```
|
|
1594
1594
|
|
|
1595
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1595
|
+
Defined in: [data-structures/heap/heap.ts:259](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L259)
|
|
1596
1596
|
|
|
1597
1597
|
Create a heap of the same class from an iterable.
|
|
1598
1598
|
|
|
@@ -1650,7 +1650,7 @@ Time O(N), Space O(N)
|
|
|
1650
1650
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1651
1651
|
```
|
|
1652
1652
|
|
|
1653
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1653
|
+
Defined in: [data-structures/heap/heap.ts:277](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L277)
|
|
1654
1654
|
|
|
1655
1655
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1656
1656
|
|
|
@@ -1703,7 +1703,7 @@ Time O(N), Space O(N)
|
|
|
1703
1703
|
protected optional _toElementFn?: (rawElement) => E;
|
|
1704
1704
|
```
|
|
1705
1705
|
|
|
1706
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1706
|
+
Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L39)
|
|
1707
1707
|
|
|
1708
1708
|
The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
1709
1709
|
|
|
@@ -1733,7 +1733,7 @@ Time O(1), Space O(1).
|
|
|
1733
1733
|
protected _createInstance(options?): this;
|
|
1734
1734
|
```
|
|
1735
1735
|
|
|
1736
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1736
|
+
Defined in: [data-structures/heap/heap.ts:1230](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1230)
|
|
1737
1737
|
|
|
1738
1738
|
(Protected) Create an empty instance of the same concrete class.
|
|
1739
1739
|
|
|
@@ -1767,7 +1767,7 @@ Time O(1), Space O(1)
|
|
|
1767
1767
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1768
1768
|
```
|
|
1769
1769
|
|
|
1770
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1770
|
+
Defined in: [data-structures/heap/heap.ts:1248](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1248)
|
|
1771
1771
|
|
|
1772
1772
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1773
1773
|
|
|
@@ -1817,7 +1817,7 @@ Time O(N log N), Space O(N)
|
|
|
1817
1817
|
protected _getIterator(): IterableIterator<E>;
|
|
1818
1818
|
```
|
|
1819
1819
|
|
|
1820
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1820
|
+
Defined in: [data-structures/heap/heap.ts:1188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1188)
|
|
1821
1821
|
|
|
1822
1822
|
Internal iterator factory used by the default iterator.
|
|
1823
1823
|
|
|
@@ -1843,7 +1843,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1843
1843
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1844
1844
|
```
|
|
1845
1845
|
|
|
1846
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1846
|
+
Defined in: [data-structures/heap/heap.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1268)
|
|
1847
1847
|
|
|
1848
1848
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1849
1849
|
|
|
@@ -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/8292cb978daf85ebe846186c7c7572aece04fb7b/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/8292cb978daf85ebe846186c7c7572aece04fb7b/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/8292cb978daf85ebe846186c7c7572aece04fb7b/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/8292cb978daf85ebe846186c7c7572aece04fb7b/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/8292cb978daf85ebe846186c7c7572aece04fb7b/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.
|