linked-list-typed 1.38.0 → 1.38.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/dist/data-structures/binary-tree/avl-tree.d.ts +100 -0
- package/dist/data-structures/binary-tree/avl-tree.js +341 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +144 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +261 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +409 -0
- package/dist/data-structures/binary-tree/binary-tree.js +1065 -0
- package/dist/data-structures/binary-tree/bst.d.ts +167 -0
- package/dist/data-structures/binary-tree/bst.js +512 -0
- package/dist/data-structures/binary-tree/index.d.ts +7 -0
- package/dist/data-structures/binary-tree/index.js +23 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +13 -0
- package/dist/data-structures/binary-tree/rb-tree.js +27 -0
- package/dist/data-structures/binary-tree/segment-tree.d.ts +83 -0
- package/dist/data-structures/binary-tree/segment-tree.js +228 -0
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +122 -0
- package/dist/data-structures/binary-tree/tree-multiset.js +351 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +332 -0
- package/dist/data-structures/graph/abstract-graph.js +923 -0
- package/dist/data-structures/graph/directed-graph.d.ts +200 -0
- package/dist/data-structures/graph/directed-graph.js +422 -0
- package/dist/data-structures/graph/index.d.ts +4 -0
- package/dist/data-structures/graph/index.js +20 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +127 -0
- package/dist/data-structures/graph/undirected-graph.js +252 -0
- package/dist/data-structures/hash/coordinate-map.d.ts +45 -0
- package/dist/data-structures/hash/coordinate-map.js +65 -0
- package/dist/data-structures/hash/coordinate-set.d.ts +37 -0
- package/dist/data-structures/hash/coordinate-set.js +55 -0
- package/dist/data-structures/hash/hash-map.d.ts +56 -0
- package/dist/data-structures/hash/hash-map.js +171 -0
- package/dist/data-structures/hash/hash-table.d.ts +106 -0
- package/dist/data-structures/hash/hash-table.js +245 -0
- package/dist/data-structures/hash/index.d.ts +6 -0
- package/dist/data-structures/hash/index.js +22 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -0
- package/dist/data-structures/hash/tree-map.js +6 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -0
- package/dist/data-structures/hash/tree-set.js +6 -0
- package/dist/data-structures/heap/heap.d.ts +224 -0
- package/dist/data-structures/heap/heap.js +497 -0
- package/dist/data-structures/heap/index.d.ts +3 -0
- package/dist/data-structures/heap/index.js +19 -0
- package/dist/data-structures/heap/max-heap.d.ts +12 -0
- package/dist/data-structures/heap/max-heap.js +24 -0
- package/dist/data-structures/heap/min-heap.d.ts +12 -0
- package/dist/data-structures/heap/min-heap.js +24 -0
- package/dist/data-structures/index.d.ts +11 -0
- package/dist/data-structures/index.js +27 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +234 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +583 -0
- package/dist/data-structures/linked-list/index.d.ts +3 -0
- package/dist/data-structures/linked-list/index.js +19 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +157 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +448 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +61 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +142 -0
- package/dist/data-structures/matrix/index.d.ts +4 -0
- package/dist/data-structures/matrix/index.js +20 -0
- package/dist/data-structures/matrix/matrix.d.ts +21 -0
- package/dist/data-structures/matrix/matrix.js +28 -0
- package/dist/data-structures/matrix/matrix2d.d.ts +108 -0
- package/dist/data-structures/matrix/matrix2d.js +203 -0
- package/dist/data-structures/matrix/navigator.d.ts +52 -0
- package/dist/data-structures/matrix/navigator.js +106 -0
- package/dist/data-structures/matrix/vector2d.d.ts +201 -0
- package/dist/data-structures/matrix/vector2d.js +291 -0
- package/dist/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/data-structures/priority-queue/index.js +19 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +24 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +24 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +12 -0
- package/dist/data-structures/priority-queue/priority-queue.js +17 -0
- package/dist/data-structures/queue/deque.d.ts +165 -0
- package/dist/data-structures/queue/deque.js +276 -0
- package/dist/data-structures/queue/index.d.ts +2 -0
- package/dist/data-structures/queue/index.js +18 -0
- package/dist/data-structures/queue/queue.d.ts +107 -0
- package/dist/data-structures/queue/queue.js +170 -0
- package/dist/data-structures/stack/index.d.ts +1 -0
- package/dist/data-structures/stack/index.js +17 -0
- package/dist/data-structures/stack/stack.d.ts +63 -0
- package/dist/data-structures/stack/stack.js +91 -0
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/data-structures/tree/tree.js +58 -0
- package/dist/data-structures/trie/index.d.ts +1 -0
- package/dist/data-structures/trie/index.js +17 -0
- package/dist/data-structures/trie/trie.d.ts +84 -0
- package/dist/data-structures/trie/trie.js +268 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/interfaces/binary-tree.d.ts +7 -0
- package/dist/interfaces/binary-tree.js +2 -0
- package/dist/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/interfaces/doubly-linked-list.js +2 -0
- package/dist/interfaces/graph.d.ts +5 -0
- package/dist/interfaces/graph.js +2 -0
- package/dist/interfaces/heap.d.ts +1 -0
- package/dist/interfaces/heap.js +2 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +24 -0
- package/dist/interfaces/navigator.d.ts +1 -0
- package/dist/interfaces/navigator.js +2 -0
- package/dist/interfaces/priority-queue.d.ts +1 -0
- package/dist/interfaces/priority-queue.js +2 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/segment-tree.js +2 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +31 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
- package/dist/types/data-structures/binary-tree/bst.js +2 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/index.js +22 -0
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
- package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
- package/dist/types/data-structures/graph/abstract-graph.js +2 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/graph/directed-graph.js +9 -0
- package/dist/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/data-structures/graph/index.js +19 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/map-graph.js +2 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/undirected-graph.js +2 -0
- package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-map.js +2 -0
- package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-set.js +2 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-map.js +2 -0
- package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-table.js +2 -0
- package/dist/types/data-structures/hash/index.d.ts +1 -0
- package/dist/types/data-structures/hash/index.js +2 -0
- package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-map.js +2 -0
- package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-set.js +2 -0
- package/dist/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/data-structures/heap/heap.js +2 -0
- package/dist/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/data-structures/heap/index.js +17 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/max-heap.js +2 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/min-heap.js +2 -0
- package/dist/types/data-structures/index.d.ts +11 -0
- package/dist/types/data-structures/index.js +27 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/types/data-structures/linked-list/index.js +18 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
- package/dist/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/types/data-structures/matrix/index.js +17 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix.js +2 -0
- package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix2d.js +2 -0
- package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/data-structures/matrix/navigator.js +2 -0
- package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/vector2d.js +2 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/index.js +19 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/types/data-structures/queue/deque.js +2 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/index.js +18 -0
- package/dist/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/types/data-structures/queue/queue.js +2 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/index.js +17 -0
- package/dist/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.js +2 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/index.js +17 -0
- package/dist/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/data-structures/tree/tree.js +2 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/index.js +17 -0
- package/dist/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.js +2 -0
- package/dist/types/helpers.d.ts +9 -0
- package/dist/types/helpers.js +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/utils.d.ts +20 -0
- package/dist/utils/utils.js +73 -0
- package/package.json +1 -4
- package/src/data-structures/binary-tree/avl-tree.ts +342 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +298 -0
- package/src/data-structures/binary-tree/binary-tree.ts +1141 -0
- package/src/data-structures/binary-tree/bst.ts +529 -0
- package/src/data-structures/binary-tree/index.ts +7 -0
- package/src/data-structures/binary-tree/rb-tree.ts +366 -0
- package/src/data-structures/binary-tree/segment-tree.ts +257 -0
- package/src/data-structures/binary-tree/tree-multiset.ts +374 -0
- package/src/data-structures/graph/abstract-graph.ts +1043 -0
- package/src/data-structures/graph/directed-graph.ts +469 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +134 -0
- package/src/data-structures/graph/undirected-graph.ts +273 -0
- package/src/data-structures/hash/coordinate-map.ts +67 -0
- package/src/data-structures/hash/coordinate-set.ts +56 -0
- package/src/data-structures/hash/hash-map.ts +209 -0
- package/src/data-structures/hash/hash-table.ts +280 -0
- package/src/data-structures/hash/index.ts +6 -0
- package/src/data-structures/hash/tree-map.ts +2 -0
- package/src/data-structures/hash/tree-set.ts +2 -0
- package/src/data-structures/heap/heap.ts +561 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +24 -0
- package/src/data-structures/heap/min-heap.ts +24 -0
- package/src/data-structures/index.ts +11 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
- package/src/data-structures/matrix/index.ts +4 -0
- package/src/data-structures/matrix/matrix.ts +27 -0
- package/src/data-structures/matrix/matrix2d.ts +213 -0
- package/src/data-structures/matrix/navigator.ts +121 -0
- package/src/data-structures/matrix/vector2d.ts +317 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +23 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +23 -0
- package/src/data-structures/priority-queue/priority-queue.ts +16 -0
- package/src/data-structures/queue/deque.ts +298 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +191 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +98 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +67 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +286 -0
- package/src/index.ts +3 -3
- package/src/interfaces/binary-tree.ts +10 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/graph.ts +7 -0
- package/src/interfaces/heap.ts +1 -0
- package/src/interfaces/index.ts +8 -0
- package/src/interfaces/navigator.ts +1 -0
- package/src/interfaces/priority-queue.ts +1 -0
- package/src/interfaces/segment-tree.ts +1 -0
- package/src/interfaces/singly-linked-list.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +35 -0
- package/src/types/data-structures/binary-tree/bst.ts +11 -0
- package/src/types/data-structures/binary-tree/index.ts +6 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
- package/src/types/data-structures/graph/abstract-graph.ts +11 -0
- package/src/types/data-structures/graph/directed-graph.ts +8 -0
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/map-graph.ts +1 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/coordinate-map.ts +1 -0
- package/src/types/data-structures/hash/coordinate-set.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +1 -0
- package/src/types/data-structures/hash/hash-table.ts +1 -0
- package/src/types/data-structures/hash/index.ts +1 -0
- package/src/types/data-structures/hash/tree-map.ts +1 -0
- package/src/types/data-structures/hash/tree-set.ts +1 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +11 -0
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/index.ts +2 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +1 -0
- package/src/types/data-structures/matrix/matrix2d.ts +1 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -0
- package/src/types/data-structures/matrix/vector2d.ts +1 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/data-structures/queue/deque.ts +1 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +1 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +1 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +1 -0
- package/src/types/helpers.ts +13 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils/index.ts +2 -0
- package/src/types/utils/utils.ts +6 -0
- package/src/types/utils/validate-type.ts +35 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './trie';
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
|
|
11
|
+
* and a flag indicating whether it's the end of a word.
|
|
12
|
+
*/
|
|
13
|
+
export class TrieNode {
|
|
14
|
+
constructor(key: string) {
|
|
15
|
+
this._key = key;
|
|
16
|
+
this._isEnd = false;
|
|
17
|
+
this._children = new Map<string, TrieNode>();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private _key;
|
|
21
|
+
|
|
22
|
+
get key(): string {
|
|
23
|
+
return this._key;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set key(v: string) {
|
|
27
|
+
this._key = v;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected _children: Map<string, TrieNode>;
|
|
31
|
+
|
|
32
|
+
get children(): Map<string, TrieNode> {
|
|
33
|
+
return this._children;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set children(v: Map<string, TrieNode>) {
|
|
37
|
+
this._children = v;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected _isEnd: boolean;
|
|
41
|
+
|
|
42
|
+
get isEnd(): boolean {
|
|
43
|
+
return this._isEnd;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
set isEnd(v: boolean) {
|
|
47
|
+
this._isEnd = v;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Trie represents a Trie data structure. It provides basic Trie operations and additional methods.
|
|
53
|
+
*/
|
|
54
|
+
export class Trie {
|
|
55
|
+
private readonly _caseSensitive: boolean;
|
|
56
|
+
|
|
57
|
+
constructor(words?: string[], caseSensitive = true) {
|
|
58
|
+
this._root = new TrieNode('');
|
|
59
|
+
this._caseSensitive = caseSensitive;
|
|
60
|
+
if (words) {
|
|
61
|
+
for (const i of words) {
|
|
62
|
+
this.add(i);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected _root: TrieNode;
|
|
68
|
+
|
|
69
|
+
get root() {
|
|
70
|
+
return this._root;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set root(v: TrieNode) {
|
|
74
|
+
this._root = v;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Add a word to the Trie structure.
|
|
79
|
+
* @param {string} word - The word to add.
|
|
80
|
+
* @returns {boolean} True if the word was successfully added.
|
|
81
|
+
*/
|
|
82
|
+
add(word: string): boolean {
|
|
83
|
+
word = this._caseProcess(word);
|
|
84
|
+
let cur = this.root;
|
|
85
|
+
for (const c of word) {
|
|
86
|
+
let nodeC = cur.children.get(c);
|
|
87
|
+
if (!nodeC) {
|
|
88
|
+
nodeC = new TrieNode(c);
|
|
89
|
+
cur.children.set(c, nodeC);
|
|
90
|
+
}
|
|
91
|
+
cur = nodeC;
|
|
92
|
+
}
|
|
93
|
+
cur.isEnd = true;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if the Trie contains a given word.
|
|
99
|
+
* @param {string} word - The word to check for.
|
|
100
|
+
* @returns {boolean} True if the word is present in the Trie.
|
|
101
|
+
*/
|
|
102
|
+
has(word: string): boolean {
|
|
103
|
+
word = this._caseProcess(word);
|
|
104
|
+
let cur = this.root;
|
|
105
|
+
for (const c of word) {
|
|
106
|
+
const nodeC = cur.children.get(c);
|
|
107
|
+
if (!nodeC) return false;
|
|
108
|
+
cur = nodeC;
|
|
109
|
+
}
|
|
110
|
+
return cur.isEnd;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Remove a word from the Trie structure.
|
|
115
|
+
* @param{string} word - The word to delete.
|
|
116
|
+
* @returns {boolean} True if the word was successfully removed.
|
|
117
|
+
*/
|
|
118
|
+
delete(word: string) {
|
|
119
|
+
word = this._caseProcess(word);
|
|
120
|
+
let isDeleted = false;
|
|
121
|
+
const dfs = (cur: TrieNode, i: number): boolean => {
|
|
122
|
+
const char = word[i];
|
|
123
|
+
const child = cur.children.get(char);
|
|
124
|
+
if (child) {
|
|
125
|
+
if (i === word.length - 1) {
|
|
126
|
+
if (child.isEnd) {
|
|
127
|
+
if (child.children.size > 0) {
|
|
128
|
+
child.isEnd = false;
|
|
129
|
+
} else {
|
|
130
|
+
cur.children.delete(char);
|
|
131
|
+
}
|
|
132
|
+
isDeleted = true;
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const res = dfs(child, i + 1);
|
|
138
|
+
if (res && !cur.isEnd && child.children.size === 0) {
|
|
139
|
+
cur.children.delete(char);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
dfs(this.root, 0);
|
|
148
|
+
return isDeleted;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
getHeight() {
|
|
152
|
+
const beginRoot = this.root;
|
|
153
|
+
let maxDepth = 0;
|
|
154
|
+
if (beginRoot) {
|
|
155
|
+
const bfs = (node: TrieNode, level: number) => {
|
|
156
|
+
if (level > maxDepth) {
|
|
157
|
+
maxDepth = level;
|
|
158
|
+
}
|
|
159
|
+
const {children} = node;
|
|
160
|
+
if (children) {
|
|
161
|
+
for (const child of children.entries()) {
|
|
162
|
+
bfs(child[1], level + 1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
bfs(beginRoot, 0);
|
|
167
|
+
}
|
|
168
|
+
return maxDepth;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// --- start additional methods ---
|
|
172
|
+
/**
|
|
173
|
+
* Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
|
|
174
|
+
* @param {string} input - The input string to check.
|
|
175
|
+
* @returns {boolean} True if it's an absolute prefix in the Trie.
|
|
176
|
+
*/
|
|
177
|
+
hasPurePrefix(input: string): boolean {
|
|
178
|
+
input = this._caseProcess(input);
|
|
179
|
+
let cur = this.root;
|
|
180
|
+
for (const c of input) {
|
|
181
|
+
const nodeC = cur.children.get(c);
|
|
182
|
+
if (!nodeC) return false;
|
|
183
|
+
cur = nodeC;
|
|
184
|
+
}
|
|
185
|
+
return !cur.isEnd;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
|
|
190
|
+
* @param {string} input - The input string representing the prefix to check.
|
|
191
|
+
* @returns {boolean} True if it's a prefix in the Trie.
|
|
192
|
+
*/
|
|
193
|
+
hasPrefix(input: string): boolean {
|
|
194
|
+
input = this._caseProcess(input);
|
|
195
|
+
let cur = this.root;
|
|
196
|
+
for (const c of input) {
|
|
197
|
+
const nodeC = cur.children.get(c);
|
|
198
|
+
if (!nodeC) return false;
|
|
199
|
+
cur = nodeC;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
|
|
206
|
+
* @param {string} input - The input string representing the common prefix to check for.
|
|
207
|
+
* @returns {boolean} True if it's a common prefix in the Trie.
|
|
208
|
+
*/
|
|
209
|
+
hasCommonPrefix(input: string): boolean {
|
|
210
|
+
input = this._caseProcess(input);
|
|
211
|
+
let commonPre = '';
|
|
212
|
+
const dfs = (cur: TrieNode) => {
|
|
213
|
+
commonPre += cur.key;
|
|
214
|
+
if (commonPre === input) return;
|
|
215
|
+
if (cur.isEnd) return;
|
|
216
|
+
if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);
|
|
217
|
+
else return;
|
|
218
|
+
};
|
|
219
|
+
dfs(this.root);
|
|
220
|
+
return commonPre === input;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Get the longest common prefix among all the words stored in the Trie.
|
|
225
|
+
* @returns {string} The longest common prefix found in the Trie.
|
|
226
|
+
*/
|
|
227
|
+
getLongestCommonPrefix(): string {
|
|
228
|
+
let commonPre = '';
|
|
229
|
+
const dfs = (cur: TrieNode) => {
|
|
230
|
+
commonPre += cur.key;
|
|
231
|
+
if (cur.isEnd) return;
|
|
232
|
+
if (cur && cur.children && cur.children.size === 1) dfs(Array.from(cur.children.values())[0]);
|
|
233
|
+
else return;
|
|
234
|
+
};
|
|
235
|
+
dfs(this.root);
|
|
236
|
+
return commonPre;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
|
|
241
|
+
* @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
|
|
242
|
+
* trie. It is an optional parameter, so if no prefix is provided, it will default to an empty string.
|
|
243
|
+
* @param {number} max - The max count of words will be found
|
|
244
|
+
* @returns {string[]} an array of strings.
|
|
245
|
+
*/
|
|
246
|
+
getWords(prefix = '', max = Number.MAX_SAFE_INTEGER): string[] {
|
|
247
|
+
prefix = this._caseProcess(prefix);
|
|
248
|
+
const words: string[] = [];
|
|
249
|
+
let found = 0;
|
|
250
|
+
|
|
251
|
+
function dfs(node: TrieNode, word: string) {
|
|
252
|
+
for (const char of node.children.keys()) {
|
|
253
|
+
const charNode = node.children.get(char);
|
|
254
|
+
if (charNode !== undefined) {
|
|
255
|
+
dfs(charNode, word.concat(char));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (node.isEnd) {
|
|
259
|
+
if (found > max - 1) return;
|
|
260
|
+
words.push(word);
|
|
261
|
+
found++;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
let startNode = this.root;
|
|
266
|
+
|
|
267
|
+
if (prefix) {
|
|
268
|
+
for (const c of prefix) {
|
|
269
|
+
const nodeC = startNode.children.get(c);
|
|
270
|
+
if (nodeC) startNode = nodeC;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (startNode !== this.root) dfs(startNode, prefix);
|
|
274
|
+
|
|
275
|
+
return words;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private _caseProcess(str: string) {
|
|
279
|
+
if (!this._caseSensitive) {
|
|
280
|
+
str = str.toLowerCase(); // Convert str to lowercase if case-insensitive
|
|
281
|
+
}
|
|
282
|
+
return str;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// --- end additional methods ---
|
|
286
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
// export { DoublyLinkedListNode, DoublyLinkedList, SinglyLinkedListNode, SinglyLinkedList } from 'data-structure-typed';
|
|
9
|
-
export * from 'data-
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
9
|
+
export * from './data-structures/linked-list';
|
|
10
|
+
export * from './types/data-structures/linked-list';
|
|
11
|
+
export * from './types/helpers';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {BinaryTreeNode} from '../data-structures';
|
|
2
|
+
import {BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../types';
|
|
3
|
+
|
|
4
|
+
export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> {
|
|
5
|
+
createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
|
|
6
|
+
|
|
7
|
+
add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
|
|
8
|
+
|
|
9
|
+
delete(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {AVLTreeNode} from '../../../data-structures';
|
|
2
|
+
import {BSTOptions} from './bst';
|
|
3
|
+
|
|
4
|
+
export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
|
+
export type AVLTreeOptions = BSTOptions & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {BinaryTreeNode} from '../../../data-structures';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enum representing different loop types.
|
|
5
|
+
*
|
|
6
|
+
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
7
|
+
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum IterationType {
|
|
11
|
+
ITERATIVE = 'ITERATIVE',
|
|
12
|
+
RECURSIVE = 'RECURSIVE'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum FamilyPosition {
|
|
16
|
+
ROOT = 'ROOT',
|
|
17
|
+
LEFT = 'LEFT',
|
|
18
|
+
RIGHT = 'RIGHT',
|
|
19
|
+
ROOT_LEFT = 'ROOT_LEFT',
|
|
20
|
+
ROOT_RIGHT = 'ROOT_RIGHT',
|
|
21
|
+
ISOLATED = 'ISOLATED',
|
|
22
|
+
MAL_NODE = 'MAL_NODE'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type BinaryTreeNodeKey = number;
|
|
26
|
+
|
|
27
|
+
export type BFSCallback<N> = (node: N, level?: number) => any;
|
|
28
|
+
|
|
29
|
+
export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;
|
|
30
|
+
|
|
31
|
+
export type BinaryTreeDeletedResult<N> = { deleted: N | null | undefined; needBalanced: N | null };
|
|
32
|
+
|
|
33
|
+
export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
34
|
+
|
|
35
|
+
export type BinaryTreeOptions = { iterationType?: IterationType }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {BSTNode} from '../../../data-structures';
|
|
2
|
+
import type {BinaryTreeNodeKey, BinaryTreeOptions} from './binary-tree';
|
|
3
|
+
|
|
4
|
+
export type BSTComparator = (a: BinaryTreeNodeKey, b: BinaryTreeNodeKey) => number;
|
|
5
|
+
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
8
|
+
|
|
9
|
+
export type BSTOptions = BinaryTreeOptions & {
|
|
10
|
+
comparator?: BSTComparator,
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {BinaryTreeOptions} from './binary-tree';
|
|
2
|
+
import {RBTreeNode} from '../../../data-structures';
|
|
3
|
+
|
|
4
|
+
export enum RBColor { RED = 'RED', BLACK = 'BLACK'}
|
|
5
|
+
|
|
6
|
+
export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
7
|
+
|
|
8
|
+
export type RBTreeOptions = BinaryTreeOptions & {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SegmentTreeNodeVal = number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {TreeMultisetNode} from '../../../data-structures';
|
|
2
|
+
import {AVLTreeOptions} from './avl-tree';
|
|
3
|
+
|
|
4
|
+
export type TreeMultisetNodeNested<T> = TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, TreeMultisetNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
|
+
|
|
6
|
+
export type TreeMultisetOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeByKey'> & {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MapGraphCoordinate = [number, number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HashFunction<K> = (key: K) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './heap';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './binary-tree';
|
|
2
|
+
export * from './graph';
|
|
3
|
+
export * from './linked-list';
|
|
4
|
+
export * from './heap';
|
|
5
|
+
export * from './matrix';
|
|
6
|
+
export * from './hash';
|
|
7
|
+
export * from './priority-queue';
|
|
8
|
+
export * from './queue';
|
|
9
|
+
export * from './stack';
|
|
10
|
+
export * from './tree';
|
|
11
|
+
export * from './trie';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigator';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Direction = 'up' | 'right' | 'down' | 'left';
|
|
2
|
+
|
|
3
|
+
export type Turning = { [key in Direction]: Direction };
|
|
4
|
+
|
|
5
|
+
export type NavigatorParams<T = any> = {
|
|
6
|
+
matrix: T[][];
|
|
7
|
+
turning: Turning;
|
|
8
|
+
onMove: (cur: [number, number]) => void;
|
|
9
|
+
init: {
|
|
10
|
+
cur: [number, number];
|
|
11
|
+
charDir: Direction;
|
|
12
|
+
VISITED: T;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stack';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './trie';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Comparator<T> = (a: T, b: T) => number;
|
|
2
|
+
|
|
3
|
+
export type DFSOrderPattern = 'pre' | 'in' | 'post';
|
|
4
|
+
|
|
5
|
+
export type MapCallback<N> = (node: N) => any;
|
|
6
|
+
|
|
7
|
+
export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;
|
|
8
|
+
|
|
9
|
+
export enum CP {
|
|
10
|
+
lt = 'lt',
|
|
11
|
+
eq = 'eq',
|
|
12
|
+
gt = 'gt'
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
2
|
+
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
|
|
3
|
+
export type TrlFn = (...args: any[]) => any;
|
|
4
|
+
export type TrlAsyncFn = (...args: any[]) => any;
|
|
5
|
+
|
|
6
|
+
export type SpecifyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|