tree-multimap-typed 2.4.1 → 2.4.3
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/tree-map.d.ts +10 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +10 -0
- package/dist/umd/tree-multimap-typed.js +36 -9
- 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/binary-tree/tree-map.ts +16 -0
- package/src/data-structures/binary-tree/tree-set.ts +16 -0
- package/src/data-structures/trie/trie.ts +6 -8
|
@@ -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
|
}
|
|
@@ -12077,6 +12077,21 @@ var treeMultimapTyped = (() => {
|
|
|
12077
12077
|
}
|
|
12078
12078
|
return out;
|
|
12079
12079
|
}
|
|
12080
|
+
/**
|
|
12081
|
+
* Creates a shallow clone of this set.
|
|
12082
|
+
* @remarks Time O(n log n), Space O(n)
|
|
12083
|
+
* @example
|
|
12084
|
+
* const original = new TreeSet([1, 2, 3]);
|
|
12085
|
+
* const copy = original.clone();
|
|
12086
|
+
* copy.add(4);
|
|
12087
|
+
* original.has(4); // false (original unchanged)
|
|
12088
|
+
*/
|
|
12089
|
+
clone() {
|
|
12090
|
+
return new _TreeSet2(this, {
|
|
12091
|
+
comparator: __privateGet(this, _isDefaultComparator) ? void 0 : __privateGet(this, _userComparator),
|
|
12092
|
+
isMapMode: __privateGet(this, _core).isMapMode
|
|
12093
|
+
});
|
|
12094
|
+
}
|
|
12080
12095
|
};
|
|
12081
12096
|
_core = /* @__PURE__ */ new WeakMap();
|
|
12082
12097
|
_isDefaultComparator = /* @__PURE__ */ new WeakMap();
|
|
@@ -12896,6 +12911,21 @@ var treeMultimapTyped = (() => {
|
|
|
12896
12911
|
}
|
|
12897
12912
|
return out;
|
|
12898
12913
|
}
|
|
12914
|
+
/**
|
|
12915
|
+
* Creates a shallow clone of this map.
|
|
12916
|
+
* @remarks Time O(n log n), Space O(n)
|
|
12917
|
+
* @example
|
|
12918
|
+
* const original = new TreeMap([['a', 1], ['b', 2]]);
|
|
12919
|
+
* const copy = original.clone();
|
|
12920
|
+
* copy.set('c', 3);
|
|
12921
|
+
* original.has('c'); // false (original unchanged)
|
|
12922
|
+
*/
|
|
12923
|
+
clone() {
|
|
12924
|
+
return new _TreeMap2(this, {
|
|
12925
|
+
comparator: __privateGet(this, _isDefaultComparator3) ? void 0 : __privateGet(this, _userComparator2),
|
|
12926
|
+
isMapMode: __privateGet(this, _core3).isMapMode
|
|
12927
|
+
});
|
|
12928
|
+
}
|
|
12899
12929
|
};
|
|
12900
12930
|
_core3 = /* @__PURE__ */ new WeakMap();
|
|
12901
12931
|
_isDefaultComparator3 = /* @__PURE__ */ new WeakMap();
|
|
@@ -14252,20 +14282,17 @@ var treeMultimapTyped = (() => {
|
|
|
14252
14282
|
prefix = this._caseProcess(prefix);
|
|
14253
14283
|
const words = [];
|
|
14254
14284
|
let found = 0;
|
|
14255
|
-
|
|
14256
|
-
for (const char of node.children
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
dfs(charNode, word.concat(char));
|
|
14260
|
-
}
|
|
14285
|
+
const dfs = /* @__PURE__ */ __name((node, word) => {
|
|
14286
|
+
for (const [char, childNode] of node.children) {
|
|
14287
|
+
if (found >= max) return;
|
|
14288
|
+
dfs(childNode, word + char);
|
|
14261
14289
|
}
|
|
14262
14290
|
if (node.isEnd) {
|
|
14263
|
-
if (found
|
|
14291
|
+
if (found >= max) return;
|
|
14264
14292
|
words.push(word);
|
|
14265
14293
|
found++;
|
|
14266
14294
|
}
|
|
14267
|
-
}
|
|
14268
|
-
__name(dfs, "dfs");
|
|
14295
|
+
}, "dfs");
|
|
14269
14296
|
let startNode = this.root;
|
|
14270
14297
|
if (prefix) {
|
|
14271
14298
|
for (const c of prefix) {
|