tree-set-typed 2.3.0
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/.eslintrc.js +61 -0
- package/.prettierignore +6 -0
- package/.prettierrc.js +16 -0
- package/LICENSE +21 -0
- package/README.md +482 -0
- package/coverage/clover.xml +13 -0
- package/coverage/coverage-final.json +96 -0
- package/coverage/coverage-summary.json +60 -0
- package/coverage/lcov-report/base.css +403 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +119 -0
- package/coverage/lcov-report/index.ts.html +109 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +206 -0
- package/coverage/lcov.info +14 -0
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs-legacy/index.cjs +12 -0
- package/dist/cjs-legacy/index.cjs.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm-legacy/index.mjs +3 -0
- package/dist/esm-legacy/index.mjs.map +1 -0
- package/dist/types/common/index.d.ts +12 -0
- package/dist/types/constants/index.d.ts +4 -0
- package/dist/types/data-structures/base/index.d.ts +2 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +219 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +150 -0
- package/dist/types/data-structures/base/linear-base.d.ts +335 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +236 -0
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +197 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +440 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +807 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +645 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +10 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +312 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -0
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +243 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +333 -0
- package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +332 -0
- package/dist/types/data-structures/graph/index.d.ts +4 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +78 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +347 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +428 -0
- package/dist/types/data-structures/hash/index.d.ts +1 -0
- package/dist/types/data-structures/heap/heap.d.ts +552 -0
- package/dist/types/data-structures/heap/index.d.ts +3 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +32 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +33 -0
- package/dist/types/data-structures/index.d.ts +12 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +437 -0
- package/dist/types/data-structures/linked-list/index.d.ts +3 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +567 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -0
- package/dist/types/data-structures/matrix/index.d.ts +2 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/matrix/navigator.d.ts +55 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/types/data-structures/queue/deque.d.ts +459 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/queue.d.ts +364 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.d.ts +324 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/tree.d.ts +62 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.d.ts +412 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/interfaces/binary-tree.d.ts +60 -0
- package/dist/types/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/types/interfaces/graph.d.ts +21 -0
- package/dist/types/interfaces/heap.d.ts +1 -0
- package/dist/types/interfaces/index.d.ts +8 -0
- package/dist/types/interfaces/navigator.d.ts +1 -0
- package/dist/types/interfaces/priority-queue.d.ts +1 -0
- package/dist/types/interfaces/segment-tree.d.ts +1 -0
- package/dist/types/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/types/types/common.d.ts +15 -0
- package/dist/types/types/data-structures/base/base.d.ts +13 -0
- package/dist/types/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
- package/dist/types/types/data-structures/binary-tree/index.d.ts +9 -0
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
- package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
- package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
- package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
- package/dist/types/types/data-structures/hash/index.d.ts +2 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
- package/dist/types/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/types/data-structures/index.d.ts +12 -0
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/index.d.ts +3 -0
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
- package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
- package/dist/types/types/data-structures/matrix/index.d.ts +2 -0
- package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
- package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
- package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
- package/dist/types/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
- package/dist/types/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
- package/dist/types/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/utils/index.d.ts +2 -0
- package/dist/types/types/utils/utils.d.ts +22 -0
- package/dist/types/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/number.d.ts +14 -0
- package/dist/types/utils/utils.d.ts +209 -0
- package/dist/umd/red-black-tree-typed.js +14578 -0
- package/dist/umd/red-black-tree-typed.js.map +1 -0
- package/dist/umd/red-black-tree-typed.min.js +44 -0
- package/dist/umd/red-black-tree-typed.min.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1383 -0
- package/docs/classes/AVLTree.html +2046 -0
- package/docs/classes/AVLTreeNode.html +263 -0
- package/docs/index.html +523 -0
- package/docs/modules.html +45 -0
- package/jest.config.js +8 -0
- package/package.json +113 -0
- package/src/common/index.ts +23 -0
- package/src/constants/index.ts +4 -0
- package/src/data-structures/base/index.ts +2 -0
- package/src/data-structures/base/iterable-element-base.ts +352 -0
- package/src/data-structures/base/iterable-entry-base.ts +246 -0
- package/src/data-structures/base/linear-base.ts +643 -0
- package/src/data-structures/binary-tree/avl-tree-counter.ts +539 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +438 -0
- package/src/data-structures/binary-tree/avl-tree.ts +840 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +331 -0
- package/src/data-structures/binary-tree/binary-tree.ts +2492 -0
- package/src/data-structures/binary-tree/bst.ts +2024 -0
- package/src/data-structures/binary-tree/index.ts +10 -0
- package/src/data-structures/binary-tree/red-black-tree.ts +767 -0
- package/src/data-structures/binary-tree/segment-tree.ts +324 -0
- package/src/data-structures/binary-tree/tree-counter.ts +575 -0
- package/src/data-structures/binary-tree/tree-multi-map.ts +549 -0
- package/src/data-structures/graph/abstract-graph.ts +1081 -0
- package/src/data-structures/graph/directed-graph.ts +715 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +132 -0
- package/src/data-structures/graph/undirected-graph.ts +626 -0
- package/src/data-structures/hash/hash-map.ts +813 -0
- package/src/data-structures/hash/index.ts +1 -0
- package/src/data-structures/heap/heap.ts +1020 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +47 -0
- package/src/data-structures/heap/min-heap.ts +36 -0
- package/src/data-structures/index.ts +12 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +876 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +1050 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +173 -0
- package/src/data-structures/matrix/index.ts +2 -0
- package/src/data-structures/matrix/matrix.ts +491 -0
- package/src/data-structures/matrix/navigator.ts +124 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +42 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +29 -0
- package/src/data-structures/priority-queue/priority-queue.ts +19 -0
- package/src/data-structures/queue/deque.ts +1001 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +592 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +469 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +115 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +756 -0
- package/src/index.ts +24 -0
- package/src/interfaces/binary-tree.ts +252 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/graph.ts +44 -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/common.ts +25 -0
- package/src/types/data-structures/base/base.ts +34 -0
- package/src/types/data-structures/base/index.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +3 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
- package/src/types/data-structures/binary-tree/bst.ts +19 -0
- package/src/types/data-structures/binary-tree/index.ts +9 -0
- package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -0
- package/src/types/data-structures/graph/abstract-graph.ts +18 -0
- package/src/types/data-structures/graph/directed-graph.ts +2 -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/hash-map.ts +19 -0
- package/src/types/data-structures/hash/index.ts +3 -0
- package/src/types/data-structures/heap/heap.ts +6 -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 +12 -0
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -0
- package/src/types/data-structures/linked-list/index.ts +3 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +2 -0
- package/src/types/data-structures/matrix/matrix.ts +7 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -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 +3 -0
- package/src/types/data-structures/queue/deque.ts +5 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +5 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +3 -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 +3 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils/index.ts +2 -0
- package/src/types/utils/utils.ts +33 -0
- package/src/types/utils/validate-type.ts +35 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/number.ts +22 -0
- package/src/utils/utils.ts +350 -0
- package/test/index.test.ts +111 -0
- package/tsconfig.base.json +23 -0
- package/tsconfig.json +12 -0
- package/tsconfig.test.json +8 -0
- package/tsconfig.types.json +15 -0
- package/tsup.config.js +28 -0
- package/tsup.node.config.js +71 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { MapGraphCoordinate, VertexKey } from '../../types';
|
|
10
|
+
import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
|
|
11
|
+
|
|
12
|
+
export class MapVertex<V = any> extends DirectedVertex<V> {
|
|
13
|
+
lat: number;
|
|
14
|
+
long: number;
|
|
15
|
+
|
|
16
|
+
constructor(key: VertexKey, value: V, lat: number, long: number) {
|
|
17
|
+
super(key, value);
|
|
18
|
+
this.lat = lat;
|
|
19
|
+
this.long = long;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class MapEdge<E = any> extends DirectedEdge<E> {
|
|
24
|
+
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
|
|
25
|
+
super(src, dest, weight, value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Directed graph variant carrying geospatial coordinates.
|
|
31
|
+
* @template V - Vertex value type.
|
|
32
|
+
* @template E - Edge value type.
|
|
33
|
+
* @template VO - Concrete vertex class (MapVertex<V>).
|
|
34
|
+
* @template EO - Concrete edge class (MapEdge<E>).
|
|
35
|
+
* @remarks Time O(1), Space O(1)
|
|
36
|
+
* @example examples will be generated by unit test
|
|
37
|
+
*/
|
|
38
|
+
export class MapGraph<
|
|
39
|
+
V = any,
|
|
40
|
+
E = any,
|
|
41
|
+
VO extends MapVertex<V> = MapVertex<V>,
|
|
42
|
+
EO extends MapEdge<E> = MapEdge<E>
|
|
43
|
+
> extends DirectedGraph<V, E, VO, EO> {
|
|
44
|
+
/**
|
|
45
|
+
* Construct a MapGraph.
|
|
46
|
+
* @param originCoord - Origin coordinate `[lat, long]` used as default.
|
|
47
|
+
* @param bottomRight - Optional bottom-right coordinate for bounding boxes.
|
|
48
|
+
* @remarks Time O(1), Space O(1)
|
|
49
|
+
*/
|
|
50
|
+
constructor(originCoord: MapGraphCoordinate, bottomRight?: MapGraphCoordinate) {
|
|
51
|
+
super();
|
|
52
|
+
this._originCoord = originCoord;
|
|
53
|
+
this._bottomRight = bottomRight;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected _originCoord: MapGraphCoordinate = [0, 0];
|
|
57
|
+
|
|
58
|
+
get originCoord(): MapGraphCoordinate {
|
|
59
|
+
return this._originCoord;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected _bottomRight: MapGraphCoordinate | undefined;
|
|
63
|
+
|
|
64
|
+
get bottomRight(): MapGraphCoordinate | undefined {
|
|
65
|
+
return this._bottomRight;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create a map vertex with optional coordinates.
|
|
70
|
+
* @param key - Vertex identifier.
|
|
71
|
+
* @param value - Optional payload.
|
|
72
|
+
* @param lat - Latitude (defaults to `originCoord[0]`).
|
|
73
|
+
* @param long - Longitude (defaults to `originCoord[1]`).
|
|
74
|
+
* @returns MapVertex instance.
|
|
75
|
+
* @remarks Time O(1), Space O(1)
|
|
76
|
+
*/
|
|
77
|
+
override createVertex(
|
|
78
|
+
key: VertexKey,
|
|
79
|
+
value?: V,
|
|
80
|
+
lat: number = this.originCoord[0],
|
|
81
|
+
long: number = this.originCoord[1]
|
|
82
|
+
): VO {
|
|
83
|
+
return new MapVertex(key, value, lat, long) as VO;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a map edge (directed) with optional weight/value.
|
|
88
|
+
* @param src - Source key.
|
|
89
|
+
* @param dest - Destination key.
|
|
90
|
+
* @param weight - Edge weight.
|
|
91
|
+
* @param value - Edge payload.
|
|
92
|
+
* @returns MapEdge instance.
|
|
93
|
+
* @remarks Time O(1), Space O(1)
|
|
94
|
+
*/
|
|
95
|
+
override createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
|
|
96
|
+
return new MapEdge(src, dest, weight, value) as EO;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Deep clone as the same concrete class.
|
|
101
|
+
* @returns A new graph of the same concrete class (`this` type).
|
|
102
|
+
* @remarks Time O(V + E), Space O(V + E)
|
|
103
|
+
*/
|
|
104
|
+
override clone(): this {
|
|
105
|
+
return super.clone();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Include `originCoord` and `bottomRight` so `clone()/filter()` preserve geospatial settings.
|
|
110
|
+
* @returns Options bag extending super snapshot.
|
|
111
|
+
* @remarks Time O(1), Space O(1)
|
|
112
|
+
*/
|
|
113
|
+
protected override _snapshotOptions(): Record<string, unknown> {
|
|
114
|
+
return { ...(super._snapshotOptions() as any), originCoord: this.originCoord, bottomRight: this.bottomRight };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Re-create a same-species MapGraph instance from snapshot options.
|
|
119
|
+
* @param options - Snapshot options providing `originCoord`/`bottomRight`.
|
|
120
|
+
* @returns Empty MapGraph instance of `this` type.
|
|
121
|
+
* @remarks Time O(1), Space O(1)
|
|
122
|
+
*/
|
|
123
|
+
protected override _createInstance(options?: Partial<Record<string, unknown>>): this {
|
|
124
|
+
const { originCoord, bottomRight } = (options || {}) as {
|
|
125
|
+
originCoord?: [number, number];
|
|
126
|
+
bottomRight?: [number, number] | undefined;
|
|
127
|
+
};
|
|
128
|
+
const oc = (originCoord ?? this.originCoord) as [number, number];
|
|
129
|
+
const br = (bottomRight ?? this.bottomRight) as [number, number] | undefined;
|
|
130
|
+
return new MapGraph<V, E, VO, EO>(oc, br) as this;
|
|
131
|
+
}
|
|
132
|
+
}
|