deque-typed 1.52.6 → 1.52.9
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/constants/index.d.ts +4 -0
- package/dist/constants/index.js +8 -0
- package/dist/data-structures/base/iterable-element-base.d.ts +8 -1
- package/dist/data-structures/base/iterable-element-base.js +10 -1
- package/dist/data-structures/base/iterable-entry-base.d.ts +8 -1
- package/dist/data-structures/base/iterable-entry-base.js +10 -10
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
- package/dist/data-structures/binary-tree/avl-tree.d.ts +23 -24
- package/dist/data-structures/binary-tree/avl-tree.js +71 -64
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -2
- package/dist/data-structures/binary-tree/binary-tree.d.ts +591 -402
- package/dist/data-structures/binary-tree/binary-tree.js +690 -604
- package/dist/data-structures/binary-tree/bst.d.ts +72 -65
- package/dist/data-structures/binary-tree/bst.js +122 -125
- package/dist/data-structures/binary-tree/rb-tree.d.ts +21 -24
- package/dist/data-structures/binary-tree/rb-tree.js +42 -39
- package/dist/data-structures/binary-tree/segment-tree.d.ts +2 -2
- package/dist/data-structures/binary-tree/segment-tree.js +2 -2
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +27 -31
- package/dist/data-structures/binary-tree/tree-multi-map.js +45 -43
- package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/data-structures/graph/abstract-graph.js +7 -4
- package/dist/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/data-structures/graph/directed-graph.js +4 -2
- package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/data-structures/hash/hash-map.js +1 -1
- package/dist/data-structures/heap/heap.js +3 -3
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/doubly-linked-list.js +7 -7
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/singly-linked-list.js +6 -6
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/data-structures/matrix/matrix.d.ts +2 -2
- package/dist/data-structures/matrix/navigator.d.ts +2 -2
- package/dist/data-structures/matrix/navigator.js +4 -2
- package/dist/data-structures/queue/deque.d.ts +3 -3
- package/dist/data-structures/queue/deque.js +29 -29
- package/dist/data-structures/queue/queue.d.ts +1 -1
- package/dist/data-structures/stack/stack.d.ts +2 -2
- package/dist/data-structures/trie/trie.d.ts +2 -2
- package/dist/data-structures/trie/trie.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/binary-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
- package/dist/types/data-structures/binary-tree/binary-tree.js +0 -6
- package/package.json +2 -2
- package/src/constants/index.ts +4 -0
- package/src/data-structures/base/iterable-element-base.ts +11 -1
- package/src/data-structures/base/iterable-entry-base.ts +11 -19
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +46 -50
- package/src/data-structures/binary-tree/avl-tree.ts +68 -71
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +716 -748
- package/src/data-structures/binary-tree/bst.ts +137 -146
- package/src/data-structures/binary-tree/rb-tree.ts +46 -46
- package/src/data-structures/binary-tree/segment-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-multi-map.ts +49 -49
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/undirected-graph.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +3 -3
- package/src/data-structures/heap/heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
- package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/navigator.ts +4 -4
- package/src/data-structures/queue/deque.ts +31 -31
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/data-structures/stack/stack.ts +2 -2
- package/src/data-structures/trie/trie.ts +3 -3
- package/src/index.ts +2 -1
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { SkipLinkedListOptions } from '../../types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { MatrixOptions } from '../../types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { Direction, NavigatorParams, Turning } from '../../types';
|
|
@@ -42,7 +42,7 @@ export class Navigator<T = number> {
|
|
|
42
42
|
this._cur = cur;
|
|
43
43
|
this._character = new Character(charDir, turning);
|
|
44
44
|
this.onMove = onMove;
|
|
45
|
-
this.onMove
|
|
45
|
+
if (this.onMove) this.onMove(this._cur);
|
|
46
46
|
this._VISITED = VISITED;
|
|
47
47
|
this._matrix[this._cur[0]][this._cur[1]] = this._VISITED;
|
|
48
48
|
}
|
|
@@ -116,6 +116,6 @@ export class Navigator<T = number> {
|
|
|
116
116
|
|
|
117
117
|
const [i, j] = this._cur;
|
|
118
118
|
this._matrix[i][j] = this._VISITED;
|
|
119
|
-
this.onMove
|
|
119
|
+
if (this.onMove) this.onMove(this._cur);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { DequeOptions, ElementCallback, IterableWithSizeOrLength } from '../../types';
|
|
@@ -163,7 +163,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
163
163
|
* @returns The first element of the collection, of type E, is being returned.
|
|
164
164
|
*/
|
|
165
165
|
get first(): E | undefined {
|
|
166
|
-
if (this.
|
|
166
|
+
if (this._size === 0) return;
|
|
167
167
|
return this._buckets[this._bucketFirst][this._firstInBucket];
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -172,7 +172,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
172
172
|
* @return The last element in the array
|
|
173
173
|
*/
|
|
174
174
|
get last(): E | undefined {
|
|
175
|
-
if (this.
|
|
175
|
+
if (this._size === 0) return;
|
|
176
176
|
return this._buckets[this._bucketLast][this._lastInBucket];
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -186,7 +186,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
186
186
|
* @returns The size of the data structure after the element has been pushed.
|
|
187
187
|
*/
|
|
188
188
|
push(element: E): boolean {
|
|
189
|
-
if (this.
|
|
189
|
+
if (this._size) {
|
|
190
190
|
if (this._lastInBucket < this._bucketSize - 1) {
|
|
191
191
|
this._lastInBucket += 1;
|
|
192
192
|
} else if (this._bucketLast < this._bucketCount - 1) {
|
|
@@ -213,9 +213,9 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
213
213
|
* @returns The element that was removed from the data structure is being returned.
|
|
214
214
|
*/
|
|
215
215
|
pop(): E | undefined {
|
|
216
|
-
if (this.
|
|
216
|
+
if (this._size === 0) return;
|
|
217
217
|
const element = this._buckets[this._bucketLast][this._lastInBucket];
|
|
218
|
-
if (this.
|
|
218
|
+
if (this._size !== 1) {
|
|
219
219
|
if (this._lastInBucket > 0) {
|
|
220
220
|
this._lastInBucket -= 1;
|
|
221
221
|
} else if (this._bucketLast > 0) {
|
|
@@ -241,7 +241,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
241
241
|
* @returns The size of the data structure after the element has been added.
|
|
242
242
|
*/
|
|
243
243
|
unshift(element: E): boolean {
|
|
244
|
-
if (this.
|
|
244
|
+
if (this._size) {
|
|
245
245
|
if (this._firstInBucket > 0) {
|
|
246
246
|
this._firstInBucket -= 1;
|
|
247
247
|
} else if (this._bucketFirst > 0) {
|
|
@@ -269,9 +269,9 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
269
269
|
* returned.
|
|
270
270
|
*/
|
|
271
271
|
shift(): E | undefined {
|
|
272
|
-
if (this.
|
|
272
|
+
if (this._size === 0) return;
|
|
273
273
|
const element = this._buckets[this._bucketFirst][this._firstInBucket];
|
|
274
|
-
if (this.
|
|
274
|
+
if (this._size !== 1) {
|
|
275
275
|
if (this._firstInBucket < this._bucketSize - 1) {
|
|
276
276
|
this._firstInBucket += 1;
|
|
277
277
|
} else if (this._bucketFirst < this._bucketCount - 1) {
|
|
@@ -294,7 +294,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
294
294
|
* @returns A boolean value indicating whether the size of the object is 0 or not.
|
|
295
295
|
*/
|
|
296
296
|
isEmpty(): boolean {
|
|
297
|
-
return this.
|
|
297
|
+
return this._size === 0;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
/**
|
|
@@ -316,7 +316,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
316
316
|
*/
|
|
317
317
|
*begin(): Generator<E> {
|
|
318
318
|
let index = 0;
|
|
319
|
-
while (index < this.
|
|
319
|
+
while (index < this._size) {
|
|
320
320
|
yield this.at(index);
|
|
321
321
|
index++;
|
|
322
322
|
}
|
|
@@ -327,7 +327,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
327
327
|
* the last element.
|
|
328
328
|
*/
|
|
329
329
|
*reverseBegin(): Generator<E> {
|
|
330
|
-
let index = this.
|
|
330
|
+
let index = this._size - 1;
|
|
331
331
|
while (index >= 0) {
|
|
332
332
|
yield this.at(index);
|
|
333
333
|
index--;
|
|
@@ -345,7 +345,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
345
345
|
* @returns The element at the specified position in the data structure is being returned.
|
|
346
346
|
*/
|
|
347
347
|
at(pos: number): E {
|
|
348
|
-
rangeCheck(pos, 0, this.
|
|
348
|
+
rangeCheck(pos, 0, this._size - 1);
|
|
349
349
|
const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
|
|
350
350
|
return this._buckets[bucketIndex][indexInBucket]!;
|
|
351
351
|
}
|
|
@@ -361,7 +361,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
361
361
|
* position in the data structure.
|
|
362
362
|
*/
|
|
363
363
|
setAt(pos: number, element: E): boolean {
|
|
364
|
-
rangeCheck(pos, 0, this.
|
|
364
|
+
rangeCheck(pos, 0, this._size - 1);
|
|
365
365
|
const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
|
|
366
366
|
this._buckets[bucketIndex][indexInBucket] = element;
|
|
367
367
|
return true;
|
|
@@ -383,15 +383,15 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
383
383
|
* @returns The size of the array after the insertion is being returned.
|
|
384
384
|
*/
|
|
385
385
|
addAt(pos: number, element: E, num = 1): boolean {
|
|
386
|
-
const length = this.
|
|
386
|
+
const length = this._size;
|
|
387
387
|
rangeCheck(pos, 0, length);
|
|
388
388
|
if (pos === 0) {
|
|
389
389
|
while (num--) this.unshift(element);
|
|
390
|
-
} else if (pos === this.
|
|
390
|
+
} else if (pos === this._size) {
|
|
391
391
|
while (num--) this.push(element);
|
|
392
392
|
} else {
|
|
393
393
|
const arr: E[] = [];
|
|
394
|
-
for (let i = pos; i < this.
|
|
394
|
+
for (let i = pos; i < this._size; ++i) {
|
|
395
395
|
arr.push(this.at(i));
|
|
396
396
|
}
|
|
397
397
|
this.cut(pos - 1, true);
|
|
@@ -462,7 +462,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
462
462
|
} else {
|
|
463
463
|
const newDeque = new Deque<E>([], { bucketSize: this._bucketSize });
|
|
464
464
|
if (pos < 0) pos = 0;
|
|
465
|
-
for (let i = pos; i < this.
|
|
465
|
+
for (let i = pos; i < this._size; i++) {
|
|
466
466
|
newDeque.push(this.at(i));
|
|
467
467
|
}
|
|
468
468
|
|
|
@@ -482,11 +482,11 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
482
482
|
* @returns The size of the data structure after the deletion operation is performed.
|
|
483
483
|
*/
|
|
484
484
|
deleteAt(pos: number): boolean {
|
|
485
|
-
rangeCheck(pos, 0, this.
|
|
485
|
+
rangeCheck(pos, 0, this._size - 1);
|
|
486
486
|
if (pos === 0) this.shift();
|
|
487
|
-
else if (pos === this.
|
|
487
|
+
else if (pos === this._size - 1) this.pop();
|
|
488
488
|
else {
|
|
489
|
-
const length = this.
|
|
489
|
+
const length = this._size - 1;
|
|
490
490
|
let { bucketIndex: curBucket, indexInBucket: curPointer } = this._getBucketAndPosition(pos);
|
|
491
491
|
for (let i = pos; i < length; ++i) {
|
|
492
492
|
const { bucketIndex: nextBucket, indexInBucket: nextPointer } = this._getBucketAndPosition(pos + 1);
|
|
@@ -510,7 +510,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
510
510
|
* @returns The size of the data structure after the element has been deleted.
|
|
511
511
|
*/
|
|
512
512
|
delete(element: E): boolean {
|
|
513
|
-
const size = this.
|
|
513
|
+
const size = this._size;
|
|
514
514
|
if (size === 0) return false;
|
|
515
515
|
let i = 0;
|
|
516
516
|
let index = 0;
|
|
@@ -556,12 +556,12 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
556
556
|
* @returns The size of the modified array is being returned.
|
|
557
557
|
*/
|
|
558
558
|
unique(): this {
|
|
559
|
-
if (this.
|
|
559
|
+
if (this._size <= 1) {
|
|
560
560
|
return this;
|
|
561
561
|
}
|
|
562
562
|
let index = 1;
|
|
563
563
|
let prev = this.at(0);
|
|
564
|
-
for (let i = 1; i < this.
|
|
564
|
+
for (let i = 1; i < this._size; ++i) {
|
|
565
565
|
const cur = this.at(i);
|
|
566
566
|
if (cur !== prev) {
|
|
567
567
|
prev = cur;
|
|
@@ -584,11 +584,11 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
584
584
|
*/
|
|
585
585
|
sort(comparator?: (x: E, y: E) => number): this {
|
|
586
586
|
const arr: E[] = [];
|
|
587
|
-
for (let i = 0; i < this.
|
|
587
|
+
for (let i = 0; i < this._size; ++i) {
|
|
588
588
|
arr.push(this.at(i));
|
|
589
589
|
}
|
|
590
590
|
arr.sort(comparator);
|
|
591
|
-
for (let i = 0; i < this.
|
|
591
|
+
for (let i = 0; i < this._size; ++i) {
|
|
592
592
|
this.setAt(i, arr[i]);
|
|
593
593
|
}
|
|
594
594
|
return this;
|
|
@@ -601,10 +601,10 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
601
601
|
* The `shrinkToFit` function reorganizes the elements in an array-like data structure to minimize
|
|
602
602
|
* memory usage.
|
|
603
603
|
* @returns Nothing is being returned. The function is using the `return` statement to exit early if
|
|
604
|
-
* `this.
|
|
604
|
+
* `this._size` is 0, but it does not return any value.
|
|
605
605
|
*/
|
|
606
606
|
shrinkToFit(): void {
|
|
607
|
-
if (this.
|
|
607
|
+
if (this._size === 0) return;
|
|
608
608
|
const newBuckets = [];
|
|
609
609
|
if (this._bucketFirst === this._bucketLast) return;
|
|
610
610
|
else if (this._bucketFirst < this._bucketLast) {
|
|
@@ -636,7 +636,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
636
636
|
* in the data structure. If the element is not found, it returns -1.
|
|
637
637
|
*/
|
|
638
638
|
indexOf(element: E): number {
|
|
639
|
-
for (let i = 0; i < this.
|
|
639
|
+
for (let i = 0; i < this._size; ++i) {
|
|
640
640
|
if (this.at(i) === element) {
|
|
641
641
|
return i;
|
|
642
642
|
}
|
|
@@ -736,7 +736,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
|
|
|
736
736
|
* object to be iterated over using a for...of loop.
|
|
737
737
|
*/
|
|
738
738
|
protected *_getIterator(): IterableIterator<E> {
|
|
739
|
-
for (let i = 0; i < this.
|
|
739
|
+
for (let i = 0; i < this._size; ++i) {
|
|
740
740
|
yield this.at(i);
|
|
741
741
|
}
|
|
742
742
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementCallback, StackOptions } from '../../types';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* data-structure-typed
|
|
3
3
|
*
|
|
4
|
-
* @author
|
|
5
|
-
* @copyright Copyright (c) 2022
|
|
4
|
+
* @author Pablo Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementCallback, TrieOptions } from '../../types';
|
|
@@ -202,7 +202,7 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|
|
202
202
|
* @return True if the size of the queue is 0
|
|
203
203
|
*/
|
|
204
204
|
isEmpty(): boolean {
|
|
205
|
-
return this.
|
|
205
|
+
return this._size === 0;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
package/src/index.ts
CHANGED
|
@@ -8,4 +8,5 @@
|
|
|
8
8
|
// export { Deque, ObjectDeque, ArrayDeque } from 'data-structure-typed';
|
|
9
9
|
export * from './data-structures/queue/deque';
|
|
10
10
|
export * from './types/data-structures/queue/deque';
|
|
11
|
-
export * from './types/common';
|
|
11
|
+
export * from './types/common';
|
|
12
|
+
export * from './constants';
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
BinaryTreeNested,
|
|
5
5
|
BinaryTreeNodeNested,
|
|
6
6
|
BinaryTreeOptions,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
BTNKeyOrNodeOrEntry,
|
|
8
|
+
BTNPredicate
|
|
9
9
|
} from '../types';
|
|
10
10
|
|
|
11
11
|
export interface IBinaryTree<
|
|
@@ -23,5 +23,5 @@ export interface IBinaryTree<
|
|
|
23
23
|
|
|
24
24
|
addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
|
|
25
25
|
|
|
26
|
-
delete
|
|
26
|
+
delete(predicate: R | BTNKeyOrNodeOrEntry<K, V, NODE> | BTNPredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
|
|
27
27
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
|
|
2
2
|
import { IterationType, OptValue } from '../../common';
|
|
3
|
+
import { DFSOperation } from '../../../constants';
|
|
3
4
|
|
|
4
5
|
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
5
6
|
|
|
@@ -30,9 +31,6 @@ export type BinaryTreeDeleteResult<NODE> = { deleted: OptBTNOrNull<NODE>; needBa
|
|
|
30
31
|
|
|
31
32
|
export type BTNCallback<NODE, D = any> = (node: NODE) => D;
|
|
32
33
|
|
|
33
|
-
export
|
|
34
|
-
VISIT = 0,
|
|
35
|
-
PROCESS = 1,
|
|
36
|
-
}
|
|
34
|
+
export type BTNPredicate<NODE> = (node: NODE) => boolean;
|
|
37
35
|
|
|
38
|
-
export type DFSStackItem<NODE> = { opt: DFSOperation; node: OptBTNOrNull<NODE> }
|
|
36
|
+
export type DFSStackItem<NODE> = { opt: DFSOperation; node: OptBTNOrNull<NODE> }
|