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: TreeSet\<K, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
9
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:30](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L30)
|
|
10
10
|
|
|
11
11
|
An ordered Set backed by a red-black tree.
|
|
12
12
|
|
|
@@ -44,7 +44,7 @@ An ordered Set backed by a red-black tree.
|
|
|
44
44
|
new TreeSet<K, R>(elements?, options?): TreeSet<K, R>;
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
47
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:50](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L50)
|
|
48
48
|
|
|
49
49
|
Create a TreeSet from an iterable of keys or raw elements.
|
|
50
50
|
|
|
@@ -92,7 +92,7 @@ const set = new TreeSet<number, User>(users, { toElementFn: u => u.id });
|
|
|
92
92
|
get size(): number;
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
95
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:70](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L70)
|
|
96
96
|
|
|
97
97
|
Number of elements in the set.
|
|
98
98
|
|
|
@@ -108,7 +108,7 @@ Number of elements in the set.
|
|
|
108
108
|
add(key): this;
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
111
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:133](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L133)
|
|
112
112
|
|
|
113
113
|
Add a key to the set (no-op if already present).
|
|
114
114
|
|
|
@@ -126,8 +126,6 @@ Add a key to the set (no-op if already present).
|
|
|
126
126
|
|
|
127
127
|
Expected time O(log n)
|
|
128
128
|
|
|
129
|
-
*
|
|
130
|
-
|
|
131
129
|
#### Example
|
|
132
130
|
|
|
133
131
|
```ts
|
|
@@ -151,7 +149,7 @@ Expected time O(log n)
|
|
|
151
149
|
addMany(keys): boolean[];
|
|
152
150
|
```
|
|
153
151
|
|
|
154
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
152
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:151](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L151)
|
|
155
153
|
|
|
156
154
|
Add multiple keys at once.
|
|
157
155
|
|
|
@@ -169,8 +167,6 @@ Iterable of keys to add.
|
|
|
169
167
|
|
|
170
168
|
Array of booleans indicating whether each key was newly added.
|
|
171
169
|
|
|
172
|
-
*
|
|
173
|
-
|
|
174
170
|
#### Remarks
|
|
175
171
|
|
|
176
172
|
Expected time O(m log n), where m is the number of keys.
|
|
@@ -192,12 +188,10 @@ Expected time O(m log n), where m is the number of keys.
|
|
|
192
188
|
ceiling(key): K | undefined;
|
|
193
189
|
```
|
|
194
190
|
|
|
195
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
191
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:550](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L550)
|
|
196
192
|
|
|
197
193
|
Smallest key that is >= the given key.
|
|
198
194
|
|
|
199
|
-
*
|
|
200
|
-
|
|
201
195
|
#### Parameters
|
|
202
196
|
|
|
203
197
|
##### key
|
|
@@ -236,12 +230,10 @@ Smallest key that is >= the given key.
|
|
|
236
230
|
clear(): void;
|
|
237
231
|
```
|
|
238
232
|
|
|
239
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
233
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L218)
|
|
240
234
|
|
|
241
235
|
Remove all keys.
|
|
242
236
|
|
|
243
|
-
*
|
|
244
|
-
|
|
245
237
|
#### Returns
|
|
246
238
|
|
|
247
239
|
`void`
|
|
@@ -263,12 +255,10 @@ Remove all keys.
|
|
|
263
255
|
clone(): TreeSet<K>;
|
|
264
256
|
```
|
|
265
257
|
|
|
266
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
258
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:837](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L837)
|
|
267
259
|
|
|
268
260
|
Deep copy
|
|
269
261
|
|
|
270
|
-
*
|
|
271
|
-
|
|
272
262
|
#### Returns
|
|
273
263
|
|
|
274
264
|
`TreeSet`\<`K`\>
|
|
@@ -291,7 +281,7 @@ Deep copy
|
|
|
291
281
|
delete(key): boolean;
|
|
292
282
|
```
|
|
293
283
|
|
|
294
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
284
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:187](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L187)
|
|
295
285
|
|
|
296
286
|
Delete a key.
|
|
297
287
|
|
|
@@ -311,8 +301,6 @@ Delete a key.
|
|
|
311
301
|
|
|
312
302
|
Expected time O(log n)
|
|
313
303
|
|
|
314
|
-
*
|
|
315
|
-
|
|
316
304
|
#### Example
|
|
317
305
|
|
|
318
306
|
```ts
|
|
@@ -332,7 +320,7 @@ Expected time O(log n)
|
|
|
332
320
|
deleteWhere(predicate): boolean;
|
|
333
321
|
```
|
|
334
322
|
|
|
335
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
323
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:198](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L198)
|
|
336
324
|
|
|
337
325
|
Delete all keys matching a predicate.
|
|
338
326
|
|
|
@@ -362,7 +350,7 @@ Time O(N), Space O(N)
|
|
|
362
350
|
difference(other): TreeSet<K>;
|
|
363
351
|
```
|
|
364
352
|
|
|
365
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
353
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:748](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L748)
|
|
366
354
|
|
|
367
355
|
Return a new TreeSet containing elements in this set but not in the other.
|
|
368
356
|
|
|
@@ -379,7 +367,6 @@ Any iterable of keys.
|
|
|
379
367
|
`TreeSet`\<`K`\>
|
|
380
368
|
|
|
381
369
|
A new TreeSet.
|
|
382
|
-
*
|
|
383
370
|
|
|
384
371
|
#### Remarks
|
|
385
372
|
|
|
@@ -400,14 +387,12 @@ Time O(n+m) with ordered merge when possible, otherwise O(n log m).
|
|
|
400
387
|
entries(): IterableIterator<[K, K]>;
|
|
401
388
|
```
|
|
402
389
|
|
|
403
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
390
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:255](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L255)
|
|
404
391
|
|
|
405
392
|
Iterate over `[value, value]` pairs (native Set convention).
|
|
406
393
|
|
|
407
394
|
Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during iteration.
|
|
408
395
|
|
|
409
|
-
*
|
|
410
|
-
|
|
411
396
|
#### Returns
|
|
412
397
|
|
|
413
398
|
`IterableIterator`\<\[`K`, `K`\]\>
|
|
@@ -428,7 +413,7 @@ Note: TreeSet stores only keys internally; `[k, k]` is created on-the-fly during
|
|
|
428
413
|
every(callbackfn, thisArg?): boolean;
|
|
429
414
|
```
|
|
430
415
|
|
|
431
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
416
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:357](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L357)
|
|
432
417
|
|
|
433
418
|
Test whether all values satisfy a predicate.
|
|
434
419
|
|
|
@@ -450,8 +435,6 @@ Test whether all values satisfy a predicate.
|
|
|
450
435
|
|
|
451
436
|
Time O(n), Space O(1)
|
|
452
437
|
|
|
453
|
-
*
|
|
454
|
-
|
|
455
438
|
#### Example
|
|
456
439
|
|
|
457
440
|
```ts
|
|
@@ -468,7 +451,7 @@ Time O(n), Space O(1)
|
|
|
468
451
|
filter(callbackfn, thisArg?): TreeSet<K>;
|
|
469
452
|
```
|
|
470
453
|
|
|
471
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
454
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:315](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L315)
|
|
472
455
|
|
|
473
456
|
Create a new TreeSet containing only values that satisfy the predicate.
|
|
474
457
|
|
|
@@ -490,8 +473,6 @@ Create a new TreeSet containing only values that satisfy the predicate.
|
|
|
490
473
|
|
|
491
474
|
Time O(n log n) expected, Space O(n)
|
|
492
475
|
|
|
493
|
-
*
|
|
494
|
-
|
|
495
476
|
#### Example
|
|
496
477
|
|
|
497
478
|
```ts
|
|
@@ -509,7 +490,7 @@ Time O(n log n) expected, Space O(n)
|
|
|
509
490
|
find(callbackfn, thisArg?): K | undefined;
|
|
510
491
|
```
|
|
511
492
|
|
|
512
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
493
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:408](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L408)
|
|
513
494
|
|
|
514
495
|
Find the first value that satisfies a predicate.
|
|
515
496
|
|
|
@@ -531,8 +512,6 @@ Find the first value that satisfies a predicate.
|
|
|
531
512
|
|
|
532
513
|
Time O(n), Space O(1)
|
|
533
514
|
|
|
534
|
-
*
|
|
535
|
-
|
|
536
515
|
#### Example
|
|
537
516
|
|
|
538
517
|
```ts
|
|
@@ -550,12 +529,10 @@ Time O(n), Space O(1)
|
|
|
550
529
|
first(): K | undefined;
|
|
551
530
|
```
|
|
552
531
|
|
|
553
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
532
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:480](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L480)
|
|
554
533
|
|
|
555
534
|
Smallest key in the set.
|
|
556
535
|
|
|
557
|
-
*
|
|
558
|
-
|
|
559
536
|
#### Returns
|
|
560
537
|
|
|
561
538
|
`K` \| `undefined`
|
|
@@ -599,12 +576,10 @@ Smallest key in the set.
|
|
|
599
576
|
floor(key): K | undefined;
|
|
600
577
|
```
|
|
601
578
|
|
|
602
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
579
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:566](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L566)
|
|
603
580
|
|
|
604
581
|
Largest key that is <= the given key.
|
|
605
582
|
|
|
606
|
-
*
|
|
607
|
-
|
|
608
583
|
#### Parameters
|
|
609
584
|
|
|
610
585
|
##### key
|
|
@@ -635,14 +610,12 @@ Largest key that is <= the given key.
|
|
|
635
610
|
forEach(cb, thisArg?): void;
|
|
636
611
|
```
|
|
637
612
|
|
|
638
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
613
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:274](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L274)
|
|
639
614
|
|
|
640
615
|
Visit each value in ascending order.
|
|
641
616
|
|
|
642
617
|
Callback follows native Set convention: `(value, value2, set)`.
|
|
643
618
|
|
|
644
|
-
*
|
|
645
|
-
|
|
646
619
|
#### Parameters
|
|
647
620
|
|
|
648
621
|
##### cb
|
|
@@ -675,7 +648,7 @@ Callback follows native Set convention: `(value, value2, set)`.
|
|
|
675
648
|
getByRank(k): K | undefined;
|
|
676
649
|
```
|
|
677
650
|
|
|
678
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
651
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L650)
|
|
679
652
|
|
|
680
653
|
Returns the element at the k-th position in tree order (0-indexed).
|
|
681
654
|
|
|
@@ -693,8 +666,6 @@ Returns the element at the k-th position in tree order (0-indexed).
|
|
|
693
666
|
|
|
694
667
|
Time O(log n). Requires `enableOrderStatistic: true`.
|
|
695
668
|
|
|
696
|
-
*
|
|
697
|
-
|
|
698
669
|
#### Example
|
|
699
670
|
|
|
700
671
|
```ts
|
|
@@ -713,7 +684,7 @@ Time O(log n). Requires `enableOrderStatistic: true`.
|
|
|
713
684
|
getRank(key): number;
|
|
714
685
|
```
|
|
715
686
|
|
|
716
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
687
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:670](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L670)
|
|
717
688
|
|
|
718
689
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
719
690
|
|
|
@@ -730,7 +701,6 @@ Returns the 0-based rank of a key (number of elements that precede it in tree or
|
|
|
730
701
|
#### Remarks
|
|
731
702
|
|
|
732
703
|
Time O(log n). Requires `enableOrderStatistic: true`.
|
|
733
|
-
*
|
|
734
704
|
|
|
735
705
|
#### Example
|
|
736
706
|
|
|
@@ -754,7 +724,7 @@ Time O(log n). Requires `enableOrderStatistic: true`.
|
|
|
754
724
|
has(key): boolean;
|
|
755
725
|
```
|
|
756
726
|
|
|
757
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
727
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:170](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L170)
|
|
758
728
|
|
|
759
729
|
Test whether a key exists.
|
|
760
730
|
|
|
@@ -772,8 +742,6 @@ Test whether a key exists.
|
|
|
772
742
|
|
|
773
743
|
Expected time O(log n)
|
|
774
744
|
|
|
775
|
-
*
|
|
776
|
-
|
|
777
745
|
#### Example
|
|
778
746
|
|
|
779
747
|
```ts
|
|
@@ -792,12 +760,10 @@ Expected time O(log n)
|
|
|
792
760
|
higher(key): K | undefined;
|
|
793
761
|
```
|
|
794
762
|
|
|
795
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
763
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:580](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L580)
|
|
796
764
|
|
|
797
765
|
Smallest key that is > the given key.
|
|
798
766
|
|
|
799
|
-
*
|
|
800
|
-
|
|
801
767
|
#### Parameters
|
|
802
768
|
|
|
803
769
|
##### key
|
|
@@ -826,7 +792,7 @@ Smallest key that is > the given key.
|
|
|
826
792
|
intersection(other): TreeSet<K>;
|
|
827
793
|
```
|
|
828
794
|
|
|
829
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
795
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:730](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L730)
|
|
830
796
|
|
|
831
797
|
Return a new TreeSet containing only elements present in both sets.
|
|
832
798
|
|
|
@@ -843,7 +809,6 @@ Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
|
|
|
843
809
|
`TreeSet`\<`K`\>
|
|
844
810
|
|
|
845
811
|
A new TreeSet.
|
|
846
|
-
*
|
|
847
812
|
|
|
848
813
|
#### Remarks
|
|
849
814
|
|
|
@@ -864,7 +829,7 @@ Time O(n+m) with ordered merge when possible, otherwise O(n log m).
|
|
|
864
829
|
isDisjointFrom(other): boolean;
|
|
865
830
|
```
|
|
866
831
|
|
|
867
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
832
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:820](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L820)
|
|
868
833
|
|
|
869
834
|
Check whether this set and the other share no common elements.
|
|
870
835
|
|
|
@@ -881,7 +846,6 @@ Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
|
|
|
881
846
|
`boolean`
|
|
882
847
|
|
|
883
848
|
`true` if sets are disjoint.
|
|
884
|
-
*
|
|
885
849
|
|
|
886
850
|
#### Remarks
|
|
887
851
|
|
|
@@ -902,12 +866,10 @@ Time O(min(n,m)), can short-circuit on first overlap.
|
|
|
902
866
|
isEmpty(): boolean;
|
|
903
867
|
```
|
|
904
868
|
|
|
905
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
869
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:114](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L114)
|
|
906
870
|
|
|
907
871
|
Whether the set is empty.
|
|
908
872
|
|
|
909
|
-
*
|
|
910
|
-
|
|
911
873
|
#### Returns
|
|
912
874
|
|
|
913
875
|
`boolean`
|
|
@@ -927,7 +889,7 @@ Whether the set is empty.
|
|
|
927
889
|
isSubsetOf(other): boolean;
|
|
928
890
|
```
|
|
929
891
|
|
|
930
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
892
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:787](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L787)
|
|
931
893
|
|
|
932
894
|
Check whether every element in this set is also in the other.
|
|
933
895
|
|
|
@@ -944,7 +906,6 @@ Any iterable of keys (converted to Set for fast lookup if not a TreeSet).
|
|
|
944
906
|
`boolean`
|
|
945
907
|
|
|
946
908
|
`true` if this is a subset of other.
|
|
947
|
-
*
|
|
948
909
|
|
|
949
910
|
#### Remarks
|
|
950
911
|
|
|
@@ -965,7 +926,7 @@ Time O(n).
|
|
|
965
926
|
isSupersetOf(other): boolean;
|
|
966
927
|
```
|
|
967
928
|
|
|
968
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
929
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:804](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L804)
|
|
969
930
|
|
|
970
931
|
Check whether every element in the other set is also in this set.
|
|
971
932
|
|
|
@@ -982,7 +943,6 @@ Any iterable of keys.
|
|
|
982
943
|
`boolean`
|
|
983
944
|
|
|
984
945
|
`true` if this is a superset of other.
|
|
985
|
-
*
|
|
986
946
|
|
|
987
947
|
#### Remarks
|
|
988
948
|
|
|
@@ -1003,12 +963,10 @@ Time O(m).
|
|
|
1003
963
|
keys(): IterableIterator<K>;
|
|
1004
964
|
```
|
|
1005
965
|
|
|
1006
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
966
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:229](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L229)
|
|
1007
967
|
|
|
1008
968
|
Iterate over keys in ascending order.
|
|
1009
969
|
|
|
1010
|
-
*
|
|
1011
|
-
|
|
1012
970
|
#### Returns
|
|
1013
971
|
|
|
1014
972
|
`IterableIterator`\<`K`\>
|
|
@@ -1029,12 +987,10 @@ Iterate over keys in ascending order.
|
|
|
1029
987
|
last(): K | undefined;
|
|
1030
988
|
```
|
|
1031
989
|
|
|
1032
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
990
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:494](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L494)
|
|
1033
991
|
|
|
1034
992
|
Largest key in the set.
|
|
1035
993
|
|
|
1036
|
-
*
|
|
1037
|
-
|
|
1038
994
|
#### Returns
|
|
1039
995
|
|
|
1040
996
|
`K` \| `undefined`
|
|
@@ -1056,12 +1012,10 @@ Largest key in the set.
|
|
|
1056
1012
|
lower(key): K | undefined;
|
|
1057
1013
|
```
|
|
1058
1014
|
|
|
1059
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1015
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:594](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L594)
|
|
1060
1016
|
|
|
1061
1017
|
Largest key that is < the given key.
|
|
1062
1018
|
|
|
1063
|
-
*
|
|
1064
|
-
|
|
1065
1019
|
#### Parameters
|
|
1066
1020
|
|
|
1067
1021
|
##### key
|
|
@@ -1093,7 +1047,7 @@ map<MK>(
|
|
|
1093
1047
|
thisArg?): TreeSet<MK>;
|
|
1094
1048
|
```
|
|
1095
1049
|
|
|
1096
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1050
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:289](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L289)
|
|
1097
1051
|
|
|
1098
1052
|
Create a new TreeSet by mapping each value to a new key.
|
|
1099
1053
|
|
|
@@ -1127,8 +1081,6 @@ This mirrors `RedBlackTree.map`: mapping produces a new ordered container.
|
|
|
1127
1081
|
|
|
1128
1082
|
Time O(n log n) expected, Space O(n)
|
|
1129
1083
|
|
|
1130
|
-
*
|
|
1131
|
-
|
|
1132
1084
|
#### Example
|
|
1133
1085
|
|
|
1134
1086
|
```ts
|
|
@@ -1146,12 +1098,10 @@ Time O(n log n) expected, Space O(n)
|
|
|
1146
1098
|
pollFirst(): K | undefined;
|
|
1147
1099
|
```
|
|
1148
1100
|
|
|
1149
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1101
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:508](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L508)
|
|
1150
1102
|
|
|
1151
1103
|
Remove and return the smallest key.
|
|
1152
1104
|
|
|
1153
|
-
*
|
|
1154
|
-
|
|
1155
1105
|
#### Returns
|
|
1156
1106
|
|
|
1157
1107
|
`K` \| `undefined`
|
|
@@ -1175,12 +1125,10 @@ Remove and return the smallest key.
|
|
|
1175
1125
|
pollLast(): K | undefined;
|
|
1176
1126
|
```
|
|
1177
1127
|
|
|
1178
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1128
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L524)
|
|
1179
1129
|
|
|
1180
1130
|
Remove and return the largest key.
|
|
1181
1131
|
|
|
1182
|
-
*
|
|
1183
|
-
|
|
1184
1132
|
#### Returns
|
|
1185
1133
|
|
|
1186
1134
|
`K` \| `undefined`
|
|
@@ -1203,7 +1151,7 @@ Remove and return the largest key.
|
|
|
1203
1151
|
print(): void;
|
|
1204
1152
|
```
|
|
1205
1153
|
|
|
1206
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1154
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:445](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L445)
|
|
1207
1155
|
|
|
1208
1156
|
Print a human-friendly representation.
|
|
1209
1157
|
|
|
@@ -1215,8 +1163,6 @@ Print a human-friendly representation.
|
|
|
1215
1163
|
|
|
1216
1164
|
Time O(n), Space O(n)
|
|
1217
1165
|
|
|
1218
|
-
*
|
|
1219
|
-
|
|
1220
1166
|
#### Example
|
|
1221
1167
|
|
|
1222
1168
|
```ts
|
|
@@ -1233,7 +1179,7 @@ Time O(n), Space O(n)
|
|
|
1233
1179
|
rangeByRank(start, end): K[];
|
|
1234
1180
|
```
|
|
1235
1181
|
|
|
1236
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1182
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:689](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L689)
|
|
1237
1183
|
|
|
1238
1184
|
Returns elements by rank range (0-indexed, inclusive on both ends).
|
|
1239
1185
|
|
|
@@ -1255,16 +1201,11 @@ Returns elements by rank range (0-indexed, inclusive on both ends).
|
|
|
1255
1201
|
|
|
1256
1202
|
Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
1257
1203
|
|
|
1258
|
-
*
|
|
1259
|
-
|
|
1260
1204
|
#### Example
|
|
1261
1205
|
|
|
1262
1206
|
```ts
|
|
1263
1207
|
// Pagination by position in tree order
|
|
1264
|
-
const tree = new TreeSet<number>(
|
|
1265
|
-
[10, 20, 30, 40, 50, 60, 70, 80, 90],
|
|
1266
|
-
{ enableOrderStatistic: true }
|
|
1267
|
-
);
|
|
1208
|
+
const tree = new TreeSet<number>([10, 20, 30, 40, 50, 60, 70, 80, 90], { enableOrderStatistic: true });
|
|
1268
1209
|
const pageSize = 3;
|
|
1269
1210
|
|
|
1270
1211
|
// Page 1
|
|
@@ -1283,7 +1224,7 @@ Time O(log n + k). Requires `enableOrderStatistic: true`.
|
|
|
1283
1224
|
rangeSearch(range, options?): K[];
|
|
1284
1225
|
```
|
|
1285
1226
|
|
|
1286
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1227
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:622](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L622)
|
|
1287
1228
|
|
|
1288
1229
|
Return all keys in a given range.
|
|
1289
1230
|
|
|
@@ -1301,8 +1242,6 @@ Return all keys in a given range.
|
|
|
1301
1242
|
|
|
1302
1243
|
Inclusive/exclusive bounds (defaults to inclusive).
|
|
1303
1244
|
|
|
1304
|
-
*
|
|
1305
|
-
|
|
1306
1245
|
#### Returns
|
|
1307
1246
|
|
|
1308
1247
|
`K`[]
|
|
@@ -1316,7 +1255,7 @@ Inclusive/exclusive bounds (defaults to inclusive).
|
|
|
1316
1255
|
167772160, // 10.0.0.0
|
|
1317
1256
|
167772416, // 10.0.1.0
|
|
1318
1257
|
167772672, // 10.0.2.0
|
|
1319
|
-
167773184
|
|
1258
|
+
167773184 // 10.0.4.0
|
|
1320
1259
|
]);
|
|
1321
1260
|
|
|
1322
1261
|
// Check if any blocked IP is in range 10.0.1.0 - 10.0.3.0
|
|
@@ -1336,7 +1275,7 @@ Inclusive/exclusive bounds (defaults to inclusive).
|
|
|
1336
1275
|
reduce<A>(callbackfn, initialValue): A;
|
|
1337
1276
|
```
|
|
1338
1277
|
|
|
1339
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1278
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:342](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L342)
|
|
1340
1279
|
|
|
1341
1280
|
Reduce values into a single accumulator.
|
|
1342
1281
|
|
|
@@ -1364,8 +1303,6 @@ Reduce values into a single accumulator.
|
|
|
1364
1303
|
|
|
1365
1304
|
Time O(n), Space O(1)
|
|
1366
1305
|
|
|
1367
|
-
*
|
|
1368
|
-
|
|
1369
1306
|
#### Example
|
|
1370
1307
|
|
|
1371
1308
|
```ts
|
|
@@ -1383,7 +1320,7 @@ Time O(n), Space O(1)
|
|
|
1383
1320
|
some(callbackfn, thisArg?): boolean;
|
|
1384
1321
|
```
|
|
1385
1322
|
|
|
1386
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1323
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:382](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L382)
|
|
1387
1324
|
|
|
1388
1325
|
Test whether any value satisfies a predicate.
|
|
1389
1326
|
|
|
@@ -1405,8 +1342,6 @@ Test whether any value satisfies a predicate.
|
|
|
1405
1342
|
|
|
1406
1343
|
Time O(n), Space O(1)
|
|
1407
1344
|
|
|
1408
|
-
*
|
|
1409
|
-
|
|
1410
1345
|
#### Example
|
|
1411
1346
|
|
|
1412
1347
|
```ts
|
|
@@ -1423,7 +1358,7 @@ Time O(n), Space O(1)
|
|
|
1423
1358
|
symmetricDifference(other): TreeSet<K>;
|
|
1424
1359
|
```
|
|
1425
1360
|
|
|
1426
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1361
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:766](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L766)
|
|
1427
1362
|
|
|
1428
1363
|
Return a new TreeSet containing elements in either set but not both.
|
|
1429
1364
|
|
|
@@ -1440,7 +1375,6 @@ Any iterable of keys.
|
|
|
1440
1375
|
`TreeSet`\<`K`\>
|
|
1441
1376
|
|
|
1442
1377
|
A new TreeSet.
|
|
1443
|
-
*
|
|
1444
1378
|
|
|
1445
1379
|
#### Remarks
|
|
1446
1380
|
|
|
@@ -1461,7 +1395,7 @@ Time O(n+m).
|
|
|
1461
1395
|
toArray(): K[];
|
|
1462
1396
|
```
|
|
1463
1397
|
|
|
1464
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1398
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:433](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L433)
|
|
1465
1399
|
|
|
1466
1400
|
Materialize the set into an array of keys.
|
|
1467
1401
|
|
|
@@ -1473,8 +1407,6 @@ Materialize the set into an array of keys.
|
|
|
1473
1407
|
|
|
1474
1408
|
Time O(n), Space O(n)
|
|
1475
1409
|
|
|
1476
|
-
*
|
|
1477
|
-
|
|
1478
1410
|
#### Example
|
|
1479
1411
|
|
|
1480
1412
|
```ts
|
|
@@ -1491,7 +1423,7 @@ Time O(n), Space O(n)
|
|
|
1491
1423
|
union(other): TreeSet<K>;
|
|
1492
1424
|
```
|
|
1493
1425
|
|
|
1494
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1426
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:702](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L702)
|
|
1495
1427
|
|
|
1496
1428
|
Return a new TreeSet containing all elements from both sets.
|
|
1497
1429
|
|
|
@@ -1508,7 +1440,6 @@ Any iterable of keys.
|
|
|
1508
1440
|
`TreeSet`\<`K`\>
|
|
1509
1441
|
|
|
1510
1442
|
A new TreeSet.
|
|
1511
|
-
*
|
|
1512
1443
|
|
|
1513
1444
|
#### Remarks
|
|
1514
1445
|
|
|
@@ -1529,14 +1460,12 @@ When both sets share the same comparator, uses O(n+m) merge. Otherwise O(m log n
|
|
|
1529
1460
|
values(): IterableIterator<K>;
|
|
1530
1461
|
```
|
|
1531
1462
|
|
|
1532
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1463
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L242)
|
|
1533
1464
|
|
|
1534
1465
|
Iterate over values in ascending order.
|
|
1535
1466
|
|
|
1536
1467
|
Note: for Set-like containers, `values()` is the same as `keys()`.
|
|
1537
1468
|
|
|
1538
|
-
*
|
|
1539
|
-
|
|
1540
1469
|
#### Returns
|
|
1541
1470
|
|
|
1542
1471
|
`IterableIterator`\<`K`\>
|
|
@@ -1557,7 +1486,7 @@ Note: for Set-like containers, `values()` is the same as `keys()`.
|
|
|
1557
1486
|
static createDefaultComparator<K>(): Comparator<K>;
|
|
1558
1487
|
```
|
|
1559
1488
|
|
|
1560
|
-
Defined in: [data-structures/binary-tree/tree-set.ts:
|
|
1489
|
+
Defined in: [data-structures/binary-tree/tree-set.ts:84](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/tree-set.ts#L84)
|
|
1561
1490
|
|
|
1562
1491
|
Create the strict default comparator.
|
|
1563
1492
|
|