queue-typed 2.2.3 → 2.2.6
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/cjs/index.cjs +0 -34
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +0 -34
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +0 -34
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +0 -34
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +6 -0
- 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/binary-tree.d.ts +14 -57
- package/dist/types/data-structures/binary-tree/bst.d.ts +151 -117
- 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/dist/umd/queue-typed.js +0 -31
- package/dist/umd/queue-typed.js.map +1 -1
- package/dist/umd/queue-typed.min.js +1 -1
- package/dist/umd/queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/index.ts +2 -4
- package/src/data-structures/base/iterable-entry-base.ts +9 -0
- 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/binary-tree.ts +67 -0
- package/src/data-structures/binary-tree/bst.ts +724 -108
- 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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { ElemOf, EntryCallback, FamilyPosition, RBTNColor,
|
|
8
|
+
import type { ElemOf, EntryCallback, FamilyPosition, RBTNColor, TreeMultiMapOptions } from '../../types';
|
|
9
9
|
import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
11
|
/**
|
|
@@ -307,8 +307,8 @@ export declare class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTre
|
|
|
307
307
|
* @returns True if the value was removed; false if not found.
|
|
308
308
|
*/
|
|
309
309
|
deleteValue(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined, value: V): boolean;
|
|
310
|
-
map<MK = K, MVArr extends unknown[] = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<
|
|
311
|
-
map<MK = K, MV = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<
|
|
310
|
+
map<MK = K, MVArr extends unknown[] = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MVArr]>, options?: Partial<TreeMultiMapOptions<MK, MVArr, MR>>, thisArg?: unknown): TreeMultiMap<MK, ElemOf<MVArr>, MR>;
|
|
311
|
+
map<MK = K, MV = V[], MR = any>(callback: EntryCallback<K, V[] | undefined, [MK, MV]>, options?: Partial<TreeMultiMapOptions<MK, MV, MR>>, thisArg?: unknown): RedBlackTree<MK, MV, MR>;
|
|
312
312
|
/**
|
|
313
313
|
* (Protected) Create an empty instance of the same concrete class.
|
|
314
314
|
* @remarks Time O(1), Space O(1)
|
|
@@ -318,7 +318,7 @@ export declare class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTre
|
|
|
318
318
|
* @param [options] - Optional constructor options for the like-kind instance.
|
|
319
319
|
* @returns An empty like-kind instance.
|
|
320
320
|
*/
|
|
321
|
-
protected _createInstance<TK = K, TV = V, TR = R>(options?: Partial<
|
|
321
|
+
protected _createInstance<TK = K, TV = V, TR = R>(options?: Partial<TreeMultiMapOptions<TK, TV, TR>>): this;
|
|
322
322
|
/**
|
|
323
323
|
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
324
324
|
* @remarks Time O(N log N), Space O(N)
|
|
@@ -329,5 +329,5 @@ export declare class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTre
|
|
|
329
329
|
* @param [options] - Options merged with the current snapshot.
|
|
330
330
|
* @returns A like-kind RedBlackTree built from the iterable.
|
|
331
331
|
*/
|
|
332
|
-
protected _createLike<TK = K, TV = V, TR = R>(iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<
|
|
332
|
+
protected _createLike<TK = K, TV = V, TR = R>(iter?: Iterable<TK | RedBlackTreeNode<TK, TV> | [TK | null | undefined, TV | undefined] | null | undefined | TR>, options?: Partial<TreeMultiMapOptions<TK, TV, TR>>): RedBlackTree<TK, TV, TR>;
|
|
333
333
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { BinaryTreeOptions } from './binary-tree';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type BSTOptions<K, V, R> =
|
|
5
|
-
|
|
6
|
-
isReverse?: boolean;
|
|
2
|
+
import type { Comparator, OptValue } from '../../common';
|
|
3
|
+
type BSTBaseOptions<K, V, R> = Omit<BinaryTreeOptions<K, V, R>, 'isDuplicate'>;
|
|
4
|
+
export type BSTOptions<K, V, R> = BSTBaseOptions<K, V, R> & {
|
|
5
|
+
comparator?: Comparator<K>;
|
|
7
6
|
};
|
|
8
7
|
export type BSTNOptKey<K> = K | undefined;
|
|
9
8
|
export type OptNode<NODE> = NODE | undefined;
|
|
10
9
|
export type BSTNEntry<K, V> = [BSTNOptKey<K>, OptValue<V>];
|
|
11
10
|
export type BSTNOptKeyOrNode<K, NODE> = BSTNOptKey<K> | NODE;
|
|
12
11
|
export type BSTNRep<K, V, NODE> = BSTNEntry<K, V> | BSTNOptKeyOrNode<K, NODE>;
|
|
12
|
+
export {};
|
package/dist/umd/queue-typed.js
CHANGED
|
@@ -1706,35 +1706,6 @@ var queueTyped = (() => {
|
|
|
1706
1706
|
if (index < min || index > max) throw new RangeError(message);
|
|
1707
1707
|
};
|
|
1708
1708
|
var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
|
|
1709
|
-
function isPrimitiveComparable(value) {
|
|
1710
|
-
const valueType = typeof value;
|
|
1711
|
-
if (valueType === "number") return true;
|
|
1712
|
-
return valueType === "bigint" || valueType === "string" || valueType === "boolean";
|
|
1713
|
-
}
|
|
1714
|
-
function tryObjectToPrimitive(obj) {
|
|
1715
|
-
if (typeof obj.valueOf === "function") {
|
|
1716
|
-
const valueOfResult = obj.valueOf();
|
|
1717
|
-
if (valueOfResult !== obj) {
|
|
1718
|
-
if (isPrimitiveComparable(valueOfResult)) return valueOfResult;
|
|
1719
|
-
if (typeof valueOfResult === "object" && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
if (typeof obj.toString === "function") {
|
|
1723
|
-
const stringResult = obj.toString();
|
|
1724
|
-
if (stringResult !== "[object Object]") return stringResult;
|
|
1725
|
-
}
|
|
1726
|
-
return null;
|
|
1727
|
-
}
|
|
1728
|
-
function isComparable(value, isForceObjectComparable = false) {
|
|
1729
|
-
if (value === null || value === void 0) return false;
|
|
1730
|
-
if (isPrimitiveComparable(value)) return true;
|
|
1731
|
-
if (typeof value !== "object") return false;
|
|
1732
|
-
if (value instanceof Date) return true;
|
|
1733
|
-
if (isForceObjectComparable) return true;
|
|
1734
|
-
const comparableValue = tryObjectToPrimitive(value);
|
|
1735
|
-
if (comparableValue === null || comparableValue === void 0) return false;
|
|
1736
|
-
return isPrimitiveComparable(comparableValue);
|
|
1737
|
-
}
|
|
1738
1709
|
|
|
1739
1710
|
// src/data-structures/queue/deque.ts
|
|
1740
1711
|
var Deque = class extends LinearBase {
|
|
@@ -2473,8 +2444,6 @@ var queueTyped = (() => {
|
|
|
2473
2444
|
this.high = high;
|
|
2474
2445
|
this.includeLow = includeLow;
|
|
2475
2446
|
this.includeHigh = includeHigh;
|
|
2476
|
-
if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
|
|
2477
|
-
if (low > high) throw new RangeError("low must be less than or equal to high");
|
|
2478
2447
|
}
|
|
2479
2448
|
// Determine whether a key is within the range
|
|
2480
2449
|
isInRange(key, comparator) {
|