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: SinglyLinkedListNode\<E\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
9
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:16](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L16)
|
|
10
10
|
|
|
11
11
|
Node of a singly linked list; stores value and the next link.
|
|
12
12
|
|
|
@@ -32,7 +32,7 @@ Time O(1), Space O(1)
|
|
|
32
32
|
new SinglyLinkedListNode<E>(value): SinglyLinkedListNode<E>;
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
35
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:23](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L23)
|
|
36
36
|
|
|
37
37
|
Create a list node.
|
|
38
38
|
|
|
@@ -68,7 +68,7 @@ Time O(1), Space O(1)
|
|
|
68
68
|
get next(): SinglyLinkedListNode<E> | undefined;
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
71
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:36](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L36)
|
|
72
72
|
|
|
73
73
|
Get the next node.
|
|
74
74
|
|
|
@@ -88,7 +88,7 @@ Next node or undefined.
|
|
|
88
88
|
set next(value): void;
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
91
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:46](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L46)
|
|
92
92
|
|
|
93
93
|
Set the next node.
|
|
94
94
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: SkipList\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
9
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:46](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L46)
|
|
10
10
|
|
|
11
11
|
SkipList — a probabilistic sorted key-value container.
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ Reference: Java ConcurrentSkipListMap (NavigableMap interface).
|
|
|
49
49
|
get size(): number;
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
52
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:79](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L79)
|
|
53
53
|
|
|
54
54
|
Total number of entries.
|
|
55
55
|
|
|
@@ -107,12 +107,10 @@ Time O(n) to iterate, Space O(1)
|
|
|
107
107
|
ceiling(key): [K, V | undefined] | undefined;
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
110
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:385](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L385)
|
|
111
111
|
|
|
112
112
|
Least entry ≥ key, or `undefined`.
|
|
113
113
|
|
|
114
|
-
*
|
|
115
|
-
|
|
116
114
|
#### Parameters
|
|
117
115
|
|
|
118
116
|
##### key
|
|
@@ -127,7 +125,11 @@ Least entry ≥ key, or `undefined`.
|
|
|
127
125
|
|
|
128
126
|
```ts
|
|
129
127
|
// Least entry ≥ key
|
|
130
|
-
const sl = new SkipList<number, string>([
|
|
128
|
+
const sl = new SkipList<number, string>([
|
|
129
|
+
[10, 'a'],
|
|
130
|
+
[20, 'b'],
|
|
131
|
+
[30, 'c']
|
|
132
|
+
]);
|
|
131
133
|
console.log(sl.ceiling(15)); // [20, 'b'];
|
|
132
134
|
console.log(sl.ceiling(20)); // [20, 'b'];
|
|
133
135
|
```
|
|
@@ -140,12 +142,10 @@ Least entry ≥ key, or `undefined`.
|
|
|
140
142
|
clear(): void;
|
|
141
143
|
```
|
|
142
144
|
|
|
143
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
145
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:146](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L146)
|
|
144
146
|
|
|
145
147
|
Remove all entries
|
|
146
148
|
|
|
147
|
-
*
|
|
148
|
-
|
|
149
149
|
#### Returns
|
|
150
150
|
|
|
151
151
|
`void`
|
|
@@ -154,7 +154,10 @@ Remove all entries
|
|
|
154
154
|
|
|
155
155
|
```ts
|
|
156
156
|
// Remove all entries
|
|
157
|
-
const sl = new SkipList<number, string>([
|
|
157
|
+
const sl = new SkipList<number, string>([
|
|
158
|
+
[1, 'a'],
|
|
159
|
+
[2, 'b']
|
|
160
|
+
]);
|
|
158
161
|
sl.clear();
|
|
159
162
|
console.log(sl.isEmpty()); // true;
|
|
160
163
|
```
|
|
@@ -171,12 +174,10 @@ Remove all entries
|
|
|
171
174
|
clone(): this;
|
|
172
175
|
```
|
|
173
176
|
|
|
174
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
177
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:164](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L164)
|
|
175
178
|
|
|
176
179
|
Create independent copy
|
|
177
180
|
|
|
178
|
-
*
|
|
179
|
-
|
|
180
181
|
#### Returns
|
|
181
182
|
|
|
182
183
|
`this`
|
|
@@ -185,7 +186,10 @@ Create independent copy
|
|
|
185
186
|
|
|
186
187
|
```ts
|
|
187
188
|
// Create independent copy
|
|
188
|
-
const sl = new SkipList<number, string>([
|
|
189
|
+
const sl = new SkipList<number, string>([
|
|
190
|
+
[1, 'a'],
|
|
191
|
+
[2, 'b']
|
|
192
|
+
]);
|
|
189
193
|
const copy = sl.clone();
|
|
190
194
|
copy.delete(1);
|
|
191
195
|
console.log(sl.has(1)); // true;
|
|
@@ -203,12 +207,10 @@ Create independent copy
|
|
|
203
207
|
delete(key): boolean;
|
|
204
208
|
```
|
|
205
209
|
|
|
206
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
210
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:280](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L280)
|
|
207
211
|
|
|
208
212
|
Delete a key. Returns `true` if the key was found and removed.
|
|
209
213
|
|
|
210
|
-
*
|
|
211
|
-
|
|
212
214
|
#### Parameters
|
|
213
215
|
|
|
214
216
|
##### key
|
|
@@ -309,12 +311,10 @@ Time O(n), Space O(1)
|
|
|
309
311
|
filter(callbackfn, thisArg?): this;
|
|
310
312
|
```
|
|
311
313
|
|
|
312
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
314
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:556](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L556)
|
|
313
315
|
|
|
314
316
|
Creates a new SkipList with entries that pass the predicate.
|
|
315
317
|
|
|
316
|
-
*
|
|
317
|
-
|
|
318
318
|
#### Parameters
|
|
319
319
|
|
|
320
320
|
##### callbackfn
|
|
@@ -333,7 +333,11 @@ Creates a new SkipList with entries that pass the predicate.
|
|
|
333
333
|
|
|
334
334
|
```ts
|
|
335
335
|
// Filter entries
|
|
336
|
-
const sl = new SkipList<number, string>([
|
|
336
|
+
const sl = new SkipList<number, string>([
|
|
337
|
+
[1, 'a'],
|
|
338
|
+
[2, 'b'],
|
|
339
|
+
[3, 'c']
|
|
340
|
+
]);
|
|
337
341
|
const result = sl.filter((v, k) => k > 1);
|
|
338
342
|
console.log(result.size); // 2;
|
|
339
343
|
```
|
|
@@ -390,12 +394,10 @@ Time O(n), Space O(1)
|
|
|
390
394
|
first(): [K, V | undefined] | undefined;
|
|
391
395
|
```
|
|
392
396
|
|
|
393
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
397
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L309)
|
|
394
398
|
|
|
395
399
|
Returns the first (smallest key) entry, or `undefined` if empty.
|
|
396
400
|
|
|
397
|
-
*
|
|
398
|
-
|
|
399
401
|
#### Returns
|
|
400
402
|
|
|
401
403
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -404,7 +406,11 @@ Returns the first (smallest key) entry, or `undefined` if empty.
|
|
|
404
406
|
|
|
405
407
|
```ts
|
|
406
408
|
// Access the minimum entry
|
|
407
|
-
const sl = new SkipList<number, string>([
|
|
409
|
+
const sl = new SkipList<number, string>([
|
|
410
|
+
[5, 'e'],
|
|
411
|
+
[1, 'a'],
|
|
412
|
+
[3, 'c']
|
|
413
|
+
]);
|
|
408
414
|
console.log(sl.first()); // [1, 'a'];
|
|
409
415
|
```
|
|
410
416
|
|
|
@@ -416,12 +422,10 @@ Returns the first (smallest key) entry, or `undefined` if empty.
|
|
|
416
422
|
floor(key): [K, V | undefined] | undefined;
|
|
417
423
|
```
|
|
418
424
|
|
|
419
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
425
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L409)
|
|
420
426
|
|
|
421
427
|
Greatest entry ≤ key, or `undefined`.
|
|
422
428
|
|
|
423
|
-
*
|
|
424
|
-
|
|
425
429
|
#### Parameters
|
|
426
430
|
|
|
427
431
|
##### key
|
|
@@ -436,7 +440,11 @@ Greatest entry ≤ key, or `undefined`.
|
|
|
436
440
|
|
|
437
441
|
```ts
|
|
438
442
|
// Greatest entry ≤ key
|
|
439
|
-
const sl = new SkipList<number, string>([
|
|
443
|
+
const sl = new SkipList<number, string>([
|
|
444
|
+
[10, 'a'],
|
|
445
|
+
[20, 'b'],
|
|
446
|
+
[30, 'c']
|
|
447
|
+
]);
|
|
440
448
|
console.log(sl.floor(25)); // [20, 'b'];
|
|
441
449
|
console.log(sl.floor(5)); // undefined;
|
|
442
450
|
```
|
|
@@ -487,13 +495,11 @@ Time O(n), Space O(1)
|
|
|
487
495
|
get(key): V | undefined;
|
|
488
496
|
```
|
|
489
497
|
|
|
490
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
498
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:243](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L243)
|
|
491
499
|
|
|
492
500
|
Get the value for a key, or `undefined` if not found.
|
|
493
501
|
Overrides base O(n) with O(log n) skip-list search.
|
|
494
502
|
|
|
495
|
-
*
|
|
496
|
-
|
|
497
503
|
#### Parameters
|
|
498
504
|
|
|
499
505
|
##### key
|
|
@@ -540,13 +546,11 @@ Overrides base O(n) with O(log n) skip-list search.
|
|
|
540
546
|
has(key): boolean;
|
|
541
547
|
```
|
|
542
548
|
|
|
543
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
549
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:261](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L261)
|
|
544
550
|
|
|
545
551
|
Check if a key exists.
|
|
546
552
|
Overrides base O(n) with O(log n) skip-list search.
|
|
547
553
|
|
|
548
|
-
*
|
|
549
|
-
|
|
550
554
|
#### Parameters
|
|
551
555
|
|
|
552
556
|
##### key
|
|
@@ -561,7 +565,11 @@ Overrides base O(n) with O(log n) skip-list search.
|
|
|
561
565
|
|
|
562
566
|
```ts
|
|
563
567
|
// Check key existence
|
|
564
|
-
const sl = new SkipList<number, string>([
|
|
568
|
+
const sl = new SkipList<number, string>([
|
|
569
|
+
[1, 'a'],
|
|
570
|
+
[3, 'c'],
|
|
571
|
+
[5, 'e']
|
|
572
|
+
]);
|
|
565
573
|
console.log(sl.has(3)); // true;
|
|
566
574
|
console.log(sl.has(4)); // false;
|
|
567
575
|
```
|
|
@@ -612,12 +620,10 @@ Time O(n), Space O(1)
|
|
|
612
620
|
higher(key): [K, V | undefined] | undefined;
|
|
613
621
|
```
|
|
614
622
|
|
|
615
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
623
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:435](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L435)
|
|
616
624
|
|
|
617
625
|
Least entry strictly > key, or `undefined`.
|
|
618
626
|
|
|
619
|
-
*
|
|
620
|
-
|
|
621
627
|
#### Parameters
|
|
622
628
|
|
|
623
629
|
##### key
|
|
@@ -632,7 +638,11 @@ Least entry strictly > key, or `undefined`.
|
|
|
632
638
|
|
|
633
639
|
```ts
|
|
634
640
|
// Strictly greater entry
|
|
635
|
-
const sl = new SkipList<number, string>([
|
|
641
|
+
const sl = new SkipList<number, string>([
|
|
642
|
+
[10, 'a'],
|
|
643
|
+
[20, 'b'],
|
|
644
|
+
[30, 'c']
|
|
645
|
+
]);
|
|
636
646
|
console.log(sl.higher(15)); // [20, 'b'];
|
|
637
647
|
console.log(sl.higher(30)); // undefined;
|
|
638
648
|
```
|
|
@@ -645,12 +655,10 @@ Least entry strictly > key, or `undefined`.
|
|
|
645
655
|
isEmpty(): boolean;
|
|
646
656
|
```
|
|
647
657
|
|
|
648
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
658
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:131](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L131)
|
|
649
659
|
|
|
650
660
|
Check if empty
|
|
651
661
|
|
|
652
|
-
*
|
|
653
|
-
|
|
654
662
|
#### Returns
|
|
655
663
|
|
|
656
664
|
`boolean`
|
|
@@ -701,12 +709,10 @@ Time O(n), Space O(1)
|
|
|
701
709
|
last(): [K, V | undefined] | undefined;
|
|
702
710
|
```
|
|
703
711
|
|
|
704
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
712
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:325](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L325)
|
|
705
713
|
|
|
706
714
|
Returns the last (largest key) entry, or `undefined` if empty.
|
|
707
715
|
|
|
708
|
-
*
|
|
709
|
-
|
|
710
716
|
#### Returns
|
|
711
717
|
|
|
712
718
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -715,7 +721,11 @@ Returns the last (largest key) entry, or `undefined` if empty.
|
|
|
715
721
|
|
|
716
722
|
```ts
|
|
717
723
|
// Access the maximum entry
|
|
718
|
-
const sl = new SkipList<number, string>([
|
|
724
|
+
const sl = new SkipList<number, string>([
|
|
725
|
+
[5, 'e'],
|
|
726
|
+
[1, 'a'],
|
|
727
|
+
[3, 'c']
|
|
728
|
+
]);
|
|
719
729
|
console.log(sl.last()); // [5, 'e'];
|
|
720
730
|
```
|
|
721
731
|
|
|
@@ -727,12 +737,10 @@ Returns the last (largest key) entry, or `undefined` if empty.
|
|
|
727
737
|
lower(key): [K, V | undefined] | undefined;
|
|
728
738
|
```
|
|
729
739
|
|
|
730
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
740
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:459](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L459)
|
|
731
741
|
|
|
732
742
|
Greatest entry strictly < key, or `undefined`.
|
|
733
743
|
|
|
734
|
-
*
|
|
735
|
-
|
|
736
744
|
#### Parameters
|
|
737
745
|
|
|
738
746
|
##### key
|
|
@@ -747,7 +755,11 @@ Greatest entry strictly < key, or `undefined`.
|
|
|
747
755
|
|
|
748
756
|
```ts
|
|
749
757
|
// Strictly less entry
|
|
750
|
-
const sl = new SkipList<number, string>([
|
|
758
|
+
const sl = new SkipList<number, string>([
|
|
759
|
+
[10, 'a'],
|
|
760
|
+
[20, 'b'],
|
|
761
|
+
[30, 'c']
|
|
762
|
+
]);
|
|
751
763
|
console.log(sl.lower(25)); // [20, 'b'];
|
|
752
764
|
console.log(sl.lower(10)); // undefined;
|
|
753
765
|
```
|
|
@@ -760,12 +772,10 @@ Greatest entry strictly < key, or `undefined`.
|
|
|
760
772
|
map<MK, MV>(callback, options?): SkipList<MK, MV>;
|
|
761
773
|
```
|
|
762
774
|
|
|
763
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
775
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L531)
|
|
764
776
|
|
|
765
777
|
Creates a new SkipList with entries transformed by callback.
|
|
766
778
|
|
|
767
|
-
*
|
|
768
|
-
|
|
769
779
|
#### Type Parameters
|
|
770
780
|
|
|
771
781
|
##### MK
|
|
@@ -794,7 +804,10 @@ Creates a new SkipList with entries transformed by callback.
|
|
|
794
804
|
|
|
795
805
|
```ts
|
|
796
806
|
// Transform entries
|
|
797
|
-
const sl = new SkipList<number, string>([
|
|
807
|
+
const sl = new SkipList<number, string>([
|
|
808
|
+
[1, 'a'],
|
|
809
|
+
[2, 'b']
|
|
810
|
+
]);
|
|
798
811
|
const mapped = sl.map((v, k) => [k, v?.toUpperCase()] as [number, string]);
|
|
799
812
|
console.log([...mapped.values()]); // ['A', 'B'];
|
|
800
813
|
```
|
|
@@ -811,12 +824,10 @@ Creates a new SkipList with entries transformed by callback.
|
|
|
811
824
|
pollFirst(): [K, V | undefined] | undefined;
|
|
812
825
|
```
|
|
813
826
|
|
|
814
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
827
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:347](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L347)
|
|
815
828
|
|
|
816
829
|
Remove and return the first (smallest key) entry.
|
|
817
830
|
|
|
818
|
-
*
|
|
819
|
-
|
|
820
831
|
#### Returns
|
|
821
832
|
|
|
822
833
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -825,7 +836,11 @@ Remove and return the first (smallest key) entry.
|
|
|
825
836
|
|
|
826
837
|
```ts
|
|
827
838
|
// Remove and return smallest
|
|
828
|
-
const sl = new SkipList<number, string>([
|
|
839
|
+
const sl = new SkipList<number, string>([
|
|
840
|
+
[1, 'a'],
|
|
841
|
+
[2, 'b'],
|
|
842
|
+
[3, 'c']
|
|
843
|
+
]);
|
|
829
844
|
console.log(sl.pollFirst()); // [1, 'a'];
|
|
830
845
|
console.log(sl.size); // 2;
|
|
831
846
|
```
|
|
@@ -838,12 +853,10 @@ Remove and return the first (smallest key) entry.
|
|
|
838
853
|
pollLast(): [K, V | undefined] | undefined;
|
|
839
854
|
```
|
|
840
855
|
|
|
841
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
856
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:366](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L366)
|
|
842
857
|
|
|
843
858
|
Remove and return the last (largest key) entry.
|
|
844
859
|
|
|
845
|
-
*
|
|
846
|
-
|
|
847
860
|
#### Returns
|
|
848
861
|
|
|
849
862
|
\[`K`, `V` \| `undefined`\] \| `undefined`
|
|
@@ -852,7 +865,11 @@ Remove and return the last (largest key) entry.
|
|
|
852
865
|
|
|
853
866
|
```ts
|
|
854
867
|
// Remove and return largest
|
|
855
|
-
const sl = new SkipList<number, string>([
|
|
868
|
+
const sl = new SkipList<number, string>([
|
|
869
|
+
[1, 'a'],
|
|
870
|
+
[2, 'b'],
|
|
871
|
+
[3, 'c']
|
|
872
|
+
]);
|
|
856
873
|
console.log(sl.pollLast()); // [3, 'c'];
|
|
857
874
|
console.log(sl.size); // 2;
|
|
858
875
|
```
|
|
@@ -889,12 +906,10 @@ Time O(n), Space O(n)
|
|
|
889
906
|
rangeSearch(range, options?): [K, V | undefined][];
|
|
890
907
|
```
|
|
891
908
|
|
|
892
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
909
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:492](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L492)
|
|
893
910
|
|
|
894
911
|
Returns entries within the given key range.
|
|
895
912
|
|
|
896
|
-
*
|
|
897
|
-
|
|
898
913
|
#### Parameters
|
|
899
914
|
|
|
900
915
|
##### range
|
|
@@ -913,9 +928,19 @@ Returns entries within the given key range.
|
|
|
913
928
|
|
|
914
929
|
```ts
|
|
915
930
|
// Find entries in a range
|
|
916
|
-
const sl = new SkipList<number, string>([
|
|
931
|
+
const sl = new SkipList<number, string>([
|
|
932
|
+
[1, 'a'],
|
|
933
|
+
[2, 'b'],
|
|
934
|
+
[3, 'c'],
|
|
935
|
+
[4, 'd'],
|
|
936
|
+
[5, 'e']
|
|
937
|
+
]);
|
|
917
938
|
const result = sl.rangeSearch([2, 4]);
|
|
918
|
-
console.log(result); // [
|
|
939
|
+
console.log(result); // [
|
|
940
|
+
// [2, 'b'],
|
|
941
|
+
// [3, 'c'],
|
|
942
|
+
// [4, 'd']
|
|
943
|
+
// ];
|
|
919
944
|
```
|
|
920
945
|
|
|
921
946
|
***
|
|
@@ -972,13 +997,11 @@ Time O(n), Space O(1)
|
|
|
972
997
|
set(key, value): this;
|
|
973
998
|
```
|
|
974
999
|
|
|
975
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1000
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L194)
|
|
976
1001
|
|
|
977
1002
|
Insert or update a key-value pair. Returns `this` for chaining.
|
|
978
1003
|
Unique keys only — if key exists, value is updated in place.
|
|
979
1004
|
|
|
980
|
-
*
|
|
981
|
-
|
|
982
1005
|
#### Parameters
|
|
983
1006
|
|
|
984
1007
|
##### key
|
|
@@ -1139,7 +1162,7 @@ Time O(n), Space O(1)
|
|
|
1139
1162
|
static createDefaultComparator<K>(): Comparator<K>;
|
|
1140
1163
|
```
|
|
1141
1164
|
|
|
1142
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1165
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:102](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L102)
|
|
1143
1166
|
|
|
1144
1167
|
Creates a default comparator supporting number, string, Date, and bigint.
|
|
1145
1168
|
|
|
@@ -1164,7 +1187,7 @@ Creates a default comparator supporting number, string, Date, and bigint.
|
|
|
1164
1187
|
protected _findNode(key): SkipListNode<K, V> | undefined;
|
|
1165
1188
|
```
|
|
1166
1189
|
|
|
1167
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1190
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:603](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L603)
|
|
1168
1191
|
|
|
1169
1192
|
Finds the node for a given key, or undefined.
|
|
1170
1193
|
|
|
@@ -1186,7 +1209,7 @@ Finds the node for a given key, or undefined.
|
|
|
1186
1209
|
protected _findUpdate(key): SkipListNode<K, V>[];
|
|
1187
1210
|
```
|
|
1188
1211
|
|
|
1189
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1212
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:587](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L587)
|
|
1190
1213
|
|
|
1191
1214
|
Finds the update array (predecessors at each level) for a given key.
|
|
1192
1215
|
|
|
@@ -1208,7 +1231,7 @@ Finds the update array (predecessors at each level) for a given key.
|
|
|
1208
1231
|
protected _getIterator(): IterableIterator<[K, V | undefined]>;
|
|
1209
1232
|
```
|
|
1210
1233
|
|
|
1211
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1234
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:571](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L571)
|
|
1212
1235
|
|
|
1213
1236
|
Underlying iterator for the default iteration protocol.
|
|
1214
1237
|
|