data-structure-typed 1.34.6 → 1.34.8
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 +1 -1
- package/README.md +74 -35
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +70 -70
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/avl-tree.js +8 -8
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-tree.js +4 -4
- package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/bst.js +59 -59
- package/dist/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/data-structures/binary-tree/rb-tree.js +4 -4
- package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/tree-multiset.js +39 -39
- package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
- package/dist/data-structures/graph/abstract-graph.js +49 -49
- package/dist/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/data-structures/graph/directed-graph.js +33 -33
- package/dist/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/data-structures/graph/map-graph.js +4 -4
- package/dist/data-structures/graph/map-graph.js.map +1 -1
- package/dist/data-structures/graph/undirected-graph.js +14 -14
- package/dist/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/data-structures/tree/tree.js +5 -5
- package/dist/data-structures/tree/tree.js.map +1 -1
- package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +71 -71
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +110 -110
- package/lib/data-structures/binary-tree/avl-tree.d.ts +10 -10
- package/lib/data-structures/binary-tree/avl-tree.js +13 -13
- package/lib/data-structures/binary-tree/binary-tree.d.ts +6 -6
- package/lib/data-structures/binary-tree/binary-tree.js +7 -7
- package/lib/data-structures/binary-tree/bst.d.ts +34 -34
- package/lib/data-structures/binary-tree/bst.js +80 -80
- package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/lib/data-structures/binary-tree/rb-tree.js +4 -4
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +27 -27
- package/lib/data-structures/binary-tree/tree-multiset.js +55 -55
- package/lib/data-structures/graph/abstract-graph.d.ts +60 -60
- package/lib/data-structures/graph/abstract-graph.js +81 -81
- package/lib/data-structures/graph/directed-graph.d.ts +51 -51
- package/lib/data-structures/graph/directed-graph.js +63 -63
- package/lib/data-structures/graph/map-graph.d.ts +13 -13
- package/lib/data-structures/graph/map-graph.js +12 -12
- package/lib/data-structures/graph/undirected-graph.d.ts +30 -30
- package/lib/data-structures/graph/undirected-graph.js +32 -32
- package/lib/data-structures/heap/heap.d.ts +1 -1
- package/lib/data-structures/tree/tree.d.ts +4 -4
- package/lib/data-structures/tree/tree.js +6 -6
- package/lib/interfaces/abstract-binary-tree.d.ts +24 -24
- package/lib/interfaces/abstract-graph.d.ts +13 -13
- package/lib/interfaces/avl-tree.d.ts +3 -3
- package/lib/interfaces/bst.d.ts +8 -8
- package/lib/interfaces/directed-graph.d.ts +5 -5
- package/lib/interfaces/rb-tree.d.ts +2 -2
- package/lib/interfaces/undirected-graph.d.ts +2 -2
- package/lib/types/data-structures/abstract-binary-tree.d.ts +3 -3
- package/lib/types/data-structures/abstract-graph.d.ts +2 -2
- package/lib/types/data-structures/bst.d.ts +2 -2
- package/lib/types/data-structures/tree-multiset.d.ts +1 -1
- package/lib/types/utils/validate-type.d.ts +8 -8
- package/package.json +1 -1
- package/scripts/rename_clear_files.sh +29 -0
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +147 -147
- package/src/data-structures/binary-tree/avl-tree.ts +14 -14
- package/src/data-structures/binary-tree/binary-tree.ts +8 -8
- package/src/data-structures/binary-tree/bst.ts +98 -90
- package/src/data-structures/binary-tree/rb-tree.ts +9 -9
- package/src/data-structures/binary-tree/tree-multiset.ts +62 -62
- package/src/data-structures/graph/abstract-graph.ts +109 -104
- package/src/data-structures/graph/directed-graph.ts +77 -77
- package/src/data-structures/graph/map-graph.ts +20 -15
- package/src/data-structures/graph/undirected-graph.ts +39 -39
- package/src/data-structures/heap/heap.ts +1 -1
- package/src/data-structures/tree/tree.ts +7 -7
- package/src/interfaces/abstract-binary-tree.ts +24 -24
- package/src/interfaces/abstract-graph.ts +13 -13
- package/src/interfaces/avl-tree.ts +3 -3
- package/src/interfaces/bst.ts +8 -8
- package/src/interfaces/directed-graph.ts +5 -5
- package/src/interfaces/rb-tree.ts +2 -2
- package/src/interfaces/undirected-graph.ts +2 -2
- package/src/types/data-structures/abstract-binary-tree.ts +3 -3
- package/src/types/data-structures/abstract-graph.ts +2 -2
- package/src/types/data-structures/bst.ts +2 -2
- package/src/types/data-structures/tree-multiset.ts +1 -1
- package/src/types/utils/validate-type.ts +10 -10
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +24 -24
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
- package/test/unit/data-structures/binary-tree/bst.test.ts +71 -71
- package/test/unit/data-structures/binary-tree/overall.test.ts +19 -19
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +72 -72
- package/test/unit/data-structures/graph/directed-graph.test.ts +8 -8
- package/test/unit/data-structures/graph/map-graph.test.ts +4 -4
- package/test/unit/data-structures/graph/overall.test.ts +2 -2
- package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -1
- package/test/unit/data-structures/tree/tree.test.ts +2 -2
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.map +1 -1
|
@@ -9,22 +9,22 @@ import { trampoline } from '../../utils';
|
|
|
9
9
|
import { FamilyPosition, LoopType } from '../../types';
|
|
10
10
|
export class AbstractBinaryTreeNode {
|
|
11
11
|
/**
|
|
12
|
-
* The constructor function initializes a BinaryTreeNode object with an
|
|
13
|
-
* @param {
|
|
12
|
+
* The constructor function initializes a BinaryTreeNode object with an key and an optional value.
|
|
13
|
+
* @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
|
|
14
14
|
* of the binary tree node. It is used to distinguish one node from another in the binary tree.
|
|
15
15
|
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It represents the value that will be
|
|
16
16
|
* stored in the binary tree node. If no value is provided, it will be set to undefined.
|
|
17
17
|
*/
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(key, val) {
|
|
19
19
|
this._height = 0;
|
|
20
|
-
this.
|
|
20
|
+
this._key = key;
|
|
21
21
|
this._val = val;
|
|
22
22
|
}
|
|
23
|
-
get
|
|
24
|
-
return this.
|
|
23
|
+
get key() {
|
|
24
|
+
return this._key;
|
|
25
25
|
}
|
|
26
|
-
set
|
|
27
|
-
this.
|
|
26
|
+
set key(v) {
|
|
27
|
+
this._key = v;
|
|
28
28
|
}
|
|
29
29
|
get val() {
|
|
30
30
|
return this._val;
|
|
@@ -110,7 +110,7 @@ export class AbstractBinaryTree {
|
|
|
110
110
|
this._root = null;
|
|
111
111
|
this._size = 0;
|
|
112
112
|
this._loopType = LoopType.ITERATIVE;
|
|
113
|
-
this.
|
|
113
|
+
this._visitedKey = [];
|
|
114
114
|
this._visitedVal = [];
|
|
115
115
|
this._visitedNode = [];
|
|
116
116
|
if (options !== undefined) {
|
|
@@ -128,8 +128,8 @@ export class AbstractBinaryTree {
|
|
|
128
128
|
get loopType() {
|
|
129
129
|
return this._loopType;
|
|
130
130
|
}
|
|
131
|
-
get
|
|
132
|
-
return this.
|
|
131
|
+
get visitedKey() {
|
|
132
|
+
return this._visitedKey;
|
|
133
133
|
}
|
|
134
134
|
get visitedVal() {
|
|
135
135
|
return this._visitedVal;
|
|
@@ -145,21 +145,21 @@ export class AbstractBinaryTree {
|
|
|
145
145
|
* @returns The `destNode` is being returned.
|
|
146
146
|
*/
|
|
147
147
|
swapLocation(srcNode, destNode) {
|
|
148
|
-
const {
|
|
149
|
-
const tempNode = this.createNode(
|
|
148
|
+
const { key, val, height } = destNode;
|
|
149
|
+
const tempNode = this.createNode(key, val);
|
|
150
150
|
if (tempNode) {
|
|
151
151
|
tempNode.height = height;
|
|
152
|
-
destNode.
|
|
152
|
+
destNode.key = srcNode.key;
|
|
153
153
|
destNode.val = srcNode.val;
|
|
154
154
|
destNode.height = srcNode.height;
|
|
155
|
-
srcNode.
|
|
155
|
+
srcNode.key = tempNode.key;
|
|
156
156
|
srcNode.val = tempNode.val;
|
|
157
157
|
srcNode.height = tempNode.height;
|
|
158
158
|
}
|
|
159
159
|
return destNode;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* The clear() function resets the root, size, and
|
|
162
|
+
* The clear() function resets the root, size, and maxKey properties to their initial values.
|
|
163
163
|
*/
|
|
164
164
|
clear() {
|
|
165
165
|
this._root = null;
|
|
@@ -179,20 +179,20 @@ export class AbstractBinaryTree {
|
|
|
179
179
|
*/
|
|
180
180
|
/**
|
|
181
181
|
* The `add` function adds a new node to a binary tree, either by ID or by creating a new node with a given value.
|
|
182
|
-
* @param {
|
|
182
|
+
* @param {BinaryTreeNodeKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a `BinaryTreeNodeKey`, which
|
|
183
183
|
* is a number representing the ID of a binary tree node, or it can be a `N` object, which represents a binary tree
|
|
184
184
|
* node itself. It can also be `null` if no node is specified.
|
|
185
185
|
* @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the new node
|
|
186
186
|
* being added to the binary tree.
|
|
187
187
|
* @returns The function `add` returns either the inserted node (`N`), `null`, or `undefined`.
|
|
188
188
|
*/
|
|
189
|
-
add(
|
|
189
|
+
add(keyOrNode, val) {
|
|
190
190
|
const _bfs = (root, newNode) => {
|
|
191
191
|
const queue = [root];
|
|
192
192
|
while (queue.length > 0) {
|
|
193
193
|
const cur = queue.shift();
|
|
194
194
|
if (cur) {
|
|
195
|
-
if (newNode && cur.
|
|
195
|
+
if (newNode && cur.key === newNode.key)
|
|
196
196
|
return;
|
|
197
197
|
const inserted = this._addTo(newNode, cur);
|
|
198
198
|
if (inserted !== undefined)
|
|
@@ -208,19 +208,19 @@ export class AbstractBinaryTree {
|
|
|
208
208
|
return;
|
|
209
209
|
};
|
|
210
210
|
let inserted, needInsert;
|
|
211
|
-
if (
|
|
211
|
+
if (keyOrNode === null) {
|
|
212
212
|
needInsert = null;
|
|
213
213
|
}
|
|
214
|
-
else if (typeof
|
|
215
|
-
needInsert = this.createNode(
|
|
214
|
+
else if (typeof keyOrNode === 'number') {
|
|
215
|
+
needInsert = this.createNode(keyOrNode, val);
|
|
216
216
|
}
|
|
217
|
-
else if (
|
|
218
|
-
needInsert =
|
|
217
|
+
else if (keyOrNode instanceof AbstractBinaryTreeNode) {
|
|
218
|
+
needInsert = keyOrNode;
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
const existNode =
|
|
223
|
+
const existNode = keyOrNode ? this.get(keyOrNode, 'key') : undefined;
|
|
224
224
|
if (this.root) {
|
|
225
225
|
if (existNode) {
|
|
226
226
|
existNode.val = val;
|
|
@@ -245,7 +245,7 @@ export class AbstractBinaryTree {
|
|
|
245
245
|
/**
|
|
246
246
|
* The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
|
|
247
247
|
* values, and adds them to the binary tree.
|
|
248
|
-
* @param {(
|
|
248
|
+
* @param {(BinaryTreeNodeKey | null)[] | (N | null)[]} idsOrNodes - An array of BinaryTreeNodeKey or BinaryTreeNode
|
|
249
249
|
* objects, or null values.
|
|
250
250
|
* @param {N['val'][]} [data] - The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to
|
|
251
251
|
* the nodes or node IDs being added. It is used to set the value of each node being added. If `data` is not provided,
|
|
@@ -256,24 +256,24 @@ export class AbstractBinaryTree {
|
|
|
256
256
|
// TODO not sure addMany not be run multi times
|
|
257
257
|
const inserted = [];
|
|
258
258
|
for (let i = 0; i < idsOrNodes.length; i++) {
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
261
|
-
inserted.push(this.add(
|
|
259
|
+
const keyOrNode = idsOrNodes[i];
|
|
260
|
+
if (keyOrNode instanceof AbstractBinaryTreeNode) {
|
|
261
|
+
inserted.push(this.add(keyOrNode.key, keyOrNode.val));
|
|
262
262
|
continue;
|
|
263
263
|
}
|
|
264
|
-
if (
|
|
264
|
+
if (keyOrNode === null) {
|
|
265
265
|
inserted.push(this.add(null));
|
|
266
266
|
continue;
|
|
267
267
|
}
|
|
268
268
|
const val = data === null || data === void 0 ? void 0 : data[i];
|
|
269
|
-
inserted.push(this.add(
|
|
269
|
+
inserted.push(this.add(keyOrNode, val));
|
|
270
270
|
}
|
|
271
271
|
return inserted;
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* The `fill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.
|
|
275
|
-
* @param {(
|
|
276
|
-
* `
|
|
275
|
+
* @param {(BinaryTreeNodeKey | N)[]} idsOrNodes - The `idsOrNodes` parameter is an array that can contain either
|
|
276
|
+
* `BinaryTreeNodeKey` or `N` values.
|
|
277
277
|
* @param {N[] | Array<N['val']>} [data] - The `data` parameter is an optional array of values that will be assigned to
|
|
278
278
|
* the nodes being added. If provided, the length of the `data` array should be equal to the length of the `idsOrNodes`
|
|
279
279
|
* array. Each value in the `data` array will be assigned to the
|
|
@@ -286,15 +286,15 @@ export class AbstractBinaryTree {
|
|
|
286
286
|
/**
|
|
287
287
|
* The `remove` function in TypeScript is used to delete a node from a binary search tree and returns an array of objects
|
|
288
288
|
* containing the deleted node and the node that needs to be balanced.
|
|
289
|
-
* @param {N |
|
|
290
|
-
* node ID (`
|
|
289
|
+
* @param {N | BinaryTreeNodeKey} nodeOrKey - The `nodeOrKey` parameter can be either a node object (`N`) or a binary tree
|
|
290
|
+
* node ID (`BinaryTreeNodeKey`).
|
|
291
291
|
* @returns The function `remove` returns an array of `BinaryTreeDeletedResult<N>` objects.
|
|
292
292
|
*/
|
|
293
|
-
remove(
|
|
293
|
+
remove(nodeOrKey) {
|
|
294
294
|
const bstDeletedResult = [];
|
|
295
295
|
if (!this.root)
|
|
296
296
|
return bstDeletedResult;
|
|
297
|
-
const curr = typeof
|
|
297
|
+
const curr = typeof nodeOrKey === 'number' ? this.get(nodeOrKey) : nodeOrKey;
|
|
298
298
|
if (!curr)
|
|
299
299
|
return bstDeletedResult;
|
|
300
300
|
const parent = (curr === null || curr === void 0 ? void 0 : curr.parent) ? curr.parent : null;
|
|
@@ -335,12 +335,12 @@ export class AbstractBinaryTree {
|
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
337
|
* The function calculates the depth of a node in a binary tree.
|
|
338
|
-
* @param {N |
|
|
338
|
+
* @param {N | BinaryTreeNodeKey | null} beginRoot - The `beginRoot` parameter can be one of the following:
|
|
339
339
|
* @returns the depth of the given node or binary tree.
|
|
340
340
|
*/
|
|
341
341
|
getDepth(beginRoot) {
|
|
342
342
|
if (typeof beginRoot === 'number')
|
|
343
|
-
beginRoot = this.get(beginRoot, '
|
|
343
|
+
beginRoot = this.get(beginRoot, 'key');
|
|
344
344
|
let depth = 0;
|
|
345
345
|
while (beginRoot === null || beginRoot === void 0 ? void 0 : beginRoot.parent) {
|
|
346
346
|
depth++;
|
|
@@ -350,15 +350,15 @@ export class AbstractBinaryTree {
|
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* The `getHeight` function calculates the maximum height of a binary tree, either recursively or iteratively.
|
|
353
|
-
* @param {N |
|
|
354
|
-
* generic type representing a node in a binary tree), `
|
|
353
|
+
* @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
|
|
354
|
+
* generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
|
|
355
355
|
* node), or `null`.
|
|
356
356
|
* @returns the height of the binary tree.
|
|
357
357
|
*/
|
|
358
358
|
getHeight(beginRoot) {
|
|
359
359
|
beginRoot = beginRoot !== null && beginRoot !== void 0 ? beginRoot : this.root;
|
|
360
360
|
if (typeof beginRoot === 'number')
|
|
361
|
-
beginRoot = this.get(beginRoot, '
|
|
361
|
+
beginRoot = this.get(beginRoot, 'key');
|
|
362
362
|
if (!beginRoot)
|
|
363
363
|
return -1;
|
|
364
364
|
if (this._loopType === LoopType.RECURSIVE) {
|
|
@@ -455,10 +455,10 @@ export class AbstractBinaryTree {
|
|
|
455
455
|
}
|
|
456
456
|
/**
|
|
457
457
|
* The function `getNodes` returns an array of nodes that match a given property name and value in a binary tree.
|
|
458
|
-
* @param {
|
|
458
|
+
* @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or a
|
|
459
459
|
* generic type `N`. It represents the property of the binary tree node that you want to search for.
|
|
460
460
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
461
|
-
* specifies the property name to use when searching for nodes. If not provided, it defaults to '
|
|
461
|
+
* specifies the property name to use when searching for nodes. If not provided, it defaults to 'key'.
|
|
462
462
|
* @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
|
|
463
463
|
* return only one node that matches the given `nodeProperty` or `propertyName`. If `onlyOne` is set to `true`, the
|
|
464
464
|
* function will stop traversing the tree and return the first matching node. If `only
|
|
@@ -467,7 +467,7 @@ export class AbstractBinaryTree {
|
|
|
467
467
|
getNodes(nodeProperty, propertyName, onlyOne) {
|
|
468
468
|
if (!this.root)
|
|
469
469
|
return [];
|
|
470
|
-
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : '
|
|
470
|
+
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : 'key';
|
|
471
471
|
const result = [];
|
|
472
472
|
if (this.loopType === LoopType.RECURSIVE) {
|
|
473
473
|
const _traverse = (cur) => {
|
|
@@ -496,31 +496,31 @@ export class AbstractBinaryTree {
|
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
498
498
|
* The function checks if a binary tree node has a specific property.
|
|
499
|
-
* @param {
|
|
499
|
+
* @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
|
|
500
500
|
* It represents the property of the binary tree node that you want to check.
|
|
501
501
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
502
|
-
* specifies the name of the property to be checked in the nodes. If not provided, it defaults to '
|
|
502
|
+
* specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'key'.
|
|
503
503
|
* @returns a boolean value.
|
|
504
504
|
*/
|
|
505
505
|
has(nodeProperty, propertyName) {
|
|
506
|
-
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : '
|
|
506
|
+
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : 'key';
|
|
507
507
|
// TODO may support finding node by value equal
|
|
508
508
|
return this.getNodes(nodeProperty, propertyName).length > 0;
|
|
509
509
|
}
|
|
510
510
|
/**
|
|
511
511
|
* The function returns the first node that matches the given property name and value, or null if no matching node is
|
|
512
512
|
* found.
|
|
513
|
-
* @param {
|
|
513
|
+
* @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter can be either a `BinaryTreeNodeKey` or `N`.
|
|
514
514
|
* It represents the property of the binary tree node that you want to search for.
|
|
515
515
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
516
516
|
* specifies the property name to be used for searching the binary tree nodes. If this parameter is not provided, the
|
|
517
|
-
* default value is set to `'
|
|
517
|
+
* default value is set to `'key'`.
|
|
518
518
|
* @returns either the value of the specified property of the node, or the node itself if no property name is provided.
|
|
519
519
|
* If no matching node is found, it returns null.
|
|
520
520
|
*/
|
|
521
521
|
get(nodeProperty, propertyName) {
|
|
522
522
|
var _a;
|
|
523
|
-
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : '
|
|
523
|
+
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : 'key';
|
|
524
524
|
// TODO may support finding node by value equal
|
|
525
525
|
return (_a = this.getNodes(nodeProperty, propertyName, true)[0]) !== null && _a !== void 0 ? _a : null;
|
|
526
526
|
}
|
|
@@ -535,7 +535,7 @@ export class AbstractBinaryTree {
|
|
|
535
535
|
* @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
|
|
536
536
|
*/
|
|
537
537
|
getPathToRoot(node, isReverse = true) {
|
|
538
|
-
// TODO to support get path through passing
|
|
538
|
+
// TODO to support get path through passing key
|
|
539
539
|
const result = [];
|
|
540
540
|
while (node.parent) {
|
|
541
541
|
// Array.push + Array.reverse is more efficient than Array.unshift
|
|
@@ -549,8 +549,8 @@ export class AbstractBinaryTree {
|
|
|
549
549
|
/**
|
|
550
550
|
* The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if
|
|
551
551
|
* no node is specified.
|
|
552
|
-
* @param {N |
|
|
553
|
-
* generic type representing a node in a binary tree), `
|
|
552
|
+
* @param {N | BinaryTreeNodeKey | null} [beginRoot] - The `beginRoot` parameter is optional and can be of type `N` (a
|
|
553
|
+
* generic type representing a node in a binary tree), `BinaryTreeNodeKey` (a type representing the ID of a binary tree
|
|
554
554
|
* node), or `null`.
|
|
555
555
|
* @returns The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is
|
|
556
556
|
* provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal
|
|
@@ -559,7 +559,7 @@ export class AbstractBinaryTree {
|
|
|
559
559
|
*/
|
|
560
560
|
getLeftMost(beginRoot) {
|
|
561
561
|
if (typeof beginRoot === 'number')
|
|
562
|
-
beginRoot = this.get(beginRoot, '
|
|
562
|
+
beginRoot = this.get(beginRoot, 'key');
|
|
563
563
|
beginRoot = beginRoot !== null && beginRoot !== void 0 ? beginRoot : this.root;
|
|
564
564
|
if (!beginRoot)
|
|
565
565
|
return beginRoot;
|
|
@@ -592,7 +592,7 @@ export class AbstractBinaryTree {
|
|
|
592
592
|
* rightmost node starting from the root of the binary tree.
|
|
593
593
|
*/
|
|
594
594
|
getRightMost(node) {
|
|
595
|
-
// TODO support get right most by passing
|
|
595
|
+
// TODO support get right most by passing key in
|
|
596
596
|
node = node !== null && node !== void 0 ? node : this.root;
|
|
597
597
|
if (!node)
|
|
598
598
|
return node;
|
|
@@ -627,9 +627,9 @@ export class AbstractBinaryTree {
|
|
|
627
627
|
const dfs = (cur, min, max) => {
|
|
628
628
|
if (!cur)
|
|
629
629
|
return true;
|
|
630
|
-
if (cur.
|
|
630
|
+
if (cur.key <= min || cur.key >= max)
|
|
631
631
|
return false;
|
|
632
|
-
return dfs(cur.left, min, cur.
|
|
632
|
+
return dfs(cur.left, min, cur.key) && dfs(cur.right, cur.key, max);
|
|
633
633
|
};
|
|
634
634
|
return dfs(node, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
635
635
|
}
|
|
@@ -642,9 +642,9 @@ export class AbstractBinaryTree {
|
|
|
642
642
|
curr = curr.left;
|
|
643
643
|
}
|
|
644
644
|
curr = stack.pop();
|
|
645
|
-
if (!curr || prev >= curr.
|
|
645
|
+
if (!curr || prev >= curr.key)
|
|
646
646
|
return false;
|
|
647
|
-
prev = curr.
|
|
647
|
+
prev = curr.key;
|
|
648
648
|
curr = curr.right;
|
|
649
649
|
}
|
|
650
650
|
return true;
|
|
@@ -664,7 +664,7 @@ export class AbstractBinaryTree {
|
|
|
664
664
|
* @returns the size of the subtree rooted at `subTreeRoot`.
|
|
665
665
|
*/
|
|
666
666
|
getSubTreeSize(subTreeRoot) {
|
|
667
|
-
// TODO support
|
|
667
|
+
// TODO support key passed in
|
|
668
668
|
let size = 0;
|
|
669
669
|
if (!subTreeRoot)
|
|
670
670
|
return size;
|
|
@@ -690,31 +690,31 @@ export class AbstractBinaryTree {
|
|
|
690
690
|
}
|
|
691
691
|
/**
|
|
692
692
|
* The function `subTreeSum` calculates the sum of a specified property in a binary tree or subtree.
|
|
693
|
-
* @param {N |
|
|
693
|
+
* @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
|
|
694
694
|
* tree or the ID of a binary tree node. It can also be `null` if there is no subtree.
|
|
695
695
|
* @param {BinaryTreeNodePropertyName} [propertyName] - propertyName is an optional parameter that specifies the
|
|
696
|
-
* property of the binary tree node to use for calculating the sum. It can be either '
|
|
697
|
-
* not provided, it defaults to '
|
|
696
|
+
* property of the binary tree node to use for calculating the sum. It can be either 'key' or 'val'. If propertyName is
|
|
697
|
+
* not provided, it defaults to 'key'.
|
|
698
698
|
* @returns a number, which is the sum of the values of the specified property in the subtree rooted at `subTreeRoot`.
|
|
699
699
|
*/
|
|
700
700
|
subTreeSum(subTreeRoot, propertyName) {
|
|
701
|
-
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : '
|
|
701
|
+
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : 'key';
|
|
702
702
|
if (typeof subTreeRoot === 'number')
|
|
703
|
-
subTreeRoot = this.get(subTreeRoot, '
|
|
703
|
+
subTreeRoot = this.get(subTreeRoot, 'key');
|
|
704
704
|
if (!subTreeRoot)
|
|
705
705
|
return 0;
|
|
706
706
|
let sum = 0;
|
|
707
707
|
const _sumByProperty = (cur) => {
|
|
708
708
|
let needSum;
|
|
709
709
|
switch (propertyName) {
|
|
710
|
-
case '
|
|
711
|
-
needSum = cur.
|
|
710
|
+
case 'key':
|
|
711
|
+
needSum = cur.key;
|
|
712
712
|
break;
|
|
713
713
|
case 'val':
|
|
714
714
|
needSum = typeof cur.val === 'number' ? cur.val : 0;
|
|
715
715
|
break;
|
|
716
716
|
default:
|
|
717
|
-
needSum = cur.
|
|
717
|
+
needSum = cur.key;
|
|
718
718
|
break;
|
|
719
719
|
}
|
|
720
720
|
return needSum;
|
|
@@ -740,27 +740,27 @@ export class AbstractBinaryTree {
|
|
|
740
740
|
}
|
|
741
741
|
/**
|
|
742
742
|
* The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.
|
|
743
|
-
* @param {N |
|
|
743
|
+
* @param {N | BinaryTreeNodeKey | null} subTreeRoot - The `subTreeRoot` parameter represents the root node of a binary
|
|
744
744
|
* tree or the ID of a node in the binary tree. It can also be `null` if there is no subtree to add to.
|
|
745
745
|
* @param {number} delta - The `delta` parameter is a number that represents the amount by which the property value of
|
|
746
746
|
* each node in the subtree should be incremented.
|
|
747
747
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
748
|
-
* specifies the property of the binary tree node that should be modified. If not provided, it defaults to '
|
|
748
|
+
* specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'key'.
|
|
749
749
|
* @returns a boolean value.
|
|
750
750
|
*/
|
|
751
751
|
subTreeAdd(subTreeRoot, delta, propertyName) {
|
|
752
|
-
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : '
|
|
752
|
+
propertyName = propertyName !== null && propertyName !== void 0 ? propertyName : 'key';
|
|
753
753
|
if (typeof subTreeRoot === 'number')
|
|
754
|
-
subTreeRoot = this.get(subTreeRoot, '
|
|
754
|
+
subTreeRoot = this.get(subTreeRoot, 'key');
|
|
755
755
|
if (!subTreeRoot)
|
|
756
756
|
return false;
|
|
757
757
|
const _addByProperty = (cur) => {
|
|
758
758
|
switch (propertyName) {
|
|
759
|
-
case '
|
|
760
|
-
cur.
|
|
759
|
+
case 'key':
|
|
760
|
+
cur.key += delta;
|
|
761
761
|
break;
|
|
762
762
|
default:
|
|
763
|
-
cur.
|
|
763
|
+
cur.key += delta;
|
|
764
764
|
break;
|
|
765
765
|
}
|
|
766
766
|
};
|
|
@@ -791,7 +791,7 @@ export class AbstractBinaryTree {
|
|
|
791
791
|
* @returns An instance of the `AbstractBinaryTreeNodeProperties` class with generic type `N`.
|
|
792
792
|
*/
|
|
793
793
|
BFS(nodeOrPropertyName) {
|
|
794
|
-
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : '
|
|
794
|
+
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'key';
|
|
795
795
|
this._clearResults();
|
|
796
796
|
const queue = [this.root];
|
|
797
797
|
while (queue.length !== 0) {
|
|
@@ -810,12 +810,12 @@ export class AbstractBinaryTree {
|
|
|
810
810
|
* The DFS function performs a depth-first search traversal on a binary tree and returns the accumulated properties of
|
|
811
811
|
* each node based on the specified pattern and property name.
|
|
812
812
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
813
|
-
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. If no `nodeOrPropertyName` is provided, the default value is `'
|
|
813
|
+
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. If no `nodeOrPropertyName` is provided, the default value is `'key'`.
|
|
814
814
|
* @returns an instance of the AbstractBinaryTreeNodeProperties class, which contains the accumulated properties of the binary tree nodes based on the specified pattern and node or property name.
|
|
815
815
|
*/
|
|
816
816
|
DFS(pattern, nodeOrPropertyName) {
|
|
817
817
|
pattern = pattern !== null && pattern !== void 0 ? pattern : 'in';
|
|
818
|
-
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : '
|
|
818
|
+
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'key';
|
|
819
819
|
this._clearResults();
|
|
820
820
|
const _traverse = (node) => {
|
|
821
821
|
switch (pattern) {
|
|
@@ -849,12 +849,12 @@ export class AbstractBinaryTree {
|
|
|
849
849
|
* The DFSIterative function performs an iterative depth-first search traversal on a binary tree, with the option to
|
|
850
850
|
* specify the traversal pattern and the property name to accumulate results by.
|
|
851
851
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
852
|
-
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. By default, it is set to `'
|
|
852
|
+
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. By default, it is set to `'key'`.
|
|
853
853
|
* @returns An object of type AbstractBinaryTreeNodeProperties<N>.
|
|
854
854
|
*/
|
|
855
855
|
DFSIterative(pattern, nodeOrPropertyName) {
|
|
856
856
|
pattern = pattern || 'in';
|
|
857
|
-
nodeOrPropertyName = nodeOrPropertyName || '
|
|
857
|
+
nodeOrPropertyName = nodeOrPropertyName || 'key';
|
|
858
858
|
this._clearResults();
|
|
859
859
|
if (!this.root)
|
|
860
860
|
return this._getResultByPropertyName(nodeOrPropertyName);
|
|
@@ -901,13 +901,13 @@ export class AbstractBinaryTree {
|
|
|
901
901
|
* node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
|
|
902
902
|
* the tree is used as the starting node.
|
|
903
903
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that
|
|
904
|
-
* can be either a `BinaryTreeNode` property name or the string `'
|
|
904
|
+
* can be either a `BinaryTreeNode` property name or the string `'key'`. If a property name is provided, the function
|
|
905
905
|
* will accumulate results based on that property. If no property name is provided, the function will default to
|
|
906
|
-
* accumulating results based on the '
|
|
906
|
+
* accumulating results based on the 'key' property.
|
|
907
907
|
* @returns An object of type `AbstractBinaryTreeNodeProperties<N>`.
|
|
908
908
|
*/
|
|
909
909
|
levelIterative(node, nodeOrPropertyName) {
|
|
910
|
-
nodeOrPropertyName = nodeOrPropertyName || '
|
|
910
|
+
nodeOrPropertyName = nodeOrPropertyName || 'key';
|
|
911
911
|
node = node || this.root;
|
|
912
912
|
if (!node)
|
|
913
913
|
return [];
|
|
@@ -930,19 +930,19 @@ export class AbstractBinaryTree {
|
|
|
930
930
|
/**
|
|
931
931
|
* The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.
|
|
932
932
|
* @param {N | null} node - The `node` parameter is a BinaryTreeNode object or null. It represents the root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
|
|
933
|
-
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that specifies the property of the `BinaryTreeNode` object to collect at each level. It can be one of the following values: '
|
|
933
|
+
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The `nodeOrPropertyName` parameter is an optional parameter that specifies the property of the `BinaryTreeNode` object to collect at each level. It can be one of the following values: 'key', 'val', or 'node'. If not provided, it defaults to 'key'.
|
|
934
934
|
* @returns A 2D array of `AbstractBinaryTreeNodeProperty<N>` objects.
|
|
935
935
|
*/
|
|
936
936
|
listLevels(node, nodeOrPropertyName) {
|
|
937
|
-
nodeOrPropertyName = nodeOrPropertyName || '
|
|
937
|
+
nodeOrPropertyName = nodeOrPropertyName || 'key';
|
|
938
938
|
node = node || this.root;
|
|
939
939
|
if (!node)
|
|
940
940
|
return [];
|
|
941
941
|
const levelsNodes = [];
|
|
942
942
|
const collectByProperty = (node, level) => {
|
|
943
943
|
switch (nodeOrPropertyName) {
|
|
944
|
-
case '
|
|
945
|
-
levelsNodes[level].push(node.
|
|
944
|
+
case 'key':
|
|
945
|
+
levelsNodes[level].push(node.key);
|
|
946
946
|
break;
|
|
947
947
|
case 'val':
|
|
948
948
|
levelsNodes[level].push(node.val);
|
|
@@ -951,7 +951,7 @@ export class AbstractBinaryTree {
|
|
|
951
951
|
levelsNodes[level].push(node);
|
|
952
952
|
break;
|
|
953
953
|
default:
|
|
954
|
-
levelsNodes[level].push(node.
|
|
954
|
+
levelsNodes[level].push(node.key);
|
|
955
955
|
break;
|
|
956
956
|
}
|
|
957
957
|
};
|
|
@@ -1005,14 +1005,14 @@ export class AbstractBinaryTree {
|
|
|
1005
1005
|
/**
|
|
1006
1006
|
* The `morris` function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
|
|
1007
1007
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
1008
|
-
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The property name of the nodes to retrieve or perform operations on during the traversal. It can be any valid property name of the nodes in the binary tree. If not provided, it defaults to '
|
|
1008
|
+
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The property name of the nodes to retrieve or perform operations on during the traversal. It can be any valid property name of the nodes in the binary tree. If not provided, it defaults to 'key'.
|
|
1009
1009
|
* @returns An array of AbstractBinaryTreeNodeProperties<N> objects.
|
|
1010
1010
|
*/
|
|
1011
1011
|
morris(pattern, nodeOrPropertyName) {
|
|
1012
1012
|
if (this.root === null)
|
|
1013
1013
|
return [];
|
|
1014
1014
|
pattern = pattern || 'in';
|
|
1015
|
-
nodeOrPropertyName = nodeOrPropertyName || '
|
|
1015
|
+
nodeOrPropertyName = nodeOrPropertyName || 'key';
|
|
1016
1016
|
this._clearResults();
|
|
1017
1017
|
let cur = this.root;
|
|
1018
1018
|
const _reverseEdge = (node) => {
|
|
@@ -1138,11 +1138,11 @@ export class AbstractBinaryTree {
|
|
|
1138
1138
|
this._loopType = value;
|
|
1139
1139
|
}
|
|
1140
1140
|
/**
|
|
1141
|
-
* The function sets the value of the `
|
|
1142
|
-
* @param {
|
|
1141
|
+
* The function sets the value of the `_visitedKey` property in a protected manner.
|
|
1142
|
+
* @param {BinaryTreeNodeKey[]} value - value is an array of BinaryTreeNodeKey values.
|
|
1143
1143
|
*/
|
|
1144
|
-
|
|
1145
|
-
this.
|
|
1144
|
+
_setVisitedKey(value) {
|
|
1145
|
+
this._visitedKey = value;
|
|
1146
1146
|
}
|
|
1147
1147
|
/**
|
|
1148
1148
|
* The function sets the value of the "_visitedVal" property to the given array.
|
|
@@ -1181,7 +1181,7 @@ export class AbstractBinaryTree {
|
|
|
1181
1181
|
* properties.
|
|
1182
1182
|
*/
|
|
1183
1183
|
_clearResults() {
|
|
1184
|
-
this.
|
|
1184
|
+
this._visitedKey = [];
|
|
1185
1185
|
this._visitedVal = [];
|
|
1186
1186
|
this._visitedNode = [];
|
|
1187
1187
|
}
|
|
@@ -1190,11 +1190,11 @@ export class AbstractBinaryTree {
|
|
|
1190
1190
|
* a result array.
|
|
1191
1191
|
* @param {N} cur - The current node being processed.
|
|
1192
1192
|
* @param {(N | null | undefined)[]} result - An array that stores the matching nodes.
|
|
1193
|
-
* @param {
|
|
1193
|
+
* @param {BinaryTreeNodeKey | N} nodeProperty - The `nodeProperty` parameter is either a `BinaryTreeNodeKey` or a `N`
|
|
1194
1194
|
* type. It represents the property value that we are comparing against in the switch statement.
|
|
1195
1195
|
* @param {BinaryTreeNodePropertyName} [propertyName] - The `propertyName` parameter is an optional parameter that
|
|
1196
|
-
* specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'
|
|
1197
|
-
* or `'val'`. If it is not provided or is not equal to `'
|
|
1196
|
+
* specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'key'`
|
|
1197
|
+
* or `'val'`. If it is not provided or is not equal to `'key'` or `'val'`, the
|
|
1198
1198
|
* @param {boolean} [onlyOne] - The `onlyOne` parameter is an optional boolean parameter that determines whether to
|
|
1199
1199
|
* stop after finding the first matching node or continue searching for all matching nodes. If `onlyOne` is set to
|
|
1200
1200
|
* `true`, the function will stop after finding the first matching node and return `true`. If `onlyOne
|
|
@@ -1202,8 +1202,8 @@ export class AbstractBinaryTree {
|
|
|
1202
1202
|
*/
|
|
1203
1203
|
_pushByPropertyNameStopOrNot(cur, result, nodeProperty, propertyName, onlyOne) {
|
|
1204
1204
|
switch (propertyName) {
|
|
1205
|
-
case '
|
|
1206
|
-
if (cur.
|
|
1205
|
+
case 'key':
|
|
1206
|
+
if (cur.key === nodeProperty) {
|
|
1207
1207
|
result.push(cur);
|
|
1208
1208
|
return !!onlyOne;
|
|
1209
1209
|
}
|
|
@@ -1215,7 +1215,7 @@ export class AbstractBinaryTree {
|
|
|
1215
1215
|
}
|
|
1216
1216
|
break;
|
|
1217
1217
|
default:
|
|
1218
|
-
if (cur.
|
|
1218
|
+
if (cur.key === nodeProperty) {
|
|
1219
1219
|
result.push(cur);
|
|
1220
1220
|
return !!onlyOne;
|
|
1221
1221
|
}
|
|
@@ -1230,10 +1230,10 @@ export class AbstractBinaryTree {
|
|
|
1230
1230
|
* specifies the property name to be used for accumulating values. If it is a `Node` object, it specifies
|
|
1231
1231
|
*/
|
|
1232
1232
|
_accumulatedByPropertyName(node, nodeOrPropertyName) {
|
|
1233
|
-
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : '
|
|
1233
|
+
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'key';
|
|
1234
1234
|
switch (nodeOrPropertyName) {
|
|
1235
|
-
case '
|
|
1236
|
-
this.
|
|
1235
|
+
case 'key':
|
|
1236
|
+
this._visitedKey.push(node.key);
|
|
1237
1237
|
break;
|
|
1238
1238
|
case 'val':
|
|
1239
1239
|
this._visitedVal.push(node.val);
|
|
@@ -1242,7 +1242,7 @@ export class AbstractBinaryTree {
|
|
|
1242
1242
|
this._visitedNode.push(node);
|
|
1243
1243
|
break;
|
|
1244
1244
|
default:
|
|
1245
|
-
this.
|
|
1245
|
+
this._visitedKey.push(node.key);
|
|
1246
1246
|
break;
|
|
1247
1247
|
}
|
|
1248
1248
|
}
|
|
@@ -1258,16 +1258,16 @@ export class AbstractBinaryTree {
|
|
|
1258
1258
|
* @returns The method `_getResultByPropertyName` returns an instance of `AbstractBinaryTreeNodeProperties<N>`.
|
|
1259
1259
|
*/
|
|
1260
1260
|
_getResultByPropertyName(nodeOrPropertyName) {
|
|
1261
|
-
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : '
|
|
1261
|
+
nodeOrPropertyName = nodeOrPropertyName !== null && nodeOrPropertyName !== void 0 ? nodeOrPropertyName : 'key';
|
|
1262
1262
|
switch (nodeOrPropertyName) {
|
|
1263
|
-
case '
|
|
1264
|
-
return this.
|
|
1263
|
+
case 'key':
|
|
1264
|
+
return this._visitedKey;
|
|
1265
1265
|
case 'val':
|
|
1266
1266
|
return this._visitedVal;
|
|
1267
1267
|
case 'node':
|
|
1268
1268
|
return this._visitedNode;
|
|
1269
1269
|
default:
|
|
1270
|
-
return this.
|
|
1270
|
+
return this._visitedKey;
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|