data-structure-typed 2.5.1 → 2.5.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/CHANGELOG.md +5 -1
- package/MIGRATION.md +169 -0
- package/README.md +135 -23
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +6460 -1591
- package/dist/cjs/graph.cjs +440 -20
- package/dist/cjs/hash.cjs +125 -22
- package/dist/cjs/heap.cjs +196 -47
- package/dist/cjs/index.cjs +8486 -2429
- package/dist/cjs/linked-list.cjs +456 -31
- package/dist/cjs/matrix.cjs +79 -9
- package/dist/cjs/priority-queue.cjs +193 -44
- package/dist/cjs/queue.cjs +391 -2
- package/dist/cjs/stack.cjs +92 -6
- package/dist/cjs/trie.cjs +122 -28
- package/dist/cjs-legacy/binary-tree.cjs +6484 -1612
- package/dist/cjs-legacy/graph.cjs +440 -20
- package/dist/cjs-legacy/hash.cjs +125 -22
- package/dist/cjs-legacy/heap.cjs +196 -47
- package/dist/cjs-legacy/index.cjs +8654 -2594
- package/dist/cjs-legacy/linked-list.cjs +456 -31
- package/dist/cjs-legacy/matrix.cjs +79 -9
- package/dist/cjs-legacy/priority-queue.cjs +193 -44
- package/dist/cjs-legacy/queue.cjs +391 -2
- package/dist/cjs-legacy/stack.cjs +92 -6
- package/dist/cjs-legacy/trie.cjs +122 -28
- package/dist/esm/binary-tree.mjs +6460 -1591
- package/dist/esm/graph.mjs +440 -20
- package/dist/esm/hash.mjs +125 -22
- package/dist/esm/heap.mjs +196 -47
- package/dist/esm/index.mjs +8486 -2430
- package/dist/esm/linked-list.mjs +456 -31
- package/dist/esm/matrix.mjs +79 -9
- package/dist/esm/priority-queue.mjs +193 -44
- package/dist/esm/queue.mjs +391 -2
- package/dist/esm/stack.mjs +92 -6
- package/dist/esm/trie.mjs +122 -28
- package/dist/esm-legacy/binary-tree.mjs +6484 -1612
- package/dist/esm-legacy/graph.mjs +440 -20
- package/dist/esm-legacy/hash.mjs +125 -22
- package/dist/esm-legacy/heap.mjs +196 -47
- package/dist/esm-legacy/index.mjs +8654 -2595
- package/dist/esm-legacy/linked-list.mjs +456 -31
- package/dist/esm-legacy/matrix.mjs +79 -9
- package/dist/esm-legacy/priority-queue.mjs +193 -44
- package/dist/esm-legacy/queue.mjs +391 -2
- package/dist/esm-legacy/stack.mjs +92 -6
- package/dist/esm-legacy/trie.mjs +122 -28
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +98 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +112 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +214 -13
- package/dist/types/data-structures/binary-tree/bst.d.ts +294 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +155 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +48 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1370 -323
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1329 -316
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +1116 -295
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1330 -326
- package/dist/types/data-structures/graph/directed-graph.d.ts +80 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +72 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +95 -6
- package/dist/types/data-structures/heap/heap.d.ts +154 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +143 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +144 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +64 -0
- package/dist/types/data-structures/queue/deque.d.ts +142 -0
- package/dist/types/data-structures/queue/queue.d.ts +109 -0
- package/dist/types/data-structures/stack/stack.d.ts +82 -2
- package/dist/types/data-structures/trie/trie.d.ts +96 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/data-structure-typed.js +8623 -2564
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +696 -194
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
- package/docs-site-docusaurus/docs/api/classes/BST.md +639 -189
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +148 -160
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +105 -91
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +104 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +51 -51
- package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
- package/docs-site-docusaurus/docs/api/classes/Queue.md +112 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +708 -206
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +79 -79
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +236 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +232 -32
- package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -5
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -3
- package/docs-site-docusaurus/docs/guide/faq.md +233 -0
- package/docs-site-docusaurus/docs/guide/guides.md +43 -58
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +75 -176
- package/docs-site-docusaurus/docs/guide/overview.md +132 -11
- package/docs-site-docusaurus/docs/guide/performance.md +2 -0
- package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
- package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
- package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
- package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
- package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
- package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
- package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
- package/docs-site-docusaurus/docusaurus.config.ts +1 -1
- package/docs-site-docusaurus/src/pages/index.tsx +55 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/llms.txt +37 -0
- package/package.json +65 -56
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +99 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
- package/src/data-structures/binary-tree/binary-tree.ts +239 -78
- package/src/data-structures/binary-tree/bst.ts +542 -13
- package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +1223 -261
- package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
- package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
- package/src/data-structures/binary-tree/tree-set.ts +1018 -99
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +102 -16
- package/src/data-structures/heap/heap.ts +153 -23
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
- package/src/data-structures/matrix/matrix.ts +65 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +130 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +86 -2
- package/src/interfaces/binary-tree.ts +1 -9
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
|
@@ -193,14 +193,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
|
|
196
|
-
* @example
|
|
197
|
-
* // Check empty
|
|
198
|
-
* console.log(new TreeMap().isEmpty()); // true;
|
|
199
|
-
*/
|
|
200
|
-
isEmpty(): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Set or overwrite a value for a key.
|
|
203
|
-
* @remarks Expected time O(log n)
|
|
204
196
|
|
|
205
197
|
|
|
206
198
|
|
|
@@ -241,6 +233,14 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
241
233
|
|
|
242
234
|
|
|
243
235
|
|
|
236
|
+
* @example
|
|
237
|
+
* // Check empty
|
|
238
|
+
* console.log(new TreeMap().isEmpty()); // true;
|
|
239
|
+
*/
|
|
240
|
+
isEmpty(): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Set or overwrite a value for a key.
|
|
243
|
+
* @remarks Expected time O(log n)
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
|
|
@@ -348,31 +348,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
348
348
|
|
|
349
349
|
|
|
350
350
|
|
|
351
|
-
* @example
|
|
352
|
-
* // Sorted dictionary for a contact book
|
|
353
|
-
* const contacts = new TreeMap<string, string>([
|
|
354
|
-
* ['Bob', '555-0102'],
|
|
355
|
-
* ['Alice', '555-0101'],
|
|
356
|
-
* ['Charlie', '555-0103']
|
|
357
|
-
* ]);
|
|
358
|
-
*
|
|
359
|
-
* // Contacts are automatically sorted by name
|
|
360
|
-
* console.log([...contacts.keys()]); // ['Alice', 'Bob', 'Charlie'];
|
|
361
|
-
* console.log(contacts.get('Bob')); // '555-0102';
|
|
362
|
-
*
|
|
363
|
-
* // Find the first contact alphabetically after 'B'
|
|
364
|
-
* console.log(contacts.ceiling('B')); // ['Bob', '555-0102'];
|
|
365
|
-
*
|
|
366
|
-
* // Find contacts in range
|
|
367
|
-
* console.log(contacts.rangeSearch(['Alice', 'Bob'])); // [
|
|
368
|
-
* // ['Alice', '555-0101'],
|
|
369
|
-
* // ['Bob', '555-0102']
|
|
370
|
-
* // ];
|
|
371
|
-
*/
|
|
372
|
-
set(key: K, value: V | undefined): this;
|
|
373
|
-
/**
|
|
374
|
-
* Get the value under a key.
|
|
375
|
-
* @remarks Expected time O(log n)
|
|
376
351
|
|
|
377
352
|
|
|
378
353
|
|
|
@@ -453,6 +428,34 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
453
428
|
|
|
454
429
|
|
|
455
430
|
|
|
431
|
+
* @example
|
|
432
|
+
* // Sorted dictionary for a contact book
|
|
433
|
+
* const contacts = new TreeMap<string, string>([
|
|
434
|
+
* ['Bob', '555-0102'],
|
|
435
|
+
* ['Alice', '555-0101'],
|
|
436
|
+
* ['Charlie', '555-0103']
|
|
437
|
+
* ]);
|
|
438
|
+
*
|
|
439
|
+
* // Contacts are automatically sorted by name
|
|
440
|
+
* console.log([...contacts.keys()]); // ['Alice', 'Bob', 'Charlie'];
|
|
441
|
+
* console.log(contacts.get('Bob')); // '555-0102';
|
|
442
|
+
*
|
|
443
|
+
* // Find the first contact alphabetically after 'B'
|
|
444
|
+
* console.log(contacts.ceiling('B')); // ['Bob', '555-0102'];
|
|
445
|
+
*
|
|
446
|
+
* // Find contacts in range
|
|
447
|
+
* console.log(contacts.rangeSearch(['Alice', 'Bob'])); // [
|
|
448
|
+
* // ['Alice', '555-0101'],
|
|
449
|
+
* // ['Bob', '555-0102']
|
|
450
|
+
* // ];
|
|
451
|
+
*/
|
|
452
|
+
set(key: K, value: V | undefined): this;
|
|
453
|
+
/**
|
|
454
|
+
* Set multiple key-value pairs at once.
|
|
455
|
+
* @remarks Expected time O(m log n), where m is the number of entries.
|
|
456
|
+
* @param entries - Iterable of `[key, value]` tuples.
|
|
457
|
+
* @returns Array of booleans indicating whether each entry was successfully set.
|
|
458
|
+
|
|
456
459
|
|
|
457
460
|
|
|
458
461
|
|
|
@@ -468,6 +471,16 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
468
471
|
|
|
469
472
|
|
|
470
473
|
|
|
474
|
+
* @example
|
|
475
|
+
* // Set multiple key-value pairs
|
|
476
|
+
* const tm = new TreeMap<number, string>();
|
|
477
|
+
* tm.setMany([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
478
|
+
* console.log(tm.size); // 3;
|
|
479
|
+
*/
|
|
480
|
+
setMany(entries: Iterable<[K, V | undefined]>): boolean[];
|
|
481
|
+
/**
|
|
482
|
+
* Get the value under a key.
|
|
483
|
+
* @remarks Expected time O(log n)
|
|
471
484
|
|
|
472
485
|
|
|
473
486
|
|
|
@@ -522,22 +535,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
522
535
|
|
|
523
536
|
|
|
524
537
|
|
|
525
|
-
* @example
|
|
526
|
-
* // Configuration registry with typed lookups
|
|
527
|
-
* const config = new TreeMap<string, number>([
|
|
528
|
-
* ['maxRetries', 3],
|
|
529
|
-
* ['timeout', 5000],
|
|
530
|
-
* ['poolSize', 10]
|
|
531
|
-
* ]);
|
|
532
|
-
*
|
|
533
|
-
* console.log(config.get('timeout')); // 5000;
|
|
534
|
-
* console.log(config.get('missing')); // undefined;
|
|
535
|
-
* console.log(config.size); // 3;
|
|
536
|
-
*/
|
|
537
|
-
get(key: K): V | undefined;
|
|
538
|
-
/**
|
|
539
|
-
* Test whether a key exists.
|
|
540
|
-
* @remarks Expected time O(log n)
|
|
541
538
|
|
|
542
539
|
|
|
543
540
|
|
|
@@ -673,6 +670,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
673
670
|
|
|
674
671
|
|
|
675
672
|
|
|
673
|
+
* @example
|
|
674
|
+
* // Configuration registry with typed lookups
|
|
675
|
+
* const config = new TreeMap<string, number>([
|
|
676
|
+
* ['maxRetries', 3],
|
|
677
|
+
* ['timeout', 5000],
|
|
678
|
+
* ['poolSize', 10]
|
|
679
|
+
* ]);
|
|
680
|
+
*
|
|
681
|
+
* console.log(config.get('timeout')); // 5000;
|
|
682
|
+
* console.log(config.get('missing')); // undefined;
|
|
683
|
+
* console.log(config.size); // 3;
|
|
684
|
+
*/
|
|
685
|
+
get(key: K): V | undefined;
|
|
686
|
+
/**
|
|
687
|
+
* Test whether a key exists.
|
|
688
|
+
* @remarks Expected time O(log n)
|
|
676
689
|
|
|
677
690
|
|
|
678
691
|
|
|
@@ -687,22 +700,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
687
700
|
|
|
688
701
|
|
|
689
702
|
|
|
690
|
-
* @example
|
|
691
|
-
* // Feature flag checking
|
|
692
|
-
* const flags = new TreeMap<string, boolean>([
|
|
693
|
-
* ['darkMode', true],
|
|
694
|
-
* ['betaFeature', false],
|
|
695
|
-
* ['notifications', true]
|
|
696
|
-
* ]);
|
|
697
|
-
*
|
|
698
|
-
* console.log(flags.has('darkMode')); // true;
|
|
699
|
-
* console.log(flags.has('unknownFlag')); // false;
|
|
700
|
-
*/
|
|
701
|
-
has(key: K): boolean;
|
|
702
|
-
/**
|
|
703
|
-
* Delete a key.
|
|
704
|
-
* @returns `true` if the key existed; otherwise `false`.
|
|
705
|
-
* @remarks Expected time O(log n)
|
|
706
703
|
|
|
707
704
|
|
|
708
705
|
|
|
@@ -852,22 +849,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
852
849
|
|
|
853
850
|
|
|
854
851
|
|
|
855
|
-
* @example
|
|
856
|
-
* // Session management with expiry
|
|
857
|
-
* const sessions = new TreeMap<string, number>([
|
|
858
|
-
* ['sess_abc', Date.now()],
|
|
859
|
-
* ['sess_def', Date.now()],
|
|
860
|
-
* ['sess_ghi', Date.now()]
|
|
861
|
-
* ]);
|
|
862
|
-
*
|
|
863
|
-
* console.log(sessions.size); // 3;
|
|
864
|
-
* sessions.delete('sess_def');
|
|
865
|
-
* console.log(sessions.has('sess_def')); // false;
|
|
866
|
-
* console.log(sessions.size); // 2;
|
|
867
|
-
*/
|
|
868
|
-
delete(key: K): boolean;
|
|
869
|
-
/**
|
|
870
|
-
* Remove all entries.
|
|
871
852
|
|
|
872
853
|
|
|
873
854
|
|
|
@@ -894,6 +875,22 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
894
875
|
|
|
895
876
|
|
|
896
877
|
|
|
878
|
+
* @example
|
|
879
|
+
* // Feature flag checking
|
|
880
|
+
* const flags = new TreeMap<string, boolean>([
|
|
881
|
+
* ['darkMode', true],
|
|
882
|
+
* ['betaFeature', false],
|
|
883
|
+
* ['notifications', true]
|
|
884
|
+
* ]);
|
|
885
|
+
*
|
|
886
|
+
* console.log(flags.has('darkMode')); // true;
|
|
887
|
+
* console.log(flags.has('unknownFlag')); // false;
|
|
888
|
+
*/
|
|
889
|
+
has(key: K): boolean;
|
|
890
|
+
/**
|
|
891
|
+
* Delete a key.
|
|
892
|
+
* @returns `true` if the key existed; otherwise `false`.
|
|
893
|
+
* @remarks Expected time O(log n)
|
|
897
894
|
|
|
898
895
|
|
|
899
896
|
|
|
@@ -1006,15 +1003,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1006
1003
|
|
|
1007
1004
|
|
|
1008
1005
|
|
|
1009
|
-
* @example
|
|
1010
|
-
* // Remove all
|
|
1011
|
-
* const tm = new TreeMap<number, string>([[1, 'a']]);
|
|
1012
|
-
* tm.clear();
|
|
1013
|
-
* console.log(tm.isEmpty()); // true;
|
|
1014
|
-
*/
|
|
1015
|
-
clear(): void;
|
|
1016
|
-
/**
|
|
1017
|
-
* Iterate over keys in ascending order.
|
|
1018
1006
|
|
|
1019
1007
|
|
|
1020
1008
|
|
|
@@ -1092,6 +1080,29 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1092
1080
|
|
|
1093
1081
|
|
|
1094
1082
|
|
|
1083
|
+
* @example
|
|
1084
|
+
* // Session management with expiry
|
|
1085
|
+
* const sessions = new TreeMap<string, number>([
|
|
1086
|
+
* ['sess_abc', Date.now()],
|
|
1087
|
+
* ['sess_def', Date.now()],
|
|
1088
|
+
* ['sess_ghi', Date.now()]
|
|
1089
|
+
* ]);
|
|
1090
|
+
*
|
|
1091
|
+
* console.log(sessions.size); // 3;
|
|
1092
|
+
* sessions.delete('sess_def');
|
|
1093
|
+
* console.log(sessions.has('sess_def')); // false;
|
|
1094
|
+
* console.log(sessions.size); // 2;
|
|
1095
|
+
*/
|
|
1096
|
+
delete(key: K): boolean;
|
|
1097
|
+
/**
|
|
1098
|
+
* Delete all entries matching a predicate.
|
|
1099
|
+
* @remarks Time O(N), Space O(N)
|
|
1100
|
+
* @param predicate - Function (key, value, index, map) → boolean; return true to delete.
|
|
1101
|
+
* @returns True if at least one entry was deleted.
|
|
1102
|
+
*/
|
|
1103
|
+
deleteWhere(predicate: (key: K, value: V | undefined, index: number, map: this) => boolean): boolean;
|
|
1104
|
+
/**
|
|
1105
|
+
* Remove all entries.
|
|
1095
1106
|
|
|
1096
1107
|
|
|
1097
1108
|
|
|
@@ -1153,17 +1164,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1153
1164
|
|
|
1154
1165
|
|
|
1155
1166
|
|
|
1156
|
-
* @example
|
|
1157
|
-
* // Get sorted keys
|
|
1158
|
-
* const tm = new TreeMap<number, string>([[3, 'c'], [1, 'a']]);
|
|
1159
|
-
* console.log([...tm.keys()]); // [1, 3];
|
|
1160
|
-
*/
|
|
1161
|
-
keys(): IterableIterator<K>;
|
|
1162
|
-
private _entryFromKey;
|
|
1163
|
-
/**
|
|
1164
|
-
* Iterate over values in ascending key order.
|
|
1165
|
-
*
|
|
1166
|
-
* Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
|
|
1167
1167
|
|
|
1168
1168
|
|
|
1169
1169
|
|
|
@@ -1281,6 +1281,15 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1281
1281
|
|
|
1282
1282
|
|
|
1283
1283
|
|
|
1284
|
+
* @example
|
|
1285
|
+
* // Remove all
|
|
1286
|
+
* const tm = new TreeMap<number, string>([[1, 'a']]);
|
|
1287
|
+
* tm.clear();
|
|
1288
|
+
* console.log(tm.isEmpty()); // true;
|
|
1289
|
+
*/
|
|
1290
|
+
clear(): void;
|
|
1291
|
+
/**
|
|
1292
|
+
* Iterate over keys in ascending order.
|
|
1284
1293
|
|
|
1285
1294
|
|
|
1286
1295
|
|
|
@@ -1302,16 +1311,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1302
1311
|
|
|
1303
1312
|
|
|
1304
1313
|
|
|
1305
|
-
* @example
|
|
1306
|
-
* // Get values in key order
|
|
1307
|
-
* const tm = new TreeMap<number, string>([[2, 'b'], [1, 'a']]);
|
|
1308
|
-
* console.log([...tm.values()]); // ['a', 'b'];
|
|
1309
|
-
*/
|
|
1310
|
-
values(): IterableIterator<V | undefined>;
|
|
1311
|
-
/**
|
|
1312
|
-
* Iterate over `[key, value]` entries in ascending key order.
|
|
1313
|
-
*
|
|
1314
|
-
* Note: values may be `undefined`.
|
|
1315
1314
|
|
|
1316
1315
|
|
|
1317
1316
|
|
|
@@ -1450,17 +1449,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1450
1449
|
|
|
1451
1450
|
|
|
1452
1451
|
|
|
1453
|
-
* @example
|
|
1454
|
-
* // Iterate key-value pairs
|
|
1455
|
-
* const tm = new TreeMap<number, string>([[3, 'c'], [1, 'a'], [2, 'b']]);
|
|
1456
|
-
* console.log([...tm.entries()]); // [[1, 'a'], [2, 'b'], [3, 'c']];
|
|
1457
|
-
*/
|
|
1458
|
-
entries(): IterableIterator<[K, V | undefined]>;
|
|
1459
|
-
[Symbol.iterator](): IterableIterator<[K, V | undefined]>;
|
|
1460
|
-
/**
|
|
1461
|
-
* Visit each entry in ascending key order.
|
|
1462
|
-
*
|
|
1463
|
-
* Note: callback value may be `undefined`.
|
|
1464
1452
|
|
|
1465
1453
|
|
|
1466
1454
|
|
|
@@ -1480,6 +1468,17 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1480
1468
|
|
|
1481
1469
|
|
|
1482
1470
|
|
|
1471
|
+
* @example
|
|
1472
|
+
* // Get sorted keys
|
|
1473
|
+
* const tm = new TreeMap<number, string>([[3, 'c'], [1, 'a']]);
|
|
1474
|
+
* console.log([...tm.keys()]); // [1, 3];
|
|
1475
|
+
*/
|
|
1476
|
+
keys(): IterableIterator<K>;
|
|
1477
|
+
private _entryFromKey;
|
|
1478
|
+
/**
|
|
1479
|
+
* Iterate over values in ascending key order.
|
|
1480
|
+
*
|
|
1481
|
+
* Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
|
|
1483
1482
|
|
|
1484
1483
|
|
|
1485
1484
|
|
|
@@ -1599,19 +1598,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1599
1598
|
|
|
1600
1599
|
|
|
1601
1600
|
|
|
1602
|
-
* @example
|
|
1603
|
-
* // Execute for each entry
|
|
1604
|
-
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
1605
|
-
* const pairs: string[] = [];
|
|
1606
|
-
* tm.forEach((v, k) => pairs.push(`${k}:${v}`));
|
|
1607
|
-
* console.log(pairs); // ['1:a', '2:b'];
|
|
1608
|
-
*/
|
|
1609
|
-
forEach(cb: (value: V | undefined, key: K, map: TreeMap<K, V>) => void, thisArg?: unknown): void;
|
|
1610
|
-
/**
|
|
1611
|
-
* Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
|
|
1612
|
-
*
|
|
1613
|
-
* This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
|
|
1614
|
-
* @remarks Time O(n log n) expected, Space O(n)
|
|
1615
1601
|
|
|
1616
1602
|
|
|
1617
1603
|
|
|
@@ -1671,6 +1657,16 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1671
1657
|
|
|
1672
1658
|
|
|
1673
1659
|
|
|
1660
|
+
* @example
|
|
1661
|
+
* // Get values in key order
|
|
1662
|
+
* const tm = new TreeMap<number, string>([[2, 'b'], [1, 'a']]);
|
|
1663
|
+
* console.log([...tm.values()]); // ['a', 'b'];
|
|
1664
|
+
*/
|
|
1665
|
+
values(): IterableIterator<V | undefined>;
|
|
1666
|
+
/**
|
|
1667
|
+
* Iterate over `[key, value]` entries in ascending key order.
|
|
1668
|
+
*
|
|
1669
|
+
* Note: values may be `undefined`.
|
|
1674
1670
|
|
|
1675
1671
|
|
|
1676
1672
|
|
|
@@ -1750,18 +1746,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1750
1746
|
|
|
1751
1747
|
|
|
1752
1748
|
|
|
1753
|
-
* @example
|
|
1754
|
-
* // Transform entries
|
|
1755
|
-
* const tm = new TreeMap<number, number>([[1, 10], [2, 20]]);
|
|
1756
|
-
* const doubled = tm.map((v, k) => [k, (v ?? 0) * 2] as [number, number]);
|
|
1757
|
-
* console.log([...doubled.values()]); // [20, 40];
|
|
1758
|
-
*/
|
|
1759
|
-
map<MK, MV>(callbackfn: TreeMapEntryCallback<K, V, [MK, MV], TreeMap<K, V>>, options?: Omit<TreeMapOptions<MK, MV>, 'toEntryFn'> & {
|
|
1760
|
-
comparator?: (a: MK, b: MK) => number;
|
|
1761
|
-
}, thisArg?: unknown): TreeMap<MK, MV>;
|
|
1762
|
-
/**
|
|
1763
|
-
* Create a new TreeMap containing only entries that satisfy the predicate.
|
|
1764
|
-
* @remarks Time O(n log n) expected, Space O(n)
|
|
1765
1749
|
|
|
1766
1750
|
|
|
1767
1751
|
|
|
@@ -1861,6 +1845,18 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1861
1845
|
|
|
1862
1846
|
|
|
1863
1847
|
|
|
1848
|
+
* @example
|
|
1849
|
+
* // Iterate key-value pairs
|
|
1850
|
+
* const tm = new TreeMap<number, string>([[3, 'c'], [1, 'a'], [2, 'b']]);
|
|
1851
|
+
* console.log([...tm.entries()]); // [[1, 'a'], [2, 'b'], [3, 'c']];
|
|
1852
|
+
*/
|
|
1853
|
+
entries(): IterableIterator<[K, V | undefined]>;
|
|
1854
|
+
[Symbol.iterator](): IterableIterator<[K, V | undefined]>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Visit each entry in ascending key order.
|
|
1857
|
+
*
|
|
1858
|
+
* Note: callback value may be `undefined`.
|
|
1859
|
+
|
|
1864
1860
|
|
|
1865
1861
|
|
|
1866
1862
|
|
|
@@ -1900,16 +1896,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
1900
1896
|
|
|
1901
1897
|
|
|
1902
1898
|
|
|
1903
|
-
* @example
|
|
1904
|
-
* // Filter entries
|
|
1905
|
-
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
1906
|
-
* const filtered = tm.filter((v, k) => k > 1);
|
|
1907
|
-
* console.log([...filtered.keys()]); // [2, 3];
|
|
1908
|
-
*/
|
|
1909
|
-
filter(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): TreeMap<K, V>;
|
|
1910
|
-
/**
|
|
1911
|
-
* Reduce entries into a single accumulator.
|
|
1912
|
-
* @remarks Time O(n), Space O(1)
|
|
1913
1899
|
|
|
1914
1900
|
|
|
1915
1901
|
|
|
@@ -2049,14 +2035,18 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2049
2035
|
|
|
2050
2036
|
|
|
2051
2037
|
* @example
|
|
2052
|
-
* //
|
|
2053
|
-
* const tm = new TreeMap<number,
|
|
2054
|
-
*
|
|
2038
|
+
* // Execute for each entry
|
|
2039
|
+
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2040
|
+
* const pairs: string[] = [];
|
|
2041
|
+
* tm.forEach((v, k) => pairs.push(`${k}:${v}`));
|
|
2042
|
+
* console.log(pairs); // ['1:a', '2:b'];
|
|
2055
2043
|
*/
|
|
2056
|
-
|
|
2044
|
+
forEach(cb: (value: V | undefined, key: K, map: TreeMap<K, V>) => void, thisArg?: unknown): void;
|
|
2057
2045
|
/**
|
|
2058
|
-
*
|
|
2059
|
-
*
|
|
2046
|
+
* Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
|
|
2047
|
+
*
|
|
2048
|
+
* This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
|
|
2049
|
+
* @remarks Time O(n log n) expected, Space O(n)
|
|
2060
2050
|
|
|
2061
2051
|
|
|
2062
2052
|
|
|
@@ -2193,15 +2183,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2193
2183
|
|
|
2194
2184
|
|
|
2195
2185
|
|
|
2196
|
-
* @example
|
|
2197
|
-
* // Test all entries
|
|
2198
|
-
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2199
|
-
* console.log(tm.every((v, k) => k > 0)); // true;
|
|
2200
|
-
*/
|
|
2201
|
-
every(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): boolean;
|
|
2202
|
-
/**
|
|
2203
|
-
* Test whether any entry satisfies a predicate.
|
|
2204
|
-
* @remarks Time O(n), Space O(1)
|
|
2205
2186
|
|
|
2206
2187
|
|
|
2207
2188
|
|
|
@@ -2244,6 +2225,18 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2244
2225
|
|
|
2245
2226
|
|
|
2246
2227
|
|
|
2228
|
+
* @example
|
|
2229
|
+
* // Transform entries
|
|
2230
|
+
* const tm = new TreeMap<number, number>([[1, 10], [2, 20]]);
|
|
2231
|
+
* const doubled = tm.map((v, k) => [k, (v ?? 0) * 2] as [number, number]);
|
|
2232
|
+
* console.log([...doubled.values()]); // [20, 40];
|
|
2233
|
+
*/
|
|
2234
|
+
map<MK, MV>(callbackfn: TreeMapEntryCallback<K, V, [MK, MV], TreeMap<K, V>>, options?: Omit<TreeMapOptions<MK, MV>, 'toEntryFn'> & {
|
|
2235
|
+
comparator?: (a: MK, b: MK) => number;
|
|
2236
|
+
}, thisArg?: unknown): TreeMap<MK, MV>;
|
|
2237
|
+
/**
|
|
2238
|
+
* Create a new TreeMap containing only entries that satisfy the predicate.
|
|
2239
|
+
* @remarks Time O(n log n) expected, Space O(n)
|
|
2247
2240
|
|
|
2248
2241
|
|
|
2249
2242
|
|
|
@@ -2338,16 +2331,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2338
2331
|
|
|
2339
2332
|
|
|
2340
2333
|
|
|
2341
|
-
* @example
|
|
2342
|
-
* // Test any entry
|
|
2343
|
-
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2344
|
-
* console.log(tm.some((v, k) => k === 2)); // true;
|
|
2345
|
-
*/
|
|
2346
|
-
some(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): boolean;
|
|
2347
|
-
/**
|
|
2348
|
-
* Find the first entry that satisfies a predicate.
|
|
2349
|
-
* @returns The first matching `[key, value]` tuple, or `undefined`.
|
|
2350
|
-
* @remarks Time O(n), Space O(1)
|
|
2351
2334
|
|
|
2352
2335
|
|
|
2353
2336
|
|
|
@@ -2432,6 +2415,16 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2432
2415
|
|
|
2433
2416
|
|
|
2434
2417
|
|
|
2418
|
+
* @example
|
|
2419
|
+
* // Filter entries
|
|
2420
|
+
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
|
|
2421
|
+
* const filtered = tm.filter((v, k) => k > 1);
|
|
2422
|
+
* console.log([...filtered.keys()]); // [2, 3];
|
|
2423
|
+
*/
|
|
2424
|
+
filter(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): TreeMap<K, V>;
|
|
2425
|
+
/**
|
|
2426
|
+
* Reduce entries into a single accumulator.
|
|
2427
|
+
* @remarks Time O(n), Space O(1)
|
|
2435
2428
|
|
|
2436
2429
|
|
|
2437
2430
|
|
|
@@ -2484,15 +2477,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2484
2477
|
|
|
2485
2478
|
|
|
2486
2479
|
|
|
2487
|
-
* @example
|
|
2488
|
-
* // Find matching entry
|
|
2489
|
-
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2490
|
-
* console.log(tm.find(v => v === 'b')?.[0]); // 2;
|
|
2491
|
-
*/
|
|
2492
|
-
find(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): [K, V | undefined] | undefined;
|
|
2493
|
-
/**
|
|
2494
|
-
* Materialize the map into an array of `[key, value]` tuples.
|
|
2495
|
-
* @remarks Time O(n), Space O(n)
|
|
2496
2480
|
|
|
2497
2481
|
|
|
2498
2482
|
|
|
@@ -2619,6 +2603,15 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2619
2603
|
|
|
2620
2604
|
|
|
2621
2605
|
|
|
2606
|
+
* @example
|
|
2607
|
+
* // Aggregate values
|
|
2608
|
+
* const tm = new TreeMap<number, number>([[1, 10], [2, 20]]);
|
|
2609
|
+
* console.log(tm.reduce((acc, v) => acc + (v ?? 0), 0)); // 30;
|
|
2610
|
+
*/
|
|
2611
|
+
reduce<A>(callbackfn: TreeMapReduceCallback<K, V, A, TreeMap<K, V>>, initialValue: A): A;
|
|
2612
|
+
/**
|
|
2613
|
+
* Test whether all entries satisfy a predicate.
|
|
2614
|
+
* @remarks Time O(n), Space O(1)
|
|
2622
2615
|
|
|
2623
2616
|
|
|
2624
2617
|
|
|
@@ -2631,15 +2624,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2631
2624
|
|
|
2632
2625
|
|
|
2633
2626
|
|
|
2634
|
-
* @example
|
|
2635
|
-
* // Convert to array
|
|
2636
|
-
* const tm = new TreeMap<number, string>([[2, 'b'], [1, 'a']]);
|
|
2637
|
-
* console.log(tm.toArray()); // [[1, 'a'], [2, 'b']];
|
|
2638
|
-
*/
|
|
2639
|
-
toArray(): Array<[K, V | undefined]>;
|
|
2640
|
-
/**
|
|
2641
|
-
* Print a human-friendly representation.
|
|
2642
|
-
* @remarks Time O(n), Space O(n)
|
|
2643
2627
|
|
|
2644
2628
|
|
|
2645
2629
|
|
|
@@ -2778,14 +2762,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2778
2762
|
|
|
2779
2763
|
|
|
2780
2764
|
|
|
2781
|
-
* @example
|
|
2782
|
-
* // Display tree
|
|
2783
|
-
* const tm = new TreeMap<number, string>([[1, 'a']]);
|
|
2784
|
-
* expect(() => tm.print()).not.toThrow();
|
|
2785
|
-
*/
|
|
2786
|
-
print(): void;
|
|
2787
|
-
/**
|
|
2788
|
-
* Smallest entry by key.
|
|
2789
2765
|
|
|
2790
2766
|
|
|
2791
2767
|
|
|
@@ -2812,41 +2788,20 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2812
2788
|
|
|
2813
2789
|
|
|
2814
2790
|
|
|
2791
|
+
* @example
|
|
2792
|
+
* // Test all entries
|
|
2793
|
+
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2794
|
+
* console.log(tm.every((v, k) => k > 0)); // true;
|
|
2795
|
+
*/
|
|
2796
|
+
every(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): boolean;
|
|
2797
|
+
/**
|
|
2798
|
+
* Test whether any entry satisfies a predicate.
|
|
2799
|
+
* @remarks Time O(n), Space O(1)
|
|
2815
2800
|
|
|
2816
2801
|
|
|
2817
2802
|
|
|
2818
2803
|
|
|
2819
2804
|
|
|
2820
|
-
* @example
|
|
2821
|
-
* // Leaderboard with ranked scores
|
|
2822
|
-
* // Use score as key (descending), player name as value
|
|
2823
|
-
* const leaderboard = new TreeMap<number, string>([], {
|
|
2824
|
-
* comparator: (a, b) => b - a // descending
|
|
2825
|
-
* });
|
|
2826
|
-
*
|
|
2827
|
-
* leaderboard.set(1500, 'Alice');
|
|
2828
|
-
* leaderboard.set(2200, 'Bob');
|
|
2829
|
-
* leaderboard.set(1800, 'Charlie');
|
|
2830
|
-
* leaderboard.set(2500, 'Diana');
|
|
2831
|
-
*
|
|
2832
|
-
* // Top 3 players (first 3 in descending order)
|
|
2833
|
-
* const top3 = [...leaderboard.entries()].slice(0, 3);
|
|
2834
|
-
* console.log(top3); // [
|
|
2835
|
-
* // [2500, 'Diana'],
|
|
2836
|
-
* // [2200, 'Bob'],
|
|
2837
|
-
* // [1800, 'Charlie']
|
|
2838
|
-
* // ];
|
|
2839
|
-
*
|
|
2840
|
-
* // Highest scorer
|
|
2841
|
-
* console.log(leaderboard.first()); // [2500, 'Diana'];
|
|
2842
|
-
*
|
|
2843
|
-
* // Remove lowest scorer
|
|
2844
|
-
* console.log(leaderboard.pollLast()); // [1500, 'Alice'];
|
|
2845
|
-
* console.log(leaderboard.size); // 3;
|
|
2846
|
-
*/
|
|
2847
|
-
first(): [K, V | undefined] | undefined;
|
|
2848
|
-
/**
|
|
2849
|
-
* Largest entry by key.
|
|
2850
2805
|
|
|
2851
2806
|
|
|
2852
2807
|
|
|
@@ -2878,20 +2833,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2878
2833
|
|
|
2879
2834
|
|
|
2880
2835
|
|
|
2881
|
-
* @example
|
|
2882
|
-
* // Access the maximum entry
|
|
2883
|
-
* const scores = new TreeMap<number, string>([
|
|
2884
|
-
* [85, 'Bob'],
|
|
2885
|
-
* [92, 'Alice'],
|
|
2886
|
-
* [78, 'Charlie']
|
|
2887
|
-
* ]);
|
|
2888
|
-
*
|
|
2889
|
-
* console.log(scores.last()); // [92, 'Alice'];
|
|
2890
|
-
* console.log(scores.first()); // [78, 'Charlie'];
|
|
2891
|
-
*/
|
|
2892
|
-
last(): [K, V | undefined] | undefined;
|
|
2893
|
-
/**
|
|
2894
|
-
* Remove and return the smallest entry.
|
|
2895
2836
|
|
|
2896
2837
|
|
|
2897
2838
|
|
|
@@ -2923,22 +2864,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2923
2864
|
|
|
2924
2865
|
|
|
2925
2866
|
|
|
2926
|
-
* @example
|
|
2927
|
-
* // Process items from lowest priority
|
|
2928
|
-
* const tasks = new TreeMap<number, string>([
|
|
2929
|
-
* [3, 'Low'],
|
|
2930
|
-
* [1, 'Critical'],
|
|
2931
|
-
* [2, 'Medium']
|
|
2932
|
-
* ]);
|
|
2933
|
-
*
|
|
2934
|
-
* // Process lowest priority first
|
|
2935
|
-
* console.log(tasks.pollFirst()); // [1, 'Critical'];
|
|
2936
|
-
* console.log(tasks.pollFirst()); // [2, 'Medium'];
|
|
2937
|
-
* console.log(tasks.size); // 1;
|
|
2938
|
-
*/
|
|
2939
|
-
pollFirst(): [K, V | undefined] | undefined;
|
|
2940
|
-
/**
|
|
2941
|
-
* Remove and return the largest entry.
|
|
2942
2867
|
|
|
2943
2868
|
|
|
2944
2869
|
|
|
@@ -2970,22 +2895,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
2970
2895
|
|
|
2971
2896
|
|
|
2972
2897
|
|
|
2973
|
-
* @example
|
|
2974
|
-
* // Remove the maximum entry
|
|
2975
|
-
* const bids = new TreeMap<number, string>([
|
|
2976
|
-
* [100, 'Alice'],
|
|
2977
|
-
* [150, 'Bob'],
|
|
2978
|
-
* [120, 'Charlie']
|
|
2979
|
-
* ]);
|
|
2980
|
-
*
|
|
2981
|
-
* // Remove highest bid
|
|
2982
|
-
* console.log(bids.pollLast()); // [150, 'Bob'];
|
|
2983
|
-
* console.log(bids.size); // 2;
|
|
2984
|
-
* console.log(bids.last()); // [120, 'Charlie'];
|
|
2985
|
-
*/
|
|
2986
|
-
pollLast(): [K, V | undefined] | undefined;
|
|
2987
|
-
/**
|
|
2988
|
-
* Smallest entry whose key is >= the given key.
|
|
2989
2898
|
|
|
2990
2899
|
|
|
2991
2900
|
|
|
@@ -3064,6 +2973,16 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3064
2973
|
|
|
3065
2974
|
|
|
3066
2975
|
|
|
2976
|
+
* @example
|
|
2977
|
+
* // Test any entry
|
|
2978
|
+
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
2979
|
+
* console.log(tm.some((v, k) => k === 2)); // true;
|
|
2980
|
+
*/
|
|
2981
|
+
some(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): boolean;
|
|
2982
|
+
/**
|
|
2983
|
+
* Find the first entry that satisfies a predicate.
|
|
2984
|
+
* @returns The first matching `[key, value]` tuple, or `undefined`.
|
|
2985
|
+
* @remarks Time O(n), Space O(1)
|
|
3067
2986
|
|
|
3068
2987
|
|
|
3069
2988
|
|
|
@@ -3104,41 +3023,6 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3104
3023
|
|
|
3105
3024
|
|
|
3106
3025
|
|
|
3107
|
-
* @example
|
|
3108
|
-
* // Event scheduler with time-based lookup
|
|
3109
|
-
* const events = new TreeMap<Date, string>();
|
|
3110
|
-
*
|
|
3111
|
-
* const meeting = new Date('2024-01-15T10:00:00Z');
|
|
3112
|
-
* const lunch = new Date('2024-01-15T12:00:00Z');
|
|
3113
|
-
* const review = new Date('2024-01-15T15:00:00Z');
|
|
3114
|
-
* const standup = new Date('2024-01-15T09:00:00Z');
|
|
3115
|
-
*
|
|
3116
|
-
* events.set(meeting, 'Team Meeting');
|
|
3117
|
-
* events.set(lunch, 'Lunch Break');
|
|
3118
|
-
* events.set(review, 'Code Review');
|
|
3119
|
-
* events.set(standup, 'Daily Standup');
|
|
3120
|
-
*
|
|
3121
|
-
* // Events are sorted chronologically
|
|
3122
|
-
* console.log([...events.values()]); // [
|
|
3123
|
-
* // 'Daily Standup',
|
|
3124
|
-
* // 'Team Meeting',
|
|
3125
|
-
* // 'Lunch Break',
|
|
3126
|
-
* // 'Code Review'
|
|
3127
|
-
* // ];
|
|
3128
|
-
*
|
|
3129
|
-
* // Next event after 11:00
|
|
3130
|
-
* const after11 = new Date('2024-01-15T11:00:00Z');
|
|
3131
|
-
* console.log(events.ceiling(after11)?.[1]); // 'Lunch Break';
|
|
3132
|
-
*
|
|
3133
|
-
* // Events between 9:30 and 13:00
|
|
3134
|
-
* const from = new Date('2024-01-15T09:30:00Z');
|
|
3135
|
-
* const to = new Date('2024-01-15T13:00:00Z');
|
|
3136
|
-
* const window = events.rangeSearch([from, to]);
|
|
3137
|
-
* console.log(window.map(([, v]) => v)); // ['Team Meeting', 'Lunch Break'];
|
|
3138
|
-
*/
|
|
3139
|
-
ceiling(key: K): [K, V | undefined] | undefined;
|
|
3140
|
-
/**
|
|
3141
|
-
* Largest entry whose key is <= the given key.
|
|
3142
3026
|
|
|
3143
3027
|
|
|
3144
3028
|
|
|
@@ -3257,10 +3141,977 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3257
3141
|
|
|
3258
3142
|
|
|
3259
3143
|
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3144
|
+
|
|
3145
|
+
|
|
3146
|
+
|
|
3147
|
+
|
|
3148
|
+
|
|
3149
|
+
|
|
3150
|
+
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
|
|
3154
|
+
|
|
3155
|
+
|
|
3156
|
+
|
|
3157
|
+
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
|
|
3161
|
+
|
|
3162
|
+
* @example
|
|
3163
|
+
* // Find matching entry
|
|
3164
|
+
* const tm = new TreeMap<number, string>([[1, 'a'], [2, 'b']]);
|
|
3165
|
+
* console.log(tm.find(v => v === 'b')?.[0]); // 2;
|
|
3166
|
+
*/
|
|
3167
|
+
find(callbackfn: TreeMapEntryCallback<K, V, boolean, TreeMap<K, V>>, thisArg?: unknown): [K, V | undefined] | undefined;
|
|
3168
|
+
/**
|
|
3169
|
+
* Materialize the map into an array of `[key, value]` tuples.
|
|
3170
|
+
* @remarks Time O(n), Space O(n)
|
|
3171
|
+
|
|
3172
|
+
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
|
|
3183
|
+
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
|
|
3220
|
+
|
|
3221
|
+
|
|
3222
|
+
|
|
3223
|
+
|
|
3224
|
+
|
|
3225
|
+
|
|
3226
|
+
|
|
3227
|
+
|
|
3228
|
+
|
|
3229
|
+
|
|
3230
|
+
|
|
3231
|
+
|
|
3232
|
+
|
|
3233
|
+
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
|
|
3269
|
+
|
|
3270
|
+
|
|
3271
|
+
|
|
3272
|
+
|
|
3273
|
+
|
|
3274
|
+
|
|
3275
|
+
|
|
3276
|
+
|
|
3277
|
+
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
|
|
3282
|
+
|
|
3283
|
+
|
|
3284
|
+
|
|
3285
|
+
|
|
3286
|
+
|
|
3287
|
+
|
|
3288
|
+
|
|
3289
|
+
|
|
3290
|
+
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
|
|
3314
|
+
|
|
3315
|
+
|
|
3316
|
+
|
|
3317
|
+
|
|
3318
|
+
|
|
3319
|
+
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
|
|
3323
|
+
|
|
3324
|
+
|
|
3325
|
+
|
|
3326
|
+
|
|
3327
|
+
|
|
3328
|
+
|
|
3329
|
+
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
|
|
3333
|
+
|
|
3334
|
+
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
|
|
3338
|
+
|
|
3339
|
+
|
|
3340
|
+
|
|
3341
|
+
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
|
|
3345
|
+
|
|
3346
|
+
|
|
3347
|
+
|
|
3348
|
+
|
|
3349
|
+
* @example
|
|
3350
|
+
* // Convert to array
|
|
3351
|
+
* const tm = new TreeMap<number, string>([[2, 'b'], [1, 'a']]);
|
|
3352
|
+
* console.log(tm.toArray()); // [[1, 'a'], [2, 'b']];
|
|
3353
|
+
*/
|
|
3354
|
+
toArray(): Array<[K, V | undefined]>;
|
|
3355
|
+
/**
|
|
3356
|
+
* Print a human-friendly representation.
|
|
3357
|
+
* @remarks Time O(n), Space O(n)
|
|
3358
|
+
|
|
3359
|
+
|
|
3360
|
+
|
|
3361
|
+
|
|
3362
|
+
|
|
3363
|
+
|
|
3364
|
+
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3388
|
+
|
|
3389
|
+
|
|
3390
|
+
|
|
3391
|
+
|
|
3392
|
+
|
|
3393
|
+
|
|
3394
|
+
|
|
3395
|
+
|
|
3396
|
+
|
|
3397
|
+
|
|
3398
|
+
|
|
3399
|
+
|
|
3400
|
+
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
|
|
3404
|
+
|
|
3405
|
+
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
|
|
3409
|
+
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
|
|
3418
|
+
|
|
3419
|
+
|
|
3420
|
+
|
|
3421
|
+
|
|
3422
|
+
|
|
3423
|
+
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
|
|
3430
|
+
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
|
|
3434
|
+
|
|
3435
|
+
|
|
3436
|
+
|
|
3437
|
+
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
|
|
3441
|
+
|
|
3442
|
+
|
|
3443
|
+
|
|
3444
|
+
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
|
|
3451
|
+
|
|
3452
|
+
|
|
3453
|
+
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
|
|
3463
|
+
|
|
3464
|
+
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
|
|
3469
|
+
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
|
|
3473
|
+
|
|
3474
|
+
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
|
|
3480
|
+
|
|
3481
|
+
|
|
3482
|
+
|
|
3483
|
+
|
|
3484
|
+
|
|
3485
|
+
|
|
3486
|
+
|
|
3487
|
+
|
|
3488
|
+
|
|
3489
|
+
|
|
3490
|
+
|
|
3491
|
+
|
|
3492
|
+
|
|
3493
|
+
|
|
3494
|
+
|
|
3495
|
+
|
|
3496
|
+
|
|
3497
|
+
|
|
3498
|
+
|
|
3499
|
+
|
|
3500
|
+
|
|
3501
|
+
|
|
3502
|
+
|
|
3503
|
+
|
|
3504
|
+
|
|
3505
|
+
|
|
3506
|
+
|
|
3507
|
+
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
|
|
3513
|
+
|
|
3514
|
+
|
|
3515
|
+
|
|
3516
|
+
|
|
3517
|
+
|
|
3518
|
+
|
|
3519
|
+
|
|
3520
|
+
|
|
3521
|
+
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
|
|
3525
|
+
|
|
3526
|
+
|
|
3527
|
+
|
|
3528
|
+
|
|
3529
|
+
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
* @example
|
|
3537
|
+
* // Display tree
|
|
3538
|
+
* const tm = new TreeMap<number, string>([[1, 'a']]);
|
|
3539
|
+
* expect(() => tm.print()).not.toThrow();
|
|
3540
|
+
*/
|
|
3541
|
+
print(): void;
|
|
3542
|
+
/**
|
|
3543
|
+
* Smallest entry by key.
|
|
3544
|
+
|
|
3545
|
+
|
|
3546
|
+
|
|
3547
|
+
|
|
3548
|
+
|
|
3549
|
+
|
|
3550
|
+
|
|
3551
|
+
|
|
3552
|
+
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
|
|
3559
|
+
|
|
3560
|
+
|
|
3561
|
+
|
|
3562
|
+
|
|
3563
|
+
|
|
3564
|
+
|
|
3565
|
+
|
|
3566
|
+
|
|
3567
|
+
|
|
3568
|
+
|
|
3569
|
+
|
|
3570
|
+
|
|
3571
|
+
|
|
3572
|
+
|
|
3573
|
+
|
|
3574
|
+
|
|
3575
|
+
|
|
3576
|
+
|
|
3577
|
+
|
|
3578
|
+
|
|
3579
|
+
|
|
3580
|
+
|
|
3581
|
+
|
|
3582
|
+
|
|
3583
|
+
* @example
|
|
3584
|
+
* // Leaderboard with ranked scores
|
|
3585
|
+
* // Use score as key (descending), player name as value
|
|
3586
|
+
* const leaderboard = new TreeMap<number, string>([], {
|
|
3587
|
+
* comparator: (a, b) => b - a // descending
|
|
3588
|
+
* });
|
|
3589
|
+
*
|
|
3590
|
+
* leaderboard.set(1500, 'Alice');
|
|
3591
|
+
* leaderboard.set(2200, 'Bob');
|
|
3592
|
+
* leaderboard.set(1800, 'Charlie');
|
|
3593
|
+
* leaderboard.set(2500, 'Diana');
|
|
3594
|
+
*
|
|
3595
|
+
* // Top 3 players (first 3 in descending order)
|
|
3596
|
+
* const top3 = [...leaderboard.entries()].slice(0, 3);
|
|
3597
|
+
* console.log(top3); // [
|
|
3598
|
+
* // [2500, 'Diana'],
|
|
3599
|
+
* // [2200, 'Bob'],
|
|
3600
|
+
* // [1800, 'Charlie']
|
|
3601
|
+
* // ];
|
|
3602
|
+
*
|
|
3603
|
+
* // Highest scorer
|
|
3604
|
+
* console.log(leaderboard.first()); // [2500, 'Diana'];
|
|
3605
|
+
*
|
|
3606
|
+
* // Remove lowest scorer
|
|
3607
|
+
* console.log(leaderboard.pollLast()); // [1500, 'Alice'];
|
|
3608
|
+
* console.log(leaderboard.size); // 3;
|
|
3609
|
+
*/
|
|
3610
|
+
first(): [K, V | undefined] | undefined;
|
|
3611
|
+
/**
|
|
3612
|
+
* Largest entry by key.
|
|
3613
|
+
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
|
|
3617
|
+
|
|
3618
|
+
|
|
3619
|
+
|
|
3620
|
+
|
|
3621
|
+
|
|
3622
|
+
|
|
3623
|
+
|
|
3624
|
+
|
|
3625
|
+
|
|
3626
|
+
|
|
3627
|
+
|
|
3628
|
+
|
|
3629
|
+
|
|
3630
|
+
|
|
3631
|
+
|
|
3632
|
+
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
|
|
3639
|
+
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3645
|
+
|
|
3646
|
+
|
|
3647
|
+
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
|
|
3651
|
+
|
|
3652
|
+
* @example
|
|
3653
|
+
* // Access the maximum entry
|
|
3654
|
+
* const scores = new TreeMap<number, string>([
|
|
3655
|
+
* [85, 'Bob'],
|
|
3656
|
+
* [92, 'Alice'],
|
|
3657
|
+
* [78, 'Charlie']
|
|
3658
|
+
* ]);
|
|
3659
|
+
*
|
|
3660
|
+
* console.log(scores.last()); // [92, 'Alice'];
|
|
3661
|
+
* console.log(scores.first()); // [78, 'Charlie'];
|
|
3662
|
+
*/
|
|
3663
|
+
last(): [K, V | undefined] | undefined;
|
|
3664
|
+
/**
|
|
3665
|
+
* Remove and return the smallest entry.
|
|
3666
|
+
|
|
3667
|
+
|
|
3668
|
+
|
|
3669
|
+
|
|
3670
|
+
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+
|
|
3674
|
+
|
|
3675
|
+
|
|
3676
|
+
|
|
3677
|
+
|
|
3678
|
+
|
|
3679
|
+
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
|
|
3689
|
+
|
|
3690
|
+
|
|
3691
|
+
|
|
3692
|
+
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
|
|
3697
|
+
|
|
3698
|
+
|
|
3699
|
+
|
|
3700
|
+
|
|
3701
|
+
|
|
3702
|
+
|
|
3703
|
+
|
|
3704
|
+
|
|
3705
|
+
* @example
|
|
3706
|
+
* // Process items from lowest priority
|
|
3707
|
+
* const tasks = new TreeMap<number, string>([
|
|
3708
|
+
* [3, 'Low'],
|
|
3709
|
+
* [1, 'Critical'],
|
|
3710
|
+
* [2, 'Medium']
|
|
3711
|
+
* ]);
|
|
3712
|
+
*
|
|
3713
|
+
* // Process lowest priority first
|
|
3714
|
+
* console.log(tasks.pollFirst()); // [1, 'Critical'];
|
|
3715
|
+
* console.log(tasks.pollFirst()); // [2, 'Medium'];
|
|
3716
|
+
* console.log(tasks.size); // 1;
|
|
3717
|
+
*/
|
|
3718
|
+
pollFirst(): [K, V | undefined] | undefined;
|
|
3719
|
+
/**
|
|
3720
|
+
* Remove and return the largest entry.
|
|
3721
|
+
|
|
3722
|
+
|
|
3723
|
+
|
|
3724
|
+
|
|
3725
|
+
|
|
3726
|
+
|
|
3727
|
+
|
|
3728
|
+
|
|
3729
|
+
|
|
3730
|
+
|
|
3731
|
+
|
|
3732
|
+
|
|
3733
|
+
|
|
3734
|
+
|
|
3735
|
+
|
|
3736
|
+
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
|
|
3748
|
+
|
|
3749
|
+
|
|
3750
|
+
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
|
|
3758
|
+
|
|
3759
|
+
|
|
3760
|
+
* @example
|
|
3761
|
+
* // Remove the maximum entry
|
|
3762
|
+
* const bids = new TreeMap<number, string>([
|
|
3763
|
+
* [100, 'Alice'],
|
|
3764
|
+
* [150, 'Bob'],
|
|
3765
|
+
* [120, 'Charlie']
|
|
3766
|
+
* ]);
|
|
3767
|
+
*
|
|
3768
|
+
* // Remove highest bid
|
|
3769
|
+
* console.log(bids.pollLast()); // [150, 'Bob'];
|
|
3770
|
+
* console.log(bids.size); // 2;
|
|
3771
|
+
* console.log(bids.last()); // [120, 'Charlie'];
|
|
3772
|
+
*/
|
|
3773
|
+
pollLast(): [K, V | undefined] | undefined;
|
|
3774
|
+
/**
|
|
3775
|
+
* Smallest entry whose key is >= the given key.
|
|
3776
|
+
|
|
3777
|
+
|
|
3778
|
+
|
|
3779
|
+
|
|
3780
|
+
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
|
|
3792
|
+
|
|
3793
|
+
|
|
3794
|
+
|
|
3795
|
+
|
|
3796
|
+
|
|
3797
|
+
|
|
3798
|
+
|
|
3799
|
+
|
|
3800
|
+
|
|
3801
|
+
|
|
3802
|
+
|
|
3803
|
+
|
|
3804
|
+
|
|
3805
|
+
|
|
3806
|
+
|
|
3807
|
+
|
|
3808
|
+
|
|
3809
|
+
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
|
|
3813
|
+
|
|
3814
|
+
|
|
3815
|
+
|
|
3816
|
+
|
|
3817
|
+
|
|
3818
|
+
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
|
|
3822
|
+
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
|
|
3826
|
+
|
|
3827
|
+
|
|
3828
|
+
|
|
3829
|
+
|
|
3830
|
+
|
|
3831
|
+
|
|
3832
|
+
|
|
3833
|
+
|
|
3834
|
+
|
|
3835
|
+
|
|
3836
|
+
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
|
|
3843
|
+
|
|
3844
|
+
|
|
3845
|
+
|
|
3846
|
+
|
|
3847
|
+
|
|
3848
|
+
|
|
3849
|
+
|
|
3850
|
+
|
|
3851
|
+
|
|
3852
|
+
|
|
3853
|
+
|
|
3854
|
+
|
|
3855
|
+
|
|
3856
|
+
|
|
3857
|
+
|
|
3858
|
+
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
3864
|
+
|
|
3865
|
+
|
|
3866
|
+
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
|
|
3876
|
+
|
|
3877
|
+
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
|
|
3881
|
+
|
|
3882
|
+
|
|
3883
|
+
|
|
3884
|
+
|
|
3885
|
+
|
|
3886
|
+
|
|
3887
|
+
|
|
3888
|
+
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
|
|
3892
|
+
|
|
3893
|
+
|
|
3894
|
+
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
|
|
3899
|
+
|
|
3900
|
+
|
|
3901
|
+
|
|
3902
|
+
|
|
3903
|
+
|
|
3904
|
+
|
|
3905
|
+
|
|
3906
|
+
|
|
3907
|
+
|
|
3908
|
+
|
|
3909
|
+
|
|
3910
|
+
|
|
3911
|
+
|
|
3912
|
+
|
|
3913
|
+
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3919
|
+
|
|
3920
|
+
|
|
3921
|
+
|
|
3922
|
+
|
|
3923
|
+
|
|
3924
|
+
|
|
3925
|
+
|
|
3926
|
+
* @example
|
|
3927
|
+
* // Event scheduler with time-based lookup
|
|
3928
|
+
* const events = new TreeMap<Date, string>();
|
|
3929
|
+
*
|
|
3930
|
+
* const meeting = new Date('2024-01-15T10:00:00Z');
|
|
3931
|
+
* const lunch = new Date('2024-01-15T12:00:00Z');
|
|
3932
|
+
* const review = new Date('2024-01-15T15:00:00Z');
|
|
3933
|
+
* const standup = new Date('2024-01-15T09:00:00Z');
|
|
3934
|
+
*
|
|
3935
|
+
* events.set(meeting, 'Team Meeting');
|
|
3936
|
+
* events.set(lunch, 'Lunch Break');
|
|
3937
|
+
* events.set(review, 'Code Review');
|
|
3938
|
+
* events.set(standup, 'Daily Standup');
|
|
3939
|
+
*
|
|
3940
|
+
* // Events are sorted chronologically
|
|
3941
|
+
* console.log([...events.values()]); // [
|
|
3942
|
+
* // 'Daily Standup',
|
|
3943
|
+
* // 'Team Meeting',
|
|
3944
|
+
* // 'Lunch Break',
|
|
3945
|
+
* // 'Code Review'
|
|
3946
|
+
* // ];
|
|
3947
|
+
*
|
|
3948
|
+
* // Next event after 11:00
|
|
3949
|
+
* const after11 = new Date('2024-01-15T11:00:00Z');
|
|
3950
|
+
* console.log(events.ceiling(after11)?.[1]); // 'Lunch Break';
|
|
3951
|
+
*
|
|
3952
|
+
* // Events between 9:30 and 13:00
|
|
3953
|
+
* const from = new Date('2024-01-15T09:30:00Z');
|
|
3954
|
+
* const to = new Date('2024-01-15T13:00:00Z');
|
|
3955
|
+
* const window = events.rangeSearch([from, to]);
|
|
3956
|
+
* console.log(window.map(([, v]) => v)); // ['Team Meeting', 'Lunch Break'];
|
|
3957
|
+
*/
|
|
3958
|
+
ceiling(key: K): [K, V | undefined] | undefined;
|
|
3959
|
+
/**
|
|
3960
|
+
* Largest entry whose key is <= the given key.
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
|
|
3973
|
+
|
|
3974
|
+
|
|
3975
|
+
|
|
3976
|
+
|
|
3977
|
+
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
|
|
3993
|
+
|
|
3994
|
+
|
|
3995
|
+
|
|
3996
|
+
|
|
3997
|
+
|
|
3998
|
+
|
|
3999
|
+
|
|
4000
|
+
|
|
4001
|
+
|
|
4002
|
+
|
|
4003
|
+
|
|
4004
|
+
|
|
4005
|
+
|
|
4006
|
+
|
|
4007
|
+
|
|
4008
|
+
|
|
4009
|
+
|
|
4010
|
+
|
|
4011
|
+
|
|
4012
|
+
|
|
4013
|
+
|
|
4014
|
+
|
|
4015
|
+
|
|
4016
|
+
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
|
|
4020
|
+
|
|
4021
|
+
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
|
|
4035
|
+
|
|
4036
|
+
|
|
4037
|
+
|
|
4038
|
+
|
|
4039
|
+
|
|
4040
|
+
|
|
4041
|
+
|
|
4042
|
+
|
|
4043
|
+
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
|
|
4052
|
+
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
|
|
4057
|
+
|
|
4058
|
+
|
|
4059
|
+
|
|
4060
|
+
|
|
4061
|
+
|
|
4062
|
+
|
|
4063
|
+
|
|
4064
|
+
|
|
4065
|
+
|
|
4066
|
+
|
|
4067
|
+
|
|
4068
|
+
|
|
4069
|
+
|
|
4070
|
+
|
|
4071
|
+
|
|
4072
|
+
|
|
4073
|
+
|
|
4074
|
+
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
4100
|
+
|
|
4101
|
+
|
|
4102
|
+
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
|
|
4106
|
+
|
|
4107
|
+
|
|
4108
|
+
|
|
4109
|
+
|
|
4110
|
+
|
|
4111
|
+
* @example
|
|
4112
|
+
* // Find the largest key ≤ target
|
|
4113
|
+
* const versions = new TreeMap<number, string>([
|
|
4114
|
+
* [1, 'v1.0'],
|
|
3264
4115
|
* [3, 'v3.0'],
|
|
3265
4116
|
* [5, 'v5.0'],
|
|
3266
4117
|
* [7, 'v7.0']
|
|
@@ -3373,6 +4224,38 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3373
4224
|
|
|
3374
4225
|
|
|
3375
4226
|
|
|
4227
|
+
|
|
4228
|
+
|
|
4229
|
+
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
|
|
4244
|
+
|
|
4245
|
+
|
|
4246
|
+
|
|
4247
|
+
|
|
4248
|
+
|
|
4249
|
+
|
|
4250
|
+
|
|
4251
|
+
|
|
4252
|
+
|
|
4253
|
+
|
|
4254
|
+
|
|
4255
|
+
|
|
4256
|
+
|
|
4257
|
+
|
|
4258
|
+
|
|
3376
4259
|
|
|
3377
4260
|
|
|
3378
4261
|
|
|
@@ -3510,6 +4393,38 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3510
4393
|
|
|
3511
4394
|
|
|
3512
4395
|
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
|
|
4403
|
+
|
|
4404
|
+
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
|
|
4411
|
+
|
|
4412
|
+
|
|
4413
|
+
|
|
4414
|
+
|
|
4415
|
+
|
|
4416
|
+
|
|
4417
|
+
|
|
4418
|
+
|
|
4419
|
+
|
|
4420
|
+
|
|
4421
|
+
|
|
4422
|
+
|
|
4423
|
+
|
|
4424
|
+
|
|
4425
|
+
|
|
4426
|
+
|
|
4427
|
+
|
|
3513
4428
|
|
|
3514
4429
|
|
|
3515
4430
|
|
|
@@ -3648,6 +4563,38 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3648
4563
|
|
|
3649
4564
|
|
|
3650
4565
|
|
|
4566
|
+
|
|
4567
|
+
|
|
4568
|
+
|
|
4569
|
+
|
|
4570
|
+
|
|
4571
|
+
|
|
4572
|
+
|
|
4573
|
+
|
|
4574
|
+
|
|
4575
|
+
|
|
4576
|
+
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4580
|
+
|
|
4581
|
+
|
|
4582
|
+
|
|
4583
|
+
|
|
4584
|
+
|
|
4585
|
+
|
|
4586
|
+
|
|
4587
|
+
|
|
4588
|
+
|
|
4589
|
+
|
|
4590
|
+
|
|
4591
|
+
|
|
4592
|
+
|
|
4593
|
+
|
|
4594
|
+
|
|
4595
|
+
|
|
4596
|
+
|
|
4597
|
+
|
|
3651
4598
|
|
|
3652
4599
|
|
|
3653
4600
|
|
|
@@ -3701,6 +4648,66 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3701
4648
|
* console.log(totalValue); // toBeCloseTo;
|
|
3702
4649
|
*/
|
|
3703
4650
|
rangeSearch(range: [K, K], options?: TreeMapRangeOptions): Array<[K, V | undefined]>;
|
|
4651
|
+
/**
|
|
4652
|
+
* Returns the entry at the k-th position in tree order (0-indexed).
|
|
4653
|
+
* @remarks Time O(log n). Requires `enableOrderStatistic: true`.
|
|
4654
|
+
|
|
4655
|
+
|
|
4656
|
+
|
|
4657
|
+
* @example
|
|
4658
|
+
* // Find k-th entry in a TreeMap
|
|
4659
|
+
* const map = new TreeMap<string, number>(
|
|
4660
|
+
* [['alice', 95], ['bob', 87], ['charlie', 92]],
|
|
4661
|
+
* { enableOrderStatistic: true }
|
|
4662
|
+
* );
|
|
4663
|
+
* console.log(map.getByRank(0)); // 'alice';
|
|
4664
|
+
* console.log(map.getByRank(1)); // 'bob';
|
|
4665
|
+
* console.log(map.getByRank(2)); // 'charlie';
|
|
4666
|
+
*/
|
|
4667
|
+
getByRank(k: number): [K, V | undefined] | undefined;
|
|
4668
|
+
/**
|
|
4669
|
+
* Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
4670
|
+
* @remarks Time O(log n). Requires `enableOrderStatistic: true`.
|
|
4671
|
+
* @example
|
|
4672
|
+
* // Get the rank of a key in sorted order
|
|
4673
|
+
* const tree = new TreeMap<number>(
|
|
4674
|
+
* [10, 20, 30, 40, 50],
|
|
4675
|
+
* { enableOrderStatistic: true }
|
|
4676
|
+
* );
|
|
4677
|
+
* console.log(tree.getRank(10)); // 0; // smallest → rank 0
|
|
4678
|
+
* console.log(tree.getRank(30)); // 2; // 2 elements before 30 in tree order
|
|
4679
|
+
* console.log(tree.getRank(50)); // 4; // largest → rank 4
|
|
4680
|
+
* console.log(tree.getRank(25)); // 2;
|
|
4681
|
+
*/
|
|
4682
|
+
getRank(key: K): number;
|
|
4683
|
+
/**
|
|
4684
|
+
* Returns keys by rank range (0-indexed, inclusive on both ends).
|
|
4685
|
+
* @remarks Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
4686
|
+
|
|
4687
|
+
|
|
4688
|
+
|
|
4689
|
+
|
|
4690
|
+
|
|
4691
|
+
|
|
4692
|
+
|
|
4693
|
+
|
|
4694
|
+
|
|
4695
|
+
* @example
|
|
4696
|
+
* // Pagination by position in tree order
|
|
4697
|
+
* const tree = new TreeMap<number>(
|
|
4698
|
+
* [10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
4699
|
+
* { enableOrderStatistic: true }
|
|
4700
|
+
* );
|
|
4701
|
+
* const pageSize = 3;
|
|
4702
|
+
*
|
|
4703
|
+
* // Page 1
|
|
4704
|
+
* console.log(tree.rangeByRank(0, pageSize - 1)); // [10, 20, 30];
|
|
4705
|
+
* // Page 2
|
|
4706
|
+
* console.log(tree.rangeByRank(pageSize, 2 * pageSize - 1)); // [40, 50, 60];
|
|
4707
|
+
* // Page 3
|
|
4708
|
+
* console.log(tree.rangeByRank(2 * pageSize, 3 * pageSize - 1)); // [70, 80, 90];
|
|
4709
|
+
*/
|
|
4710
|
+
rangeByRank(start: number, end: number): Array<[K, V | undefined]>;
|
|
3704
4711
|
/**
|
|
3705
4712
|
* Creates a shallow clone of this map.
|
|
3706
4713
|
* @remarks Time O(n log n), Space O(n)
|
|
@@ -3822,6 +4829,46 @@ export declare class TreeMap<K = any, V = any, R = [K, V]> implements Iterable<[
|
|
|
3822
4829
|
|
|
3823
4830
|
|
|
3824
4831
|
|
|
4832
|
+
|
|
4833
|
+
|
|
4834
|
+
|
|
4835
|
+
|
|
4836
|
+
|
|
4837
|
+
|
|
4838
|
+
|
|
4839
|
+
|
|
4840
|
+
|
|
4841
|
+
|
|
4842
|
+
|
|
4843
|
+
|
|
4844
|
+
|
|
4845
|
+
|
|
4846
|
+
|
|
4847
|
+
|
|
4848
|
+
|
|
4849
|
+
|
|
4850
|
+
|
|
4851
|
+
|
|
4852
|
+
|
|
4853
|
+
|
|
4854
|
+
|
|
4855
|
+
|
|
4856
|
+
|
|
4857
|
+
|
|
4858
|
+
|
|
4859
|
+
|
|
4860
|
+
|
|
4861
|
+
|
|
4862
|
+
|
|
4863
|
+
|
|
4864
|
+
|
|
4865
|
+
|
|
4866
|
+
|
|
4867
|
+
|
|
4868
|
+
|
|
4869
|
+
|
|
4870
|
+
|
|
4871
|
+
|
|
3825
4872
|
|
|
3826
4873
|
|
|
3827
4874
|
|