data-structure-typed 2.6.1 → 2.6.2
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 +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
- package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +1 -1
- package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: TreeMap\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
9
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:30](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L30)
|
|
10
10
|
|
|
11
11
|
An ordered Map backed by a red-black tree.
|
|
12
12
|
|
|
@@ -48,7 +48,7 @@ An ordered Map backed by a red-black tree.
|
|
|
48
48
|
new TreeMap<K, V, R>(entries?, options?): TreeMap<K, V, R>;
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
51
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:50](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L50)
|
|
52
52
|
|
|
53
53
|
Create a TreeMap from an iterable of `[key, value]` entries or raw elements.
|
|
54
54
|
|
|
@@ -97,7 +97,7 @@ const map = new TreeMap<number, User, User>(users, { toEntryFn: u => [u.id, u] }
|
|
|
97
97
|
get size(): number;
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
100
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:81](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L81)
|
|
101
101
|
|
|
102
102
|
Number of entries in the map.
|
|
103
103
|
|
|
@@ -113,12 +113,10 @@ Number of entries in the map.
|
|
|
113
113
|
ceiling(key): [K, V | undefined] | undefined;
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
116
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:683](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L683)
|
|
117
117
|
|
|
118
118
|
Smallest entry whose key is >= the given key.
|
|
119
119
|
|
|
120
|
-
*
|
|
121
|
-
|
|
122
120
|
#### Parameters
|
|
123
121
|
|
|
124
122
|
##### key
|
|
@@ -146,12 +144,7 @@ Smallest entry whose key is >= the given key.
|
|
|
146
144
|
events.set(standup, 'Daily Standup');
|
|
147
145
|
|
|
148
146
|
// Events are sorted chronologically
|
|
149
|
-
console.log([...events.values()]); // [
|
|
150
|
-
// 'Daily Standup',
|
|
151
|
-
// 'Team Meeting',
|
|
152
|
-
// 'Lunch Break',
|
|
153
|
-
// 'Code Review'
|
|
154
|
-
// ];
|
|
147
|
+
console.log([...events.values()]); // ['Daily Standup', 'Team Meeting', 'Lunch Break', 'Code Review'];
|
|
155
148
|
|
|
156
149
|
// Next event after 11:00
|
|
157
150
|
const after11 = new Date('2024-01-15T11:00:00Z');
|
|
@@ -172,12 +165,10 @@ Smallest entry whose key is >= the given key.
|
|
|
172
165
|
clear(): void;
|
|
173
166
|
```
|
|
174
167
|
|
|
175
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
168
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L269)
|
|
176
169
|
|
|
177
170
|
Remove all entries.
|
|
178
171
|
|
|
179
|
-
*
|
|
180
|
-
|
|
181
172
|
#### Returns
|
|
182
173
|
|
|
183
174
|
`void`
|
|
@@ -199,7 +190,7 @@ Remove all entries.
|
|
|
199
190
|
clone(): TreeMap<K, V>;
|
|
200
191
|
```
|
|
201
192
|
|
|
202
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
193
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:882](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L882)
|
|
203
194
|
|
|
204
195
|
Creates a shallow clone of this map.
|
|
205
196
|
|
|
@@ -211,13 +202,14 @@ Creates a shallow clone of this map.
|
|
|
211
202
|
|
|
212
203
|
Time O(n log n), Space O(n)
|
|
213
204
|
|
|
214
|
-
*
|
|
215
|
-
|
|
216
205
|
#### Example
|
|
217
206
|
|
|
218
207
|
```ts
|
|
219
208
|
// Deep clone
|
|
220
|
-
const tm = new TreeMap<number, string>([
|
|
209
|
+
const tm = new TreeMap<number, string>([
|
|
210
|
+
[1, 'a'],
|
|
211
|
+
[2, 'b']
|
|
212
|
+
]);
|
|
221
213
|
const copy = tm.clone();
|
|
222
214
|
copy.delete(1);
|
|
223
215
|
console.log(tm.has(1)); // true;
|
|
@@ -231,7 +223,7 @@ Time O(n log n), Space O(n)
|
|
|
231
223
|
delete(key): boolean;
|
|
232
224
|
```
|
|
233
225
|
|
|
234
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
226
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L238)
|
|
235
227
|
|
|
236
228
|
Delete a key.
|
|
237
229
|
|
|
@@ -251,8 +243,6 @@ Delete a key.
|
|
|
251
243
|
|
|
252
244
|
Expected time O(log n)
|
|
253
245
|
|
|
254
|
-
*
|
|
255
|
-
|
|
256
246
|
#### Example
|
|
257
247
|
|
|
258
248
|
```ts
|
|
@@ -277,7 +267,7 @@ Expected time O(log n)
|
|
|
277
267
|
deleteWhere(predicate): boolean;
|
|
278
268
|
```
|
|
279
269
|
|
|
280
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
270
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:249](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L249)
|
|
281
271
|
|
|
282
272
|
Delete all entries matching a predicate.
|
|
283
273
|
|
|
@@ -307,14 +297,12 @@ Time O(N), Space O(N)
|
|
|
307
297
|
entries(): IterableIterator<[K, V | undefined]>;
|
|
308
298
|
```
|
|
309
299
|
|
|
310
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
300
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:320](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L320)
|
|
311
301
|
|
|
312
302
|
Iterate over `[key, value]` entries in ascending key order.
|
|
313
303
|
|
|
314
304
|
Note: values may be `undefined`.
|
|
315
305
|
|
|
316
|
-
*
|
|
317
|
-
|
|
318
306
|
#### Returns
|
|
319
307
|
|
|
320
308
|
`IterableIterator`\<\[`K`, `V` \| `undefined`\]\>
|
|
@@ -323,8 +311,16 @@ Note: values may be `undefined`.
|
|
|
323
311
|
|
|
324
312
|
```ts
|
|
325
313
|
// Iterate key-value pairs
|
|
326
|
-
const tm = new TreeMap<number, string>([
|
|
327
|
-
|
|
314
|
+
const tm = new TreeMap<number, string>([
|
|
315
|
+
[3, 'c'],
|
|
316
|
+
[1, 'a'],
|
|
317
|
+
[2, 'b']
|
|
318
|
+
]);
|
|
319
|
+
console.log([...tm.entries()]); // [
|
|
320
|
+
// [1, 'a'],
|
|
321
|
+
// [2, 'b'],
|
|
322
|
+
// [3, 'c']
|
|
323
|
+
// ];
|
|
328
324
|
```
|
|
329
325
|
|
|
330
326
|
***
|
|
@@ -335,7 +331,7 @@ Note: values may be `undefined`.
|
|
|
335
331
|
every(callbackfn, thisArg?): boolean;
|
|
336
332
|
```
|
|
337
333
|
|
|
338
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
334
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:444](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L444)
|
|
339
335
|
|
|
340
336
|
Test whether all entries satisfy a predicate.
|
|
341
337
|
|
|
@@ -357,13 +353,14 @@ Test whether all entries satisfy a predicate.
|
|
|
357
353
|
|
|
358
354
|
Time O(n), Space O(1)
|
|
359
355
|
|
|
360
|
-
*
|
|
361
|
-
|
|
362
356
|
#### Example
|
|
363
357
|
|
|
364
358
|
```ts
|
|
365
359
|
// Test all entries
|
|
366
|
-
const tm = new TreeMap<number, string>([
|
|
360
|
+
const tm = new TreeMap<number, string>([
|
|
361
|
+
[1, 'a'],
|
|
362
|
+
[2, 'b']
|
|
363
|
+
]);
|
|
367
364
|
console.log(tm.every((v, k) => k > 0)); // true;
|
|
368
365
|
```
|
|
369
366
|
|
|
@@ -375,7 +372,7 @@ Time O(n), Space O(1)
|
|
|
375
372
|
filter(callbackfn, thisArg?): TreeMap<K, V>;
|
|
376
373
|
```
|
|
377
374
|
|
|
378
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
375
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:396](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L396)
|
|
379
376
|
|
|
380
377
|
Create a new TreeMap containing only entries that satisfy the predicate.
|
|
381
378
|
|
|
@@ -397,13 +394,15 @@ Create a new TreeMap containing only entries that satisfy the predicate.
|
|
|
397
394
|
|
|
398
395
|
Time O(n log n) expected, Space O(n)
|
|
399
396
|
|
|
400
|
-
*
|
|
401
|
-
|
|
402
397
|
#### Example
|
|
403
398
|
|
|
404
399
|
```ts
|
|
405
400
|
// Filter entries
|
|
406
|
-
const tm = new TreeMap<number, string>([
|
|
401
|
+
const tm = new TreeMap<number, string>([
|
|
402
|
+
[1, 'a'],
|
|
403
|
+
[2, 'b'],
|
|
404
|
+
[3, 'c']
|
|
405
|
+
]);
|
|
407
406
|
const filtered = tm.filter((v, k) => k > 1);
|
|
408
407
|
console.log([...filtered.keys()]); // [2, 3];
|
|
409
408
|
```
|
|
@@ -416,7 +415,7 @@ Time O(n log n) expected, Space O(n)
|
|
|
416
415
|
find(callbackfn, thisArg?): [K, V | undefined] | undefined;
|
|
417
416
|
```
|
|
418
417
|
|
|
419
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
418
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:503](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L503)
|
|
420
419
|
|
|
421
420
|
Find the first entry that satisfies a predicate.
|
|
422
421
|
|
|
@@ -440,13 +439,14 @@ The first matching `[key, value]` tuple, or `undefined`.
|
|
|
440
439
|
|
|
441
440
|
Time O(n), Space O(1)
|
|
442
441
|
|
|
443
|
-
*
|
|
444
|
-
|
|
445
442
|
#### Example
|
|
446
443
|
|
|
447
444
|
```ts
|
|
448
445
|
// Find matching entry
|
|
449
|
-
const tm = new TreeMap<number, string>([
|
|
446
|
+
const tm = new TreeMap<number, string>([
|
|
447
|
+
[1, 'a'],
|
|
448
|
+
[2, 'b']
|
|
449
|
+
]);
|
|
450
450
|
console.log(tm.find(v => v === 'b')?.[0]); // 2;
|
|
451
451
|
```
|
|
452
452
|
|
|
@@ -458,12 +458,10 @@ Time O(n), Space O(1)
|
|
|
458
458
|
first(): [K, V | undefined] | undefined;
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
461
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:584](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L584)
|
|
462
462
|
|
|
463
463
|
Smallest entry by key.
|
|
464
464
|
|
|
465
|
-
*
|
|
466
|
-
|
|
467
465
|
#### Returns
|
|
468
466
|
|
|
469
467
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -506,12 +504,10 @@ Smallest entry by key.
|
|
|
506
504
|
floor(key): [K, V | undefined] | undefined;
|
|
507
505
|
```
|
|
508
506
|
|
|
509
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
507
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:707](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L707)
|
|
510
508
|
|
|
511
509
|
Largest entry whose key is <= the given key.
|
|
512
510
|
|
|
513
|
-
*
|
|
514
|
-
|
|
515
511
|
#### Parameters
|
|
516
512
|
|
|
517
513
|
##### key
|
|
@@ -549,14 +545,12 @@ Largest entry whose key is <= the given key.
|
|
|
549
545
|
forEach(cb, thisArg?): void;
|
|
550
546
|
```
|
|
551
547
|
|
|
552
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
548
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:342](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L342)
|
|
553
549
|
|
|
554
550
|
Visit each entry in ascending key order.
|
|
555
551
|
|
|
556
552
|
Note: callback value may be `undefined`.
|
|
557
553
|
|
|
558
|
-
*
|
|
559
|
-
|
|
560
554
|
#### Parameters
|
|
561
555
|
|
|
562
556
|
##### cb
|
|
@@ -575,7 +569,10 @@ Note: callback value may be `undefined`.
|
|
|
575
569
|
|
|
576
570
|
```ts
|
|
577
571
|
// Execute for each entry
|
|
578
|
-
const tm = new TreeMap<number, string>([
|
|
572
|
+
const tm = new TreeMap<number, string>([
|
|
573
|
+
[1, 'a'],
|
|
574
|
+
[2, 'b']
|
|
575
|
+
]);
|
|
579
576
|
const pairs: string[] = [];
|
|
580
577
|
tm.forEach((v, k) => pairs.push(`${k}:${v}`));
|
|
581
578
|
console.log(pairs); // ['1:a', '2:b'];
|
|
@@ -589,7 +586,7 @@ Note: callback value may be `undefined`.
|
|
|
589
586
|
get(key): V | undefined;
|
|
590
587
|
```
|
|
591
588
|
|
|
592
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
589
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:197](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L197)
|
|
593
590
|
|
|
594
591
|
Get the value under a key.
|
|
595
592
|
|
|
@@ -607,8 +604,6 @@ Get the value under a key.
|
|
|
607
604
|
|
|
608
605
|
Expected time O(log n)
|
|
609
606
|
|
|
610
|
-
*
|
|
611
|
-
|
|
612
607
|
#### Example
|
|
613
608
|
|
|
614
609
|
```ts
|
|
@@ -632,7 +627,7 @@ Expected time O(log n)
|
|
|
632
627
|
getByRank(k): [K, V | undefined] | undefined;
|
|
633
628
|
```
|
|
634
629
|
|
|
635
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
630
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:823](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L823)
|
|
636
631
|
|
|
637
632
|
Returns the entry at the k-th position in tree order (0-indexed).
|
|
638
633
|
|
|
@@ -650,8 +645,6 @@ Returns the entry at the k-th position in tree order (0-indexed).
|
|
|
650
645
|
|
|
651
646
|
Time O(log n). Requires `enableOrderStatistic: true`.
|
|
652
647
|
|
|
653
|
-
*
|
|
654
|
-
|
|
655
648
|
#### Example
|
|
656
649
|
|
|
657
650
|
```ts
|
|
@@ -673,7 +666,7 @@ Time O(log n). Requires `enableOrderStatistic: true`.
|
|
|
673
666
|
getRank(key): number;
|
|
674
667
|
```
|
|
675
668
|
|
|
676
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
669
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:843](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L843)
|
|
677
670
|
|
|
678
671
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
679
672
|
|
|
@@ -690,7 +683,6 @@ Returns the 0-based rank of a key (number of elements that precede it in tree or
|
|
|
690
683
|
#### Remarks
|
|
691
684
|
|
|
692
685
|
Time O(log n). Requires `enableOrderStatistic: true`.
|
|
693
|
-
*
|
|
694
686
|
|
|
695
687
|
#### Example
|
|
696
688
|
|
|
@@ -714,7 +706,7 @@ Time O(log n). Requires `enableOrderStatistic: true`.
|
|
|
714
706
|
has(key): boolean;
|
|
715
707
|
```
|
|
716
708
|
|
|
717
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
709
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:216](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L216)
|
|
718
710
|
|
|
719
711
|
Test whether a key exists.
|
|
720
712
|
|
|
@@ -732,8 +724,6 @@ Test whether a key exists.
|
|
|
732
724
|
|
|
733
725
|
Expected time O(log n)
|
|
734
726
|
|
|
735
|
-
*
|
|
736
|
-
|
|
737
727
|
#### Example
|
|
738
728
|
|
|
739
729
|
```ts
|
|
@@ -756,12 +746,10 @@ Expected time O(log n)
|
|
|
756
746
|
higher(key): [K, V | undefined] | undefined;
|
|
757
747
|
```
|
|
758
748
|
|
|
759
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
749
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:731](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L731)
|
|
760
750
|
|
|
761
751
|
Smallest entry whose key is > the given key.
|
|
762
752
|
|
|
763
|
-
*
|
|
764
|
-
|
|
765
753
|
#### Parameters
|
|
766
754
|
|
|
767
755
|
##### key
|
|
@@ -799,12 +787,10 @@ Smallest entry whose key is > the given key.
|
|
|
799
787
|
isEmpty(): boolean;
|
|
800
788
|
```
|
|
801
789
|
|
|
802
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
790
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:124](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L124)
|
|
803
791
|
|
|
804
792
|
Whether the map is empty.
|
|
805
793
|
|
|
806
|
-
*
|
|
807
|
-
|
|
808
794
|
#### Returns
|
|
809
795
|
|
|
810
796
|
`boolean`
|
|
@@ -824,12 +810,10 @@ Whether the map is empty.
|
|
|
824
810
|
keys(): IterableIterator<K>;
|
|
825
811
|
```
|
|
826
812
|
|
|
827
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
813
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:283](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L283)
|
|
828
814
|
|
|
829
815
|
Iterate over keys in ascending order.
|
|
830
816
|
|
|
831
|
-
*
|
|
832
|
-
|
|
833
817
|
#### Returns
|
|
834
818
|
|
|
835
819
|
`IterableIterator`\<`K`\>
|
|
@@ -838,7 +822,10 @@ Iterate over keys in ascending order.
|
|
|
838
822
|
|
|
839
823
|
```ts
|
|
840
824
|
// Get sorted keys
|
|
841
|
-
const tm = new TreeMap<number, string>([
|
|
825
|
+
const tm = new TreeMap<number, string>([
|
|
826
|
+
[3, 'c'],
|
|
827
|
+
[1, 'a']
|
|
828
|
+
]);
|
|
842
829
|
console.log([...tm.keys()]); // [1, 3];
|
|
843
830
|
```
|
|
844
831
|
|
|
@@ -850,12 +837,10 @@ Iterate over keys in ascending order.
|
|
|
850
837
|
last(): [K, V | undefined] | undefined;
|
|
851
838
|
```
|
|
852
839
|
|
|
853
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
840
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:602](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L602)
|
|
854
841
|
|
|
855
842
|
Largest entry by key.
|
|
856
843
|
|
|
857
|
-
*
|
|
858
|
-
|
|
859
844
|
#### Returns
|
|
860
845
|
|
|
861
846
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -882,12 +867,10 @@ Largest entry by key.
|
|
|
882
867
|
lower(key): [K, V | undefined] | undefined;
|
|
883
868
|
```
|
|
884
869
|
|
|
885
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
870
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:753](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L753)
|
|
886
871
|
|
|
887
872
|
Largest entry whose key is < the given key.
|
|
888
873
|
|
|
889
|
-
*
|
|
890
|
-
|
|
891
874
|
#### Parameters
|
|
892
875
|
|
|
893
876
|
##### key
|
|
@@ -926,7 +909,7 @@ map<MK, MV>(
|
|
|
926
909
|
thisArg?): TreeMap<MK, MV>;
|
|
927
910
|
```
|
|
928
911
|
|
|
929
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
912
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L360)
|
|
930
913
|
|
|
931
914
|
Create a new TreeMap by mapping each entry to a new `[key, value]` entry.
|
|
932
915
|
|
|
@@ -964,13 +947,14 @@ This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
|
|
|
964
947
|
|
|
965
948
|
Time O(n log n) expected, Space O(n)
|
|
966
949
|
|
|
967
|
-
*
|
|
968
|
-
|
|
969
950
|
#### Example
|
|
970
951
|
|
|
971
952
|
```ts
|
|
972
953
|
// Transform entries
|
|
973
|
-
const tm = new TreeMap<number, number>([
|
|
954
|
+
const tm = new TreeMap<number, number>([
|
|
955
|
+
[1, 10],
|
|
956
|
+
[2, 20]
|
|
957
|
+
]);
|
|
974
958
|
const doubled = tm.map((v, k) => [k, (v ?? 0) * 2] as [number, number]);
|
|
975
959
|
console.log([...doubled.values()]); // [20, 40];
|
|
976
960
|
```
|
|
@@ -983,12 +967,10 @@ Time O(n log n) expected, Space O(n)
|
|
|
983
967
|
pollFirst(): [K, V | undefined] | undefined;
|
|
984
968
|
```
|
|
985
969
|
|
|
986
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
970
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L625)
|
|
987
971
|
|
|
988
972
|
Remove and return the smallest entry.
|
|
989
973
|
|
|
990
|
-
*
|
|
991
|
-
|
|
992
974
|
#### Returns
|
|
993
975
|
|
|
994
976
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -1017,12 +999,10 @@ Remove and return the smallest entry.
|
|
|
1017
999
|
pollLast(): [K, V | undefined] | undefined;
|
|
1018
1000
|
```
|
|
1019
1001
|
|
|
1020
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1002
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:647](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L647)
|
|
1021
1003
|
|
|
1022
1004
|
Remove and return the largest entry.
|
|
1023
1005
|
|
|
1024
|
-
*
|
|
1025
|
-
|
|
1026
1006
|
#### Returns
|
|
1027
1007
|
|
|
1028
1008
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -1051,7 +1031,7 @@ Remove and return the largest entry.
|
|
|
1051
1031
|
print(): void;
|
|
1052
1032
|
```
|
|
1053
1033
|
|
|
1054
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1034
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:550](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L550)
|
|
1055
1035
|
|
|
1056
1036
|
Print a human-friendly representation.
|
|
1057
1037
|
|
|
@@ -1063,8 +1043,6 @@ Print a human-friendly representation.
|
|
|
1063
1043
|
|
|
1064
1044
|
Time O(n), Space O(n)
|
|
1065
1045
|
|
|
1066
|
-
*
|
|
1067
|
-
|
|
1068
1046
|
#### Example
|
|
1069
1047
|
|
|
1070
1048
|
```ts
|
|
@@ -1081,7 +1059,7 @@ Time O(n), Space O(n)
|
|
|
1081
1059
|
rangeByRank(start, end): [K, V | undefined][];
|
|
1082
1060
|
```
|
|
1083
1061
|
|
|
1084
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1062
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:864](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L864)
|
|
1085
1063
|
|
|
1086
1064
|
Returns keys by rank range (0-indexed, inclusive on both ends).
|
|
1087
1065
|
|
|
@@ -1103,16 +1081,11 @@ Returns keys by rank range (0-indexed, inclusive on both ends).
|
|
|
1103
1081
|
|
|
1104
1082
|
Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
1105
1083
|
|
|
1106
|
-
*
|
|
1107
|
-
|
|
1108
1084
|
#### Example
|
|
1109
1085
|
|
|
1110
1086
|
```ts
|
|
1111
1087
|
// Pagination by position in tree order
|
|
1112
|
-
const tree = new TreeMap<number>(
|
|
1113
|
-
[10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
1114
|
-
{ enableOrderStatistic: true }
|
|
1115
|
-
);
|
|
1088
|
+
const tree = new TreeMap<number>([10, 20, 30, 40, 50, 60, 70, 80, 90], { enableOrderStatistic: true });
|
|
1116
1089
|
const pageSize = 3;
|
|
1117
1090
|
|
|
1118
1091
|
// Page 1
|
|
@@ -1131,7 +1104,7 @@ Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
|
1131
1104
|
rangeSearch(range, options?): [K, V | undefined][];
|
|
1132
1105
|
```
|
|
1133
1106
|
|
|
1134
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1107
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:792](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L792)
|
|
1135
1108
|
|
|
1136
1109
|
Return all entries in a given key range.
|
|
1137
1110
|
|
|
@@ -1149,8 +1122,6 @@ Return all entries in a given key range.
|
|
|
1149
1122
|
|
|
1150
1123
|
Inclusive/exclusive bounds (defaults to inclusive).
|
|
1151
1124
|
|
|
1152
|
-
*
|
|
1153
|
-
|
|
1154
1125
|
#### Returns
|
|
1155
1126
|
|
|
1156
1127
|
\[`K`, `V` \| `undefined`\][]
|
|
@@ -1182,10 +1153,7 @@ Inclusive/exclusive bounds (defaults to inclusive).
|
|
|
1182
1153
|
console.log([...highStock.keys()]); // ['Doohickey', 'Widget'];
|
|
1183
1154
|
|
|
1184
1155
|
// Calculate total inventory value
|
|
1185
|
-
const totalValue = inventory.reduce(
|
|
1186
|
-
(sum, p) => sum + (p ? p.price * p.stock : 0),
|
|
1187
|
-
0
|
|
1188
|
-
);
|
|
1156
|
+
const totalValue = inventory.reduce((sum, p) => sum + (p ? p.price * p.stock : 0), 0);
|
|
1189
1157
|
console.log(totalValue); // toBeCloseTo;
|
|
1190
1158
|
```
|
|
1191
1159
|
|
|
@@ -1197,7 +1165,7 @@ Inclusive/exclusive bounds (defaults to inclusive).
|
|
|
1197
1165
|
reduce<A>(callbackfn, initialValue): A;
|
|
1198
1166
|
```
|
|
1199
1167
|
|
|
1200
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1168
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:426](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L426)
|
|
1201
1169
|
|
|
1202
1170
|
Reduce entries into a single accumulator.
|
|
1203
1171
|
|
|
@@ -1225,13 +1193,14 @@ Reduce entries into a single accumulator.
|
|
|
1225
1193
|
|
|
1226
1194
|
Time O(n), Space O(1)
|
|
1227
1195
|
|
|
1228
|
-
*
|
|
1229
|
-
|
|
1230
1196
|
#### Example
|
|
1231
1197
|
|
|
1232
1198
|
```ts
|
|
1233
1199
|
// Aggregate values
|
|
1234
|
-
const tm = new TreeMap<number, number>([
|
|
1200
|
+
const tm = new TreeMap<number, number>([
|
|
1201
|
+
[1, 10],
|
|
1202
|
+
[2, 20]
|
|
1203
|
+
]);
|
|
1235
1204
|
console.log(tm.reduce((acc, v) => acc + (v ?? 0), 0)); // 30;
|
|
1236
1205
|
```
|
|
1237
1206
|
|
|
@@ -1243,7 +1212,7 @@ Time O(n), Space O(1)
|
|
|
1243
1212
|
set(key, value): this;
|
|
1244
1213
|
```
|
|
1245
1214
|
|
|
1246
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1215
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:152](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L152)
|
|
1247
1216
|
|
|
1248
1217
|
Set or overwrite a value for a key.
|
|
1249
1218
|
|
|
@@ -1265,8 +1234,6 @@ Set or overwrite a value for a key.
|
|
|
1265
1234
|
|
|
1266
1235
|
Expected time O(log n)
|
|
1267
1236
|
|
|
1268
|
-
*
|
|
1269
|
-
|
|
1270
1237
|
#### Example
|
|
1271
1238
|
|
|
1272
1239
|
```ts
|
|
@@ -1299,7 +1266,7 @@ Expected time O(log n)
|
|
|
1299
1266
|
setMany(entries): boolean[];
|
|
1300
1267
|
```
|
|
1301
1268
|
|
|
1302
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1269
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:173](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L173)
|
|
1303
1270
|
|
|
1304
1271
|
Set multiple key-value pairs at once.
|
|
1305
1272
|
|
|
@@ -1317,8 +1284,6 @@ Iterable of `[key, value]` tuples.
|
|
|
1317
1284
|
|
|
1318
1285
|
Array of booleans indicating whether each entry was successfully set.
|
|
1319
1286
|
|
|
1320
|
-
*
|
|
1321
|
-
|
|
1322
1287
|
#### Remarks
|
|
1323
1288
|
|
|
1324
1289
|
Expected time O(m log n), where m is the number of entries.
|
|
@@ -1328,7 +1293,11 @@ Expected time O(m log n), where m is the number of entries.
|
|
|
1328
1293
|
```ts
|
|
1329
1294
|
// Set multiple key-value pairs
|
|
1330
1295
|
const tm = new TreeMap<number, string>();
|
|
1331
|
-
tm.setMany([
|
|
1296
|
+
tm.setMany([
|
|
1297
|
+
[1, 'a'],
|
|
1298
|
+
[2, 'b'],
|
|
1299
|
+
[3, 'c']
|
|
1300
|
+
]);
|
|
1332
1301
|
console.log(tm.size); // 3;
|
|
1333
1302
|
```
|
|
1334
1303
|
|
|
@@ -1340,7 +1309,7 @@ Expected time O(m log n), where m is the number of entries.
|
|
|
1340
1309
|
some(callbackfn, thisArg?): boolean;
|
|
1341
1310
|
```
|
|
1342
1311
|
|
|
1343
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1312
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:473](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L473)
|
|
1344
1313
|
|
|
1345
1314
|
Test whether any entry satisfies a predicate.
|
|
1346
1315
|
|
|
@@ -1362,13 +1331,14 @@ Test whether any entry satisfies a predicate.
|
|
|
1362
1331
|
|
|
1363
1332
|
Time O(n), Space O(1)
|
|
1364
1333
|
|
|
1365
|
-
*
|
|
1366
|
-
|
|
1367
1334
|
#### Example
|
|
1368
1335
|
|
|
1369
1336
|
```ts
|
|
1370
1337
|
// Test any entry
|
|
1371
|
-
const tm = new TreeMap<number, string>([
|
|
1338
|
+
const tm = new TreeMap<number, string>([
|
|
1339
|
+
[1, 'a'],
|
|
1340
|
+
[2, 'b']
|
|
1341
|
+
]);
|
|
1372
1342
|
console.log(tm.some((v, k) => k === 2)); // true;
|
|
1373
1343
|
```
|
|
1374
1344
|
|
|
@@ -1380,7 +1350,7 @@ Time O(n), Space O(1)
|
|
|
1380
1350
|
toArray(): [K, V | undefined][];
|
|
1381
1351
|
```
|
|
1382
1352
|
|
|
1383
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1353
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:538](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L538)
|
|
1384
1354
|
|
|
1385
1355
|
Materialize the map into an array of `[key, value]` tuples.
|
|
1386
1356
|
|
|
@@ -1392,14 +1362,18 @@ Materialize the map into an array of `[key, value]` tuples.
|
|
|
1392
1362
|
|
|
1393
1363
|
Time O(n), Space O(n)
|
|
1394
1364
|
|
|
1395
|
-
*
|
|
1396
|
-
|
|
1397
1365
|
#### Example
|
|
1398
1366
|
|
|
1399
1367
|
```ts
|
|
1400
1368
|
// Convert to array
|
|
1401
|
-
const tm = new TreeMap<number, string>([
|
|
1402
|
-
|
|
1369
|
+
const tm = new TreeMap<number, string>([
|
|
1370
|
+
[2, 'b'],
|
|
1371
|
+
[1, 'a']
|
|
1372
|
+
]);
|
|
1373
|
+
console.log(tm.toArray()); // [
|
|
1374
|
+
// [1, 'a'],
|
|
1375
|
+
// [2, 'b']
|
|
1376
|
+
// ];
|
|
1403
1377
|
```
|
|
1404
1378
|
|
|
1405
1379
|
***
|
|
@@ -1410,14 +1384,12 @@ Time O(n), Space O(n)
|
|
|
1410
1384
|
values(): IterableIterator<V | undefined>;
|
|
1411
1385
|
```
|
|
1412
1386
|
|
|
1413
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1387
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:299](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L299)
|
|
1414
1388
|
|
|
1415
1389
|
Iterate over values in ascending key order.
|
|
1416
1390
|
|
|
1417
1391
|
Note: values may be `undefined` (TreeMap allows storing `undefined`, like native `Map`).
|
|
1418
1392
|
|
|
1419
|
-
*
|
|
1420
|
-
|
|
1421
1393
|
#### Returns
|
|
1422
1394
|
|
|
1423
1395
|
`IterableIterator`\<`V` \| `undefined`\>
|
|
@@ -1426,7 +1398,10 @@ Note: values may be `undefined` (TreeMap allows storing `undefined`, like native
|
|
|
1426
1398
|
|
|
1427
1399
|
```ts
|
|
1428
1400
|
// Get values in key order
|
|
1429
|
-
const tm = new TreeMap<number, string>([
|
|
1401
|
+
const tm = new TreeMap<number, string>([
|
|
1402
|
+
[2, 'b'],
|
|
1403
|
+
[1, 'a']
|
|
1404
|
+
]);
|
|
1430
1405
|
console.log([...tm.values()]); // ['a', 'b'];
|
|
1431
1406
|
```
|
|
1432
1407
|
|
|
@@ -1438,7 +1413,7 @@ Note: values may be `undefined` (TreeMap allows storing `undefined`, like native
|
|
|
1438
1413
|
static createDefaultComparator<K>(): Comparator<K>;
|
|
1439
1414
|
```
|
|
1440
1415
|
|
|
1441
|
-
Defined in: [data-structures/binary-tree/tree-map.ts:
|
|
1416
|
+
Defined in: [data-structures/binary-tree/tree-map.ts:95](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-map.ts#L95)
|
|
1442
1417
|
|
|
1443
1418
|
Create the strict default comparator.
|
|
1444
1419
|
|