tree-multimap-typed 2.4.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-multimap-typed",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "TreeMultiMap - A sorted map that allows multiple values per key",
5
5
  "browser": "dist/umd/tree-multimap-typed.min.js",
6
6
  "umd:main": "dist/umd/tree-multimap-typed.min.js",
@@ -217,6 +217,6 @@
217
217
  "typescript": "^4.9.5"
218
218
  },
219
219
  "dependencies": {
220
- "data-structure-typed": "^2.4.2"
220
+ "data-structure-typed": "^2.4.3"
221
221
  }
222
222
  }
@@ -436,4 +436,20 @@ export class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[K, V | u
436
436
 
437
437
  return out;
438
438
  }
439
+
440
+ /**
441
+ * Creates a shallow clone of this map.
442
+ * @remarks Time O(n log n), Space O(n)
443
+ * @example
444
+ * const original = new TreeMap([['a', 1], ['b', 2]]);
445
+ * const copy = original.clone();
446
+ * copy.set('c', 3);
447
+ * original.has('c'); // false (original unchanged)
448
+ */
449
+ clone(): TreeMap<K, V> {
450
+ return new TreeMap<K, V>(this, {
451
+ comparator: this.#isDefaultComparator ? undefined : this.#userComparator,
452
+ isMapMode: this.#core.isMapMode
453
+ });
454
+ }
439
455
  }
@@ -404,4 +404,20 @@ export class TreeSet<K = any, R = K> implements Iterable<K> {
404
404
 
405
405
  return out;
406
406
  }
407
+
408
+ /**
409
+ * Creates a shallow clone of this set.
410
+ * @remarks Time O(n log n), Space O(n)
411
+ * @example
412
+ * const original = new TreeSet([1, 2, 3]);
413
+ * const copy = original.clone();
414
+ * copy.add(4);
415
+ * original.has(4); // false (original unchanged)
416
+ */
417
+ clone(): TreeSet<K> {
418
+ return new TreeSet<K>(this, {
419
+ comparator: this.#isDefaultComparator ? undefined : this.#userComparator,
420
+ isMapMode: this.#core.isMapMode
421
+ });
422
+ }
407
423
  }