tree-multimap-typed 2.4.2 → 2.4.4
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/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +10 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +10 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/types/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/types/data-structures/heap/heap.d.ts +3 -7
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
- package/dist/umd/tree-multimap-typed.js +58 -35
- package/dist/umd/tree-multimap-typed.js.map +1 -1
- package/dist/umd/tree-multimap-typed.min.js +2 -2
- package/dist/umd/tree-multimap-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +8 -7
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/tree-map.ts +16 -0
- package/src/data-structures/binary-tree/tree-multi-set.ts +5 -5
- package/src/data-structures/binary-tree/tree-set.ts +16 -0
- package/src/data-structures/graph/abstract-graph.ts +18 -18
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/map-graph.ts +1 -1
- package/src/data-structures/graph/undirected-graph.ts +4 -4
- package/src/data-structures/hash/hash-map.ts +6 -4
- package/src/data-structures/heap/heap.ts +17 -14
- package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
- package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
- package/src/data-structures/queue/deque.ts +1 -1
- package/src/data-structures/stack/stack.ts +1 -1
- package/src/data-structures/trie/trie.ts +10 -5
- package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/types/data-structures/stack/stack.ts +1 -1
|
@@ -27,7 +27,7 @@ export declare abstract class IterableElementBase<E, R> implements Iterable<E> {
|
|
|
27
27
|
* @remarks
|
|
28
28
|
* Time O(1), Space O(1).
|
|
29
29
|
*/
|
|
30
|
-
protected _toElementFn?: (rawElement: R) => E;
|
|
30
|
+
protected readonly _toElementFn?: (rawElement: R) => E;
|
|
31
31
|
/**
|
|
32
32
|
* Exposes the current `toElementFn`, if configured.
|
|
33
33
|
*
|
|
@@ -275,7 +275,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
275
275
|
* @param [options] - Configuration options for the tree.
|
|
276
276
|
*/
|
|
277
277
|
constructor(keysNodesEntriesOrRaws?: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: BinaryTreeOptions<K, V, R>);
|
|
278
|
-
protected _isMapMode: boolean;
|
|
278
|
+
protected readonly _isMapMode: boolean;
|
|
279
279
|
/**
|
|
280
280
|
* Gets whether the tree is in Map mode.
|
|
281
281
|
* @remarks In Map mode (default), values are stored in an external Map, and nodes only hold keys. If false, values are stored directly on the nodes. Time O(1)
|
|
@@ -283,7 +283,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
283
283
|
* @returns True if in Map mode, false otherwise.
|
|
284
284
|
*/
|
|
285
285
|
get isMapMode(): boolean;
|
|
286
|
-
protected _isDuplicate: boolean;
|
|
286
|
+
protected readonly _isDuplicate: boolean;
|
|
287
287
|
/**
|
|
288
288
|
* Gets whether the tree allows duplicate keys.
|
|
289
289
|
* @remarks Time O(1)
|
|
@@ -315,7 +315,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
315
315
|
* @returns The size of the tree.
|
|
316
316
|
*/
|
|
317
317
|
get size(): number;
|
|
318
|
-
protected _NIL: BinaryTreeNode<K, V>;
|
|
318
|
+
protected readonly _NIL: BinaryTreeNode<K, V>;
|
|
319
319
|
/**
|
|
320
320
|
* Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
|
|
321
321
|
* @remarks Time O(1)
|
|
@@ -323,7 +323,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
323
323
|
* @returns The NIL node.
|
|
324
324
|
*/
|
|
325
325
|
get NIL(): BinaryTreeNode<K, V>;
|
|
326
|
-
protected _toEntryFn?: ToEntryFn<K, V, R>;
|
|
326
|
+
protected readonly _toEntryFn?: ToEntryFn<K, V, R>;
|
|
327
327
|
/**
|
|
328
328
|
* Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
329
329
|
* @remarks Time O(1)
|
|
@@ -682,7 +682,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
|
|
|
682
682
|
* @param node - The node.
|
|
683
683
|
* @returns The node's key or undefined.
|
|
684
684
|
*/
|
|
685
|
-
protected _DEFAULT_NODE_CALLBACK:
|
|
685
|
+
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
686
686
|
/**
|
|
687
687
|
* (Protected) Snapshots the current tree's configuration options.
|
|
688
688
|
* @remarks Time O(1)
|
|
@@ -294,7 +294,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
|
|
|
294
294
|
|
|
295
295
|
* @remarks Time O(1) Space O(1)
|
|
296
296
|
*/
|
|
297
|
-
protected _comparator: Comparator<K>;
|
|
297
|
+
protected readonly _comparator: Comparator<K>;
|
|
298
298
|
/**
|
|
299
299
|
* Gets the comparator function used by the tree.
|
|
300
300
|
* @remarks Time O(1)
|
|
@@ -185,4 +185,14 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
185
185
|
* @param options Inclusive/exclusive bounds (defaults to inclusive).
|
|
186
186
|
*/
|
|
187
187
|
rangeSearch(range: [K, K], options?: TreeMapRangeOptions): Array<[K, V | undefined]>;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a shallow clone of this map.
|
|
190
|
+
* @remarks Time O(n log n), Space O(n)
|
|
191
|
+
* @example
|
|
192
|
+
* const original = new TreeMap([['a', 1], ['b', 2]]);
|
|
193
|
+
* const copy = original.clone();
|
|
194
|
+
* copy.set('c', 3);
|
|
195
|
+
* original.has('c'); // false (original unchanged)
|
|
196
|
+
*/
|
|
197
|
+
clone(): TreeMap<K, V>;
|
|
188
198
|
}
|
|
@@ -178,4 +178,14 @@ export declare class TreeSet<K = any, R = K> implements Iterable<K> {
|
|
|
178
178
|
* @param options Inclusive/exclusive bounds (defaults to inclusive).
|
|
179
179
|
*/
|
|
180
180
|
rangeSearch(range: [K, K], options?: TreeSetRangeOptions): K[];
|
|
181
|
+
/**
|
|
182
|
+
* Creates a shallow clone of this set.
|
|
183
|
+
* @remarks Time O(n log n), Space O(n)
|
|
184
|
+
* @example
|
|
185
|
+
* const original = new TreeSet([1, 2, 3]);
|
|
186
|
+
* const copy = original.clone();
|
|
187
|
+
* copy.add(4);
|
|
188
|
+
* original.has(4); // false (original unchanged)
|
|
189
|
+
*/
|
|
190
|
+
clone(): TreeSet<K>;
|
|
181
191
|
}
|
|
@@ -170,7 +170,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
170
170
|
* @returns DirectedGraph with all keys added.
|
|
171
171
|
* @remarks Time O(V), Space O(V)
|
|
172
172
|
*/
|
|
173
|
-
static fromKeys<K extends VertexKey>(keys: Iterable<K>): DirectedGraph<K,
|
|
173
|
+
static fromKeys<K extends VertexKey>(keys: Iterable<K>): DirectedGraph<K, undefined, DirectedVertex<K>, DirectedEdge<undefined>>;
|
|
174
174
|
/**
|
|
175
175
|
* Construct a directed graph from `[key, value]` entries.
|
|
176
176
|
* @template V - Vertex value type.
|
|
@@ -178,7 +178,7 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
|
|
|
178
178
|
* @returns DirectedGraph with all vertices added.
|
|
179
179
|
* @remarks Time O(V), Space O(V)
|
|
180
180
|
*/
|
|
181
|
-
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): DirectedGraph<V,
|
|
181
|
+
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): DirectedGraph<V, undefined, DirectedVertex<V>, DirectedEdge<undefined>>;
|
|
182
182
|
/**
|
|
183
183
|
* Create a directed vertex instance. Does not insert into the graph.
|
|
184
184
|
* @param key - Vertex identifier.
|
|
@@ -200,7 +200,7 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
200
200
|
* @returns UndirectedGraph with all keys added.
|
|
201
201
|
* @remarks Time O(V), Space O(V)
|
|
202
202
|
*/
|
|
203
|
-
static fromKeys<K extends VertexKey>(keys: Iterable<K>): UndirectedGraph<K,
|
|
203
|
+
static fromKeys<K extends VertexKey>(keys: Iterable<K>): UndirectedGraph<K, undefined, UndirectedVertex<K>, UndirectedEdge<undefined>>;
|
|
204
204
|
/**
|
|
205
205
|
* Construct an undirected graph from `[key, value]` entries.
|
|
206
206
|
* @template V - Vertex value type.
|
|
@@ -208,7 +208,7 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
208
208
|
* @returns UndirectedGraph with all vertices added.
|
|
209
209
|
* @remarks Time O(V), Space O(V)
|
|
210
210
|
*/
|
|
211
|
-
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): UndirectedGraph<V,
|
|
211
|
+
static fromEntries<V>(entries: Iterable<[VertexKey, V]>): UndirectedGraph<V, undefined, UndirectedVertex<V>, UndirectedEdge<undefined>>;
|
|
212
212
|
/**
|
|
213
213
|
* Create an undirected vertex instance. Does not insert into the graph.
|
|
214
214
|
* @param key - Vertex identifier.
|
|
@@ -175,7 +175,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
175
175
|
* @returns Map of object→value.
|
|
176
176
|
*/
|
|
177
177
|
get objMap(): Map<object, V>;
|
|
178
|
-
protected _toEntryFn?: (rawElement: R) => [K, V];
|
|
178
|
+
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
179
179
|
/**
|
|
180
180
|
* Get the raw→entry converter function if present.
|
|
181
181
|
* @remarks Time O(1), Space O(1)
|
|
@@ -346,7 +346,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
346
346
|
* @returns Tail node or sentinel.
|
|
347
347
|
*/
|
|
348
348
|
get tail(): HashMapLinkedNode<K, V | undefined>;
|
|
349
|
-
protected _toEntryFn?: (rawElement: R) => [K, V];
|
|
349
|
+
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
350
350
|
get toEntryFn(): ((rawElement: R) => [K, V]) | undefined;
|
|
351
351
|
protected _size: number;
|
|
352
352
|
get size(): number;
|
|
@@ -414,12 +414,8 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
414
414
|
* @returns A new heap with mapped elements.
|
|
415
415
|
*/
|
|
416
416
|
mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
|
|
417
|
-
protected _DEFAULT_COMPARATOR:
|
|
418
|
-
protected _comparator: Comparator<E>;
|
|
419
|
-
* Get the comparator used to order elements.
|
|
420
|
-
* @remarks Time O(1), Space O(1)
|
|
421
|
-
* @returns Comparator function.
|
|
422
|
-
*/
|
|
417
|
+
protected readonly _DEFAULT_COMPARATOR: Comparator<E>;
|
|
418
|
+
protected readonly _comparator: Comparator<E>;
|
|
423
419
|
/**
|
|
424
420
|
* Get the comparator used to order elements.
|
|
425
421
|
* @remarks Time O(1), Space O(1)
|
|
@@ -501,7 +497,7 @@ export declare class FibonacciHeap<E> {
|
|
|
501
497
|
* @returns Min node or undefined.
|
|
502
498
|
*/
|
|
503
499
|
get min(): FibonacciHeapNode<E> | undefined;
|
|
504
|
-
protected _comparator: Comparator<E>;
|
|
500
|
+
protected readonly _comparator: Comparator<E>;
|
|
505
501
|
get comparator(): Comparator<E>;
|
|
506
502
|
clear(): void;
|
|
507
503
|
add(element: E): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BSTOptions } from './bst';
|
|
2
|
-
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R
|
|
2
|
+
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { LinearBaseOptions } from '../base';
|
|
2
|
-
export type DoublyLinkedListOptions<E, R> = LinearBaseOptions<E, R
|
|
2
|
+
export type DoublyLinkedListOptions<E, R> = LinearBaseOptions<E, R>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { LinearBaseOptions } from '../base';
|
|
2
|
-
export type SinglyLinkedListOptions<E, R> = LinearBaseOptions<E, R
|
|
2
|
+
export type SinglyLinkedListOptions<E, R> = LinearBaseOptions<E, R>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { HeapOptions } from '../heap';
|
|
2
|
-
export type PriorityQueueOptions<E, R> = HeapOptions<E, R
|
|
2
|
+
export type PriorityQueueOptions<E, R> = HeapOptions<E, R>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IterableElementBaseOptions } from '../base';
|
|
2
|
-
export type StackOptions<E, R> = IterableElementBaseOptions<E, R
|
|
2
|
+
export type StackOptions<E, R> = IterableElementBaseOptions<E, R>;
|
|
@@ -1026,8 +1026,9 @@ var treeMultimapTyped = (() => {
|
|
|
1026
1026
|
const cur = node;
|
|
1027
1027
|
node = node.next;
|
|
1028
1028
|
if (predicate(cur.key, cur.value, i++, this)) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1029
|
+
const keyToCheck = cur.key;
|
|
1030
|
+
if (isWeakKey(keyToCheck)) {
|
|
1031
|
+
this._objMap.delete(keyToCheck);
|
|
1031
1032
|
} else {
|
|
1032
1033
|
const hash = this._hashFn(cur.key);
|
|
1033
1034
|
delete this._noObjMap[hash];
|
|
@@ -1540,7 +1541,7 @@ var treeMultimapTyped = (() => {
|
|
|
1540
1541
|
*/
|
|
1541
1542
|
constructor(elements = [], options) {
|
|
1542
1543
|
super(options);
|
|
1543
|
-
__publicField(this, "_equals", Object.is);
|
|
1544
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
1544
1545
|
__publicField(this, "_head");
|
|
1545
1546
|
__publicField(this, "_tail");
|
|
1546
1547
|
__publicField(this, "_length", 0);
|
|
@@ -1628,6 +1629,7 @@ var treeMultimapTyped = (() => {
|
|
|
1628
1629
|
* @returns Removed element or undefined.
|
|
1629
1630
|
*/
|
|
1630
1631
|
pop() {
|
|
1632
|
+
var _a;
|
|
1631
1633
|
if (!this.head) return void 0;
|
|
1632
1634
|
if (this.head === this.tail) {
|
|
1633
1635
|
const value2 = this.head.value;
|
|
@@ -1637,8 +1639,8 @@ var treeMultimapTyped = (() => {
|
|
|
1637
1639
|
return value2;
|
|
1638
1640
|
}
|
|
1639
1641
|
let current = this.head;
|
|
1640
|
-
while (current.next !== this.tail) current = current.next;
|
|
1641
|
-
const value = this.tail.value;
|
|
1642
|
+
while (current.next && current.next !== this.tail) current = current.next;
|
|
1643
|
+
const value = (_a = this.tail) == null ? void 0 : _a.value;
|
|
1642
1644
|
current.next = void 0;
|
|
1643
1645
|
this._tail = current;
|
|
1644
1646
|
this._length--;
|
|
@@ -1726,8 +1728,8 @@ var treeMultimapTyped = (() => {
|
|
|
1726
1728
|
at(index) {
|
|
1727
1729
|
if (index < 0 || index >= this._length) return void 0;
|
|
1728
1730
|
let current = this.head;
|
|
1729
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1730
|
-
return current.value;
|
|
1731
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1732
|
+
return current == null ? void 0 : current.value;
|
|
1731
1733
|
}
|
|
1732
1734
|
/**
|
|
1733
1735
|
* Type guard: check whether the input is a SinglyLinkedListNode.
|
|
@@ -1747,7 +1749,7 @@ var treeMultimapTyped = (() => {
|
|
|
1747
1749
|
getNodeAt(index) {
|
|
1748
1750
|
if (index < 0 || index >= this._length) return void 0;
|
|
1749
1751
|
let current = this.head;
|
|
1750
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1752
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1751
1753
|
return current;
|
|
1752
1754
|
}
|
|
1753
1755
|
/**
|
|
@@ -2261,7 +2263,7 @@ var treeMultimapTyped = (() => {
|
|
|
2261
2263
|
*/
|
|
2262
2264
|
constructor(elements = [], options) {
|
|
2263
2265
|
super(options);
|
|
2264
|
-
__publicField(this, "_equals", Object.is);
|
|
2266
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
2265
2267
|
__publicField(this, "_head");
|
|
2266
2268
|
__publicField(this, "_tail");
|
|
2267
2269
|
__publicField(this, "_length", 0);
|
|
@@ -2449,8 +2451,8 @@ var treeMultimapTyped = (() => {
|
|
|
2449
2451
|
at(index) {
|
|
2450
2452
|
if (index < 0 || index >= this._length) return void 0;
|
|
2451
2453
|
let current = this.head;
|
|
2452
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
2453
|
-
return current.value;
|
|
2454
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
2455
|
+
return current == null ? void 0 : current.value;
|
|
2454
2456
|
}
|
|
2455
2457
|
/**
|
|
2456
2458
|
* Get the node reference at a given index.
|
|
@@ -2461,7 +2463,7 @@ var treeMultimapTyped = (() => {
|
|
|
2461
2463
|
getNodeAt(index) {
|
|
2462
2464
|
if (index < 0 || index >= this._length) return void 0;
|
|
2463
2465
|
let current = this.head;
|
|
2464
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
2466
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
2465
2467
|
return current;
|
|
2466
2468
|
}
|
|
2467
2469
|
/**
|
|
@@ -2967,7 +2969,7 @@ var treeMultimapTyped = (() => {
|
|
|
2967
2969
|
*/
|
|
2968
2970
|
constructor(elements = [], options) {
|
|
2969
2971
|
super(options);
|
|
2970
|
-
__publicField(this, "_equals", Object.is);
|
|
2972
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
2971
2973
|
__publicField(this, "_elements", []);
|
|
2972
2974
|
this.pushMany(elements);
|
|
2973
2975
|
}
|
|
@@ -3596,7 +3598,7 @@ var treeMultimapTyped = (() => {
|
|
|
3596
3598
|
*/
|
|
3597
3599
|
constructor(elements = [], options) {
|
|
3598
3600
|
super(options);
|
|
3599
|
-
__publicField(this, "_equals", Object.is);
|
|
3601
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
3600
3602
|
__publicField(this, "_bucketSize", 1 << 12);
|
|
3601
3603
|
__publicField(this, "_bucketFirst", 0);
|
|
3602
3604
|
__publicField(this, "_firstInBucket", 0);
|
|
@@ -4665,11 +4667,6 @@ var treeMultimapTyped = (() => {
|
|
|
4665
4667
|
}
|
|
4666
4668
|
return out;
|
|
4667
4669
|
}
|
|
4668
|
-
/**
|
|
4669
|
-
* Get the comparator used to order elements.
|
|
4670
|
-
* @remarks Time O(1), Space O(1)
|
|
4671
|
-
* @returns Comparator function.
|
|
4672
|
-
*/
|
|
4673
4670
|
/**
|
|
4674
4671
|
* Get the comparator used to order elements.
|
|
4675
4672
|
* @remarks Time O(1), Space O(1)
|
|
@@ -4718,8 +4715,7 @@ var treeMultimapTyped = (() => {
|
|
|
4718
4715
|
*/
|
|
4719
4716
|
_createInstance(options) {
|
|
4720
4717
|
const Ctor = this.constructor;
|
|
4721
|
-
|
|
4722
|
-
return next;
|
|
4718
|
+
return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
|
|
4723
4719
|
}
|
|
4724
4720
|
/**
|
|
4725
4721
|
* (Protected) Create a like-kind instance seeded by elements.
|
|
@@ -5756,8 +5752,8 @@ var treeMultimapTyped = (() => {
|
|
|
5756
5752
|
const Ctor = this.constructor;
|
|
5757
5753
|
const instance = new Ctor();
|
|
5758
5754
|
const graph = _options == null ? void 0 : _options.graph;
|
|
5759
|
-
if (graph) instance
|
|
5760
|
-
else instance
|
|
5755
|
+
if (graph) instance["_options"] = { ...instance["_options"], ...graph };
|
|
5756
|
+
else instance["_options"] = { ...instance["_options"], ...this._options };
|
|
5761
5757
|
return instance;
|
|
5762
5758
|
}
|
|
5763
5759
|
/**
|
|
@@ -5790,12 +5786,10 @@ var treeMultimapTyped = (() => {
|
|
|
5790
5786
|
const [va, vb] = ends;
|
|
5791
5787
|
const ka = va.key;
|
|
5792
5788
|
const kb = vb.key;
|
|
5793
|
-
const hasA = g.hasVertex ? g.hasVertex(ka) : false;
|
|
5794
|
-
const hasB = g.hasVertex ? g.hasVertex(kb) : false;
|
|
5789
|
+
const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
|
|
5790
|
+
const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
|
|
5795
5791
|
if (hasA && hasB) {
|
|
5796
|
-
const
|
|
5797
|
-
const val = e.value;
|
|
5798
|
-
const newEdge = g.createEdge(ka, kb, w, val);
|
|
5792
|
+
const newEdge = g.createEdge(ka, kb, e.weight, e.value);
|
|
5799
5793
|
g._addEdge(newEdge);
|
|
5800
5794
|
}
|
|
5801
5795
|
}
|
|
@@ -6960,7 +6954,7 @@ var treeMultimapTyped = (() => {
|
|
|
6960
6954
|
__publicField(this, "_size", 0);
|
|
6961
6955
|
__publicField(this, "_NIL", new BinaryTreeNode(NaN));
|
|
6962
6956
|
__publicField(this, "_toEntryFn");
|
|
6963
|
-
__publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node
|
|
6957
|
+
__publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node == null ? void 0 : node.key, "_DEFAULT_NODE_CALLBACK"));
|
|
6964
6958
|
if (options) {
|
|
6965
6959
|
const { iterationType, toEntryFn, isMapMode, isDuplicate } = options;
|
|
6966
6960
|
if (iterationType) this.iterationType = iterationType;
|
|
@@ -12077,6 +12071,21 @@ var treeMultimapTyped = (() => {
|
|
|
12077
12071
|
}
|
|
12078
12072
|
return out;
|
|
12079
12073
|
}
|
|
12074
|
+
/**
|
|
12075
|
+
* Creates a shallow clone of this set.
|
|
12076
|
+
* @remarks Time O(n log n), Space O(n)
|
|
12077
|
+
* @example
|
|
12078
|
+
* const original = new TreeSet([1, 2, 3]);
|
|
12079
|
+
* const copy = original.clone();
|
|
12080
|
+
* copy.add(4);
|
|
12081
|
+
* original.has(4); // false (original unchanged)
|
|
12082
|
+
*/
|
|
12083
|
+
clone() {
|
|
12084
|
+
return new _TreeSet2(this, {
|
|
12085
|
+
comparator: __privateGet(this, _isDefaultComparator) ? void 0 : __privateGet(this, _userComparator),
|
|
12086
|
+
isMapMode: __privateGet(this, _core).isMapMode
|
|
12087
|
+
});
|
|
12088
|
+
}
|
|
12080
12089
|
};
|
|
12081
12090
|
_core = /* @__PURE__ */ new WeakMap();
|
|
12082
12091
|
_isDefaultComparator = /* @__PURE__ */ new WeakMap();
|
|
@@ -12896,6 +12905,21 @@ var treeMultimapTyped = (() => {
|
|
|
12896
12905
|
}
|
|
12897
12906
|
return out;
|
|
12898
12907
|
}
|
|
12908
|
+
/**
|
|
12909
|
+
* Creates a shallow clone of this map.
|
|
12910
|
+
* @remarks Time O(n log n), Space O(n)
|
|
12911
|
+
* @example
|
|
12912
|
+
* const original = new TreeMap([['a', 1], ['b', 2]]);
|
|
12913
|
+
* const copy = original.clone();
|
|
12914
|
+
* copy.set('c', 3);
|
|
12915
|
+
* original.has('c'); // false (original unchanged)
|
|
12916
|
+
*/
|
|
12917
|
+
clone() {
|
|
12918
|
+
return new _TreeMap2(this, {
|
|
12919
|
+
comparator: __privateGet(this, _isDefaultComparator3) ? void 0 : __privateGet(this, _userComparator2),
|
|
12920
|
+
isMapMode: __privateGet(this, _core3).isMapMode
|
|
12921
|
+
});
|
|
12922
|
+
}
|
|
12899
12923
|
};
|
|
12900
12924
|
_core3 = /* @__PURE__ */ new WeakMap();
|
|
12901
12925
|
_isDefaultComparator3 = /* @__PURE__ */ new WeakMap();
|
|
@@ -13113,7 +13137,7 @@ var treeMultimapTyped = (() => {
|
|
|
13113
13137
|
* @remarks Time O(1), Space O(1)
|
|
13114
13138
|
*/
|
|
13115
13139
|
get comparator() {
|
|
13116
|
-
return __privateGet(this, _core4).
|
|
13140
|
+
return __privateGet(this, _core4).comparator;
|
|
13117
13141
|
}
|
|
13118
13142
|
// ━━━ clear ━━━
|
|
13119
13143
|
/**
|
|
@@ -13250,7 +13274,7 @@ var treeMultimapTyped = (() => {
|
|
|
13250
13274
|
filter(predicate) {
|
|
13251
13275
|
const result = new _TreeMultiSet2([], {
|
|
13252
13276
|
comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
|
|
13253
|
-
isMapMode: __privateGet(this, _core4).
|
|
13277
|
+
isMapMode: __privateGet(this, _core4).isMapMode
|
|
13254
13278
|
});
|
|
13255
13279
|
for (const [k, c] of this.entries()) {
|
|
13256
13280
|
if (predicate(k, c)) {
|
|
@@ -13290,7 +13314,7 @@ var treeMultimapTyped = (() => {
|
|
|
13290
13314
|
map(mapper, options) {
|
|
13291
13315
|
const result = new _TreeMultiSet2([], {
|
|
13292
13316
|
comparator: options == null ? void 0 : options.comparator,
|
|
13293
|
-
isMapMode: __privateGet(this, _core4).
|
|
13317
|
+
isMapMode: __privateGet(this, _core4).isMapMode
|
|
13294
13318
|
});
|
|
13295
13319
|
for (const [k, c] of this.entries()) {
|
|
13296
13320
|
const [newKey, newCount] = mapper(k, c);
|
|
@@ -13310,7 +13334,7 @@ var treeMultimapTyped = (() => {
|
|
|
13310
13334
|
clone() {
|
|
13311
13335
|
const result = new _TreeMultiSet2([], {
|
|
13312
13336
|
comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
|
|
13313
|
-
isMapMode: __privateGet(this, _core4).
|
|
13337
|
+
isMapMode: __privateGet(this, _core4).isMapMode
|
|
13314
13338
|
});
|
|
13315
13339
|
for (const [k, c] of this.entries()) {
|
|
13316
13340
|
result.add(k, c);
|
|
@@ -14341,12 +14365,11 @@ var treeMultimapTyped = (() => {
|
|
|
14341
14365
|
*/
|
|
14342
14366
|
_createInstance(options) {
|
|
14343
14367
|
const Ctor = this.constructor;
|
|
14344
|
-
|
|
14368
|
+
return new Ctor([], {
|
|
14345
14369
|
toElementFn: this.toElementFn,
|
|
14346
14370
|
caseSensitive: this.caseSensitive,
|
|
14347
14371
|
...options != null ? options : {}
|
|
14348
14372
|
});
|
|
14349
|
-
return next;
|
|
14350
14373
|
}
|
|
14351
14374
|
/**
|
|
14352
14375
|
* (Protected) Create a like-kind trie and seed it from an iterable.
|