max-priority-queue-typed 2.2.3 → 2.2.5
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/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -5
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
- package/dist/types/data-structures/binary-tree/bst.d.ts +142 -28
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +4 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -5
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +5 -5
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree-counter.ts +1 -2
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +9 -8
- package/src/data-structures/binary-tree/avl-tree.ts +4 -5
- package/src/data-structures/binary-tree/bst.ts +495 -85
- package/src/data-structures/binary-tree/red-black-tree.ts +1 -2
- package/src/data-structures/binary-tree/tree-counter.ts +5 -7
- package/src/data-structures/binary-tree/tree-multi-map.ts +7 -8
- package/src/types/data-structures/binary-tree/bst.ts +5 -5
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import type {
|
|
10
10
|
BinaryTreeDeleteResult,
|
|
11
|
-
BinaryTreeOptions,
|
|
12
11
|
CRUD,
|
|
13
12
|
EntryCallback,
|
|
14
13
|
FamilyPosition,
|
|
@@ -463,7 +462,7 @@ export class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R> implem
|
|
|
463
462
|
|
|
464
463
|
override map<MK = K, MV = V, MR = any>(
|
|
465
464
|
callback: EntryCallback<K, V | undefined, [MK, MV]>,
|
|
466
|
-
options?: Partial<
|
|
465
|
+
options?: Partial<RedBlackTreeOptions<MK, MV, MR>>,
|
|
467
466
|
thisArg?: unknown
|
|
468
467
|
): RedBlackTree<MK, MV, MR> {
|
|
469
468
|
const out = this._createLike<MK, MV, MR>([], options);
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import type {
|
|
10
10
|
BinaryTreeDeleteResult,
|
|
11
|
-
BinaryTreeOptions,
|
|
12
11
|
BSTNOptKeyOrNode,
|
|
13
12
|
EntryCallback,
|
|
14
13
|
FamilyPosition,
|
|
@@ -17,7 +16,6 @@ import type {
|
|
|
17
16
|
RBTNColor,
|
|
18
17
|
TreeCounterOptions
|
|
19
18
|
} from '../../types';
|
|
20
|
-
import { BSTOptions } from '../../types';
|
|
21
19
|
import { BSTNode } from './bst';
|
|
22
20
|
import { IBinaryTree } from '../../interfaces';
|
|
23
21
|
import { RedBlackTree } from './red-black-tree';
|
|
@@ -432,7 +430,7 @@ export class TreeCounter<K = any, V = any, R = any> extends RedBlackTree<K, V, R
|
|
|
432
430
|
*/
|
|
433
431
|
override map<MK = K, MV = V, MR = any>(
|
|
434
432
|
callback: EntryCallback<K, V | undefined, [MK, MV]>,
|
|
435
|
-
options?: Partial<
|
|
433
|
+
options?: Partial<TreeCounterOptions<MK, MV, MR>>,
|
|
436
434
|
thisArg?: unknown
|
|
437
435
|
): TreeCounter<MK, MV, MR> {
|
|
438
436
|
const out = this._createLike<MK, MV, MR>([], options);
|
|
@@ -465,10 +463,10 @@ export class TreeCounter<K = any, V = any, R = any> extends RedBlackTree<K, V, R
|
|
|
465
463
|
* @param [options] - Optional constructor options for the like-kind instance.
|
|
466
464
|
* @returns An empty like-kind instance.
|
|
467
465
|
*/
|
|
468
|
-
protected override _createInstance<TK = K, TV = V, TR = R>(options?: Partial<
|
|
466
|
+
protected override _createInstance<TK = K, TV = V, TR = R>(options?: Partial<TreeCounterOptions<TK, TV, TR>>): this {
|
|
469
467
|
const Ctor = this.constructor as unknown as new (
|
|
470
468
|
iter?: Iterable<TK | BSTNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>,
|
|
471
|
-
opts?:
|
|
469
|
+
opts?: TreeCounterOptions<TK, TV, TR>
|
|
472
470
|
) => this;
|
|
473
471
|
return new Ctor([], { ...this._snapshotOptions<TK, TV, TR>(), ...(options ?? {}) }) as unknown as this;
|
|
474
472
|
}
|
|
@@ -485,11 +483,11 @@ export class TreeCounter<K = any, V = any, R = any> extends RedBlackTree<K, V, R
|
|
|
485
483
|
*/
|
|
486
484
|
protected override _createLike<TK = K, TV = V, TR = R>(
|
|
487
485
|
iter: Iterable<TK | BSTNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR> = [],
|
|
488
|
-
options?: Partial<
|
|
486
|
+
options?: Partial<TreeCounterOptions<TK, TV, TR>>
|
|
489
487
|
): TreeCounter<TK, TV, TR> {
|
|
490
488
|
const Ctor = this.constructor as unknown as new (
|
|
491
489
|
iter?: Iterable<TK | BSTNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>,
|
|
492
|
-
opts?:
|
|
490
|
+
opts?: TreeCounterOptions<TK, TV, TR>
|
|
493
491
|
) => TreeCounter<TK, TV, TR>;
|
|
494
492
|
return new Ctor(iter as unknown as Iterable<TK | any>, {
|
|
495
493
|
...this._snapshotOptions<TK, TV, TR>(),
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
EntryCallback,
|
|
13
13
|
FamilyPosition,
|
|
14
14
|
RBTNColor,
|
|
15
|
-
RedBlackTreeOptions,
|
|
16
15
|
TreeMultiMapOptions
|
|
17
16
|
} from '../../types';
|
|
18
17
|
import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
|
|
@@ -476,13 +475,13 @@ export class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTree<K, V[]
|
|
|
476
475
|
|
|
477
476
|
override map<MK = K, MVArr extends unknown[] = V[], MR = any>(
|
|
478
477
|
callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>,
|
|
479
|
-
options?: Partial<
|
|
478
|
+
options?: Partial<TreeMultiMapOptions<MK, MVArr, MR>>,
|
|
480
479
|
thisArg?: unknown
|
|
481
480
|
): TreeMultiMap<MK, ElemOf<MVArr>, MR>;
|
|
482
481
|
|
|
483
482
|
override map<MK = K, MV = V[], MR = any>(
|
|
484
483
|
callback: EntryCallback<K, V[] | undefined, [MK, MV]>,
|
|
485
|
-
options?: Partial<
|
|
484
|
+
options?: Partial<TreeMultiMapOptions<MK, MV, MR>>,
|
|
486
485
|
thisArg?: unknown
|
|
487
486
|
): RedBlackTree<MK, MV, MR>;
|
|
488
487
|
|
|
@@ -499,7 +498,7 @@ export class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTree<K, V[]
|
|
|
499
498
|
*/
|
|
500
499
|
override map<MK, MV, MR extends object>(
|
|
501
500
|
callback: EntryCallback<K, V[] | undefined, [MK, MV]>,
|
|
502
|
-
options?: Partial<
|
|
501
|
+
options?: Partial<TreeMultiMapOptions<MK, MV, MR>>,
|
|
503
502
|
thisArg?: unknown
|
|
504
503
|
): RedBlackTree<MK, MV, MR> {
|
|
505
504
|
const out = this._createLike<MK, MV, MR>([], options);
|
|
@@ -517,10 +516,10 @@ export class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTree<K, V[]
|
|
|
517
516
|
* @param [options] - Optional constructor options for the like-kind instance.
|
|
518
517
|
* @returns An empty like-kind instance.
|
|
519
518
|
*/
|
|
520
|
-
protected override _createInstance<TK = K, TV = V, TR = R>(options?: Partial<
|
|
519
|
+
protected override _createInstance<TK = K, TV = V, TR = R>(options?: Partial<TreeMultiMapOptions<TK, TV, TR>>): this {
|
|
521
520
|
const Ctor = this.constructor as unknown as new (
|
|
522
521
|
iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>,
|
|
523
|
-
opts?:
|
|
522
|
+
opts?: TreeMultiMapOptions<TK, TV, TR>
|
|
524
523
|
) => RedBlackTree<TK, TV, TR>;
|
|
525
524
|
return new Ctor([], { ...(this._snapshotOptions?.<TK, TV, TR>() ?? {}), ...(options ?? {}) }) as unknown as this;
|
|
526
525
|
}
|
|
@@ -539,11 +538,11 @@ export class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTree<K, V[]
|
|
|
539
538
|
iter: Iterable<
|
|
540
539
|
TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR
|
|
541
540
|
> = [],
|
|
542
|
-
options?: Partial<
|
|
541
|
+
options?: Partial<TreeMultiMapOptions<TK, TV, TR>>
|
|
543
542
|
): RedBlackTree<TK, TV, TR> {
|
|
544
543
|
const Ctor = this.constructor as unknown as new (
|
|
545
544
|
iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>,
|
|
546
|
-
opts?:
|
|
545
|
+
opts?: TreeMultiMapOptions<TK, TV, TR>
|
|
547
546
|
) => RedBlackTree<TK, TV, TR>;
|
|
548
547
|
return new Ctor(iter, { ...(this._snapshotOptions?.<TK, TV, TR>() ?? {}), ...(options ?? {}) });
|
|
549
548
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { BinaryTreeOptions } from './binary-tree';
|
|
2
|
-
import {
|
|
3
|
-
import { OptValue } from '../../common';
|
|
2
|
+
import type { Comparator, OptValue } from '../../common';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type BSTBaseOptions<K, V, R> = Omit<BinaryTreeOptions<K, V, R>, 'isDuplicate'>;
|
|
5
|
+
|
|
6
|
+
export type BSTOptions<K, V, R> = BSTBaseOptions<K, V, R> & {
|
|
7
|
+
comparator?: Comparator<K>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export type BSTNOptKey<K> = K | undefined;
|