min-heap-typed 1.51.9 → 1.52.1
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/dist/data-structures/base/index.d.ts +2 -1
- package/dist/data-structures/base/index.js +2 -1
- package/dist/data-structures/base/iterable-element-base.d.ts +171 -0
- package/dist/data-structures/base/iterable-element-base.js +225 -0
- package/dist/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
- package/dist/data-structures/base/{iterable-base.js → iterable-entry-base.js} +12 -189
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +13 -13
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/data-structures/binary-tree/avl-tree.d.ts +13 -13
- package/dist/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/data-structures/binary-tree/binary-tree.d.ts +99 -99
- package/dist/data-structures/binary-tree/binary-tree.js +54 -52
- package/dist/data-structures/binary-tree/bst.d.ts +37 -45
- package/dist/data-structures/binary-tree/bst.js +17 -25
- package/dist/data-structures/binary-tree/rb-tree.d.ts +10 -10
- package/dist/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
- package/dist/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/data-structures/graph/directed-graph.js +2 -1
- package/dist/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/data-structures/heap/heap.d.ts +43 -114
- package/dist/data-structures/heap/heap.js +59 -127
- package/dist/data-structures/heap/max-heap.d.ts +50 -4
- package/dist/data-structures/heap/max-heap.js +76 -10
- package/dist/data-structures/heap/min-heap.d.ts +51 -5
- package/dist/data-structures/heap/min-heap.js +68 -11
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
- package/dist/data-structures/linked-list/doubly-linked-list.js +26 -28
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +22 -25
- package/dist/data-structures/linked-list/singly-linked-list.js +29 -26
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
- package/dist/data-structures/priority-queue/max-priority-queue.js +79 -10
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
- package/dist/data-structures/priority-queue/min-priority-queue.js +71 -11
- package/dist/data-structures/priority-queue/priority-queue.d.ts +50 -4
- package/dist/data-structures/priority-queue/priority-queue.js +70 -1
- package/dist/data-structures/queue/deque.d.ts +27 -18
- package/dist/data-structures/queue/deque.js +43 -21
- package/dist/data-structures/queue/queue.d.ts +8 -29
- package/dist/data-structures/queue/queue.js +15 -32
- package/dist/data-structures/stack/stack.d.ts +17 -22
- package/dist/data-structures/stack/stack.js +25 -24
- package/dist/data-structures/trie/trie.d.ts +18 -13
- package/dist/data-structures/trie/trie.js +26 -15
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/interfaces/binary-tree.d.ts +4 -4
- package/dist/types/common.d.ts +1 -22
- package/dist/types/data-structures/base/base.d.ts +5 -2
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +20 -4
- package/dist/types/data-structures/binary-tree/bst.d.ts +5 -3
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +2 -3
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -3
- package/dist/types/data-structures/heap/heap.d.ts +3 -2
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +4 -2
- package/dist/types/data-structures/queue/queue.d.ts +2 -1
- package/dist/types/data-structures/stack/stack.d.ts +2 -1
- package/dist/types/data-structures/trie/trie.d.ts +3 -2
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +2 -1
- package/src/data-structures/base/iterable-element-base.ts +250 -0
- package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +14 -15
- package/src/data-structures/binary-tree/avl-tree.ts +13 -14
- package/src/data-structures/binary-tree/binary-tree.ts +156 -152
- package/src/data-structures/binary-tree/bst.ts +52 -60
- package/src/data-structures/binary-tree/rb-tree.ts +12 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +12 -13
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/hash/hash-map.ts +4 -4
- package/src/data-structures/heap/heap.ts +71 -152
- package/src/data-structures/heap/max-heap.ts +88 -13
- package/src/data-structures/heap/min-heap.ts +78 -15
- package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
- package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
- package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
- package/src/data-structures/priority-queue/priority-queue.ts +81 -4
- package/src/data-structures/queue/deque.ts +50 -25
- package/src/data-structures/queue/queue.ts +23 -37
- package/src/data-structures/stack/stack.ts +31 -26
- package/src/data-structures/trie/trie.ts +33 -18
- package/src/index.ts +2 -1
- package/src/interfaces/binary-tree.ts +4 -5
- package/src/types/common.ts +2 -24
- package/src/types/data-structures/base/base.ts +14 -6
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -3
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +24 -5
- package/src/types/data-structures/binary-tree/bst.ts +9 -3
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -3
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -3
- package/src/types/data-structures/heap/heap.ts +4 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
- package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/types/data-structures/queue/deque.ts +6 -1
- package/src/types/data-structures/queue/queue.ts +3 -1
- package/src/types/data-structures/stack/stack.ts +3 -1
- package/src/types/data-structures/trie/trie.ts +3 -1
|
@@ -16,9 +16,9 @@ import { calcMinUnitsRequired, rangeCheck } from '../../utils';
|
|
|
16
16
|
* 4. Efficiency: Adding and removing elements at both ends of a deque is usually very fast. However, when the dynamic array needs to expand, it may involve copying the entire array to a larger one, and this operation has a time complexity of O(n).
|
|
17
17
|
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
|
|
18
18
|
*/
|
|
19
|
-
export class Deque<E> extends IterableElementBase<E
|
|
19
|
+
export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E, R>> {
|
|
20
20
|
/**
|
|
21
|
-
* The constructor initializes a Deque object with
|
|
21
|
+
* The constructor initializes a Deque object with optional iterable of elements and options.
|
|
22
22
|
* @param elements - An iterable object (such as an array or a Set) that contains the initial
|
|
23
23
|
* elements to be added to the deque. It can also be an object with a `length` or `size` property
|
|
24
24
|
* that represents the number of elements in the iterable object. If no elements are provided, an
|
|
@@ -28,12 +28,13 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
28
28
|
* which determines the size of each bucket in the deque. If the `bucketSize` option is not provided
|
|
29
29
|
* or is not a number
|
|
30
30
|
*/
|
|
31
|
-
constructor(elements: IterableWithSizeOrLength<E> = [], options?: DequeOptions) {
|
|
32
|
-
super();
|
|
31
|
+
constructor(elements: IterableWithSizeOrLength<E> | IterableWithSizeOrLength<R> = [], options?: DequeOptions<E, R>) {
|
|
32
|
+
super(options);
|
|
33
33
|
|
|
34
34
|
if (options) {
|
|
35
|
-
const { bucketSize } = options;
|
|
35
|
+
const { bucketSize, maxLen } = options;
|
|
36
36
|
if (typeof bucketSize === 'number') this._bucketSize = bucketSize;
|
|
37
|
+
if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
let _size: number;
|
|
@@ -53,8 +54,12 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
53
54
|
this._bucketFirst = this._bucketLast = (this._bucketCount >> 1) - (needBucketNum >> 1);
|
|
54
55
|
this._firstInBucket = this._lastInBucket = (this._bucketSize - (_size % this._bucketSize)) >> 1;
|
|
55
56
|
|
|
56
|
-
for (const
|
|
57
|
-
this.
|
|
57
|
+
for (const el of elements) {
|
|
58
|
+
if (this.toElementFn) {
|
|
59
|
+
this.push(this.toElementFn(el as R));
|
|
60
|
+
} else {
|
|
61
|
+
this.push(el as E);
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
|
@@ -69,6 +74,17 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
69
74
|
return this._bucketSize;
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
protected _maxLen: number = -1;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The maxLen function returns the max length of the deque.
|
|
81
|
+
*
|
|
82
|
+
* @return The max length of the deque
|
|
83
|
+
*/
|
|
84
|
+
get maxLen() {
|
|
85
|
+
return this._maxLen;
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
protected _bucketFirst = 0;
|
|
73
89
|
|
|
74
90
|
/**
|
|
@@ -189,6 +205,7 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
189
205
|
}
|
|
190
206
|
this._size += 1;
|
|
191
207
|
this._buckets[this._bucketLast][this._lastInBucket] = element;
|
|
208
|
+
if (this._maxLen > 0 && this._size > this._maxLen) this.shift();
|
|
192
209
|
return true;
|
|
193
210
|
}
|
|
194
211
|
|
|
@@ -253,6 +270,7 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
253
270
|
}
|
|
254
271
|
this._size += 1;
|
|
255
272
|
this._buckets[this._bucketFirst][this._firstInBucket] = element;
|
|
273
|
+
if (this._maxLen > 0 && this._size > this._maxLen) this.pop();
|
|
256
274
|
return true;
|
|
257
275
|
}
|
|
258
276
|
|
|
@@ -747,8 +765,8 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
747
765
|
* @returns The `clone()` method is returning a new instance of the `Deque` class with the same
|
|
748
766
|
* elements as the original deque (`this`) and the same bucket size.
|
|
749
767
|
*/
|
|
750
|
-
clone(): Deque<E> {
|
|
751
|
-
return new Deque<E>(
|
|
768
|
+
clone(): Deque<E, R> {
|
|
769
|
+
return new Deque<E, R>(this, { bucketSize: this.bucketSize, toElementFn: this.toElementFn });
|
|
752
770
|
}
|
|
753
771
|
|
|
754
772
|
/**
|
|
@@ -772,8 +790,8 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
772
790
|
* @returns The `filter` method is returning a new `Deque` object that contains the elements that
|
|
773
791
|
* satisfy the given predicate function.
|
|
774
792
|
*/
|
|
775
|
-
filter(predicate: ElementCallback<E, boolean
|
|
776
|
-
const newDeque = new Deque<E>([], { bucketSize: this._bucketSize });
|
|
793
|
+
filter(predicate: ElementCallback<E, R, boolean, Deque<E, R>>, thisArg?: any): Deque<E, R> {
|
|
794
|
+
const newDeque = new Deque<E, R>([], { bucketSize: this._bucketSize, toElementFn: this.toElementFn });
|
|
777
795
|
let index = 0;
|
|
778
796
|
for (const el of this) {
|
|
779
797
|
if (predicate.call(thisArg, el, index, this)) {
|
|
@@ -788,21 +806,28 @@ export class Deque<E> extends IterableElementBase<E> {
|
|
|
788
806
|
* Time Complexity: O(n)
|
|
789
807
|
* Space Complexity: O(n)
|
|
790
808
|
*/
|
|
809
|
+
|
|
791
810
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
* @param
|
|
798
|
-
* the
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
811
|
+
* The `map` function takes a callback function and applies it to each element in the deque,
|
|
812
|
+
* returning a new deque with the results.
|
|
813
|
+
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
814
|
+
* deque. It takes three arguments: the current element, the index of the element, and the deque
|
|
815
|
+
* itself. It should return a value of type EM.
|
|
816
|
+
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
|
|
817
|
+
* transform the raw element (`RM`) into a new element (`EM`) before adding it to the new deque. If
|
|
818
|
+
* provided, this function will be called for each raw element in the original deque.
|
|
819
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
820
|
+
* specify the value of `this` within the callback function. It is used to set the context or scope
|
|
821
|
+
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
|
|
822
|
+
* value of
|
|
823
|
+
* @returns a new Deque object with elements of type EM and raw elements of type RM.
|
|
824
|
+
*/
|
|
825
|
+
map<EM, RM>(
|
|
826
|
+
callback: ElementCallback<E, R, EM, Deque<E, R>>,
|
|
827
|
+
toElementFn?: (rawElement: RM) => EM,
|
|
828
|
+
thisArg?: any
|
|
829
|
+
): Deque<EM, RM> {
|
|
830
|
+
const newDeque = new Deque<EM, RM>([], { bucketSize: this._bucketSize, toElementFn });
|
|
806
831
|
let index = 0;
|
|
807
832
|
for (const el of this) {
|
|
808
833
|
newDeque.push(callback.call(thisArg, el, index, this));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @copyright Tyler Zeng <zrwusa@gmail.com>
|
|
4
4
|
* @class
|
|
5
5
|
*/
|
|
6
|
-
import type { ElementCallback } from '../../types';
|
|
6
|
+
import type { ElementCallback, QueueOptions } from '../../types';
|
|
7
7
|
import { IterableElementBase } from '../base';
|
|
8
8
|
import { SinglyLinkedList } from '../linked-list';
|
|
9
9
|
|
|
@@ -16,17 +16,14 @@ import { SinglyLinkedList } from '../linked-list';
|
|
|
16
16
|
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
|
|
17
17
|
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
|
|
18
18
|
*/
|
|
19
|
-
export class Queue<E = any> extends IterableElementBase<E
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
|
|
23
|
-
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
|
|
24
|
-
* initialized as an empty array.
|
|
25
|
-
*/
|
|
26
|
-
constructor(elements: Iterable<E> = []) {
|
|
27
|
-
super();
|
|
19
|
+
export class Queue<E = any, R = any> extends IterableElementBase<E, R, Queue<E, R>> {
|
|
20
|
+
constructor(elements: Iterable<E> | Iterable<R> = [], options?: QueueOptions<E, R>) {
|
|
21
|
+
super(options);
|
|
28
22
|
if (elements) {
|
|
29
|
-
for (const el of elements)
|
|
23
|
+
for (const el of elements) {
|
|
24
|
+
if (this.toElementFn) this.push(this.toElementFn(el as R));
|
|
25
|
+
else this.push(el as E);
|
|
26
|
+
}
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
|
|
@@ -103,7 +100,6 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
103
100
|
*
|
|
104
101
|
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
|
|
105
102
|
* @public
|
|
106
|
-
* @static
|
|
107
103
|
* @param {E[]} elements - The "elements" parameter is an array of elements of type E.
|
|
108
104
|
* @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
|
|
109
105
|
* array.
|
|
@@ -190,7 +186,7 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
190
186
|
* @param index
|
|
191
187
|
*/
|
|
192
188
|
at(index: number): E | undefined {
|
|
193
|
-
return this.elements[index];
|
|
189
|
+
return this.elements[index + this._offset];
|
|
194
190
|
}
|
|
195
191
|
|
|
196
192
|
/**
|
|
@@ -254,8 +250,8 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
254
250
|
* The `clone()` function returns a new Queue object with the same elements as the original Queue.
|
|
255
251
|
* @returns The `clone()` method is returning a new instance of the `Queue` class.
|
|
256
252
|
*/
|
|
257
|
-
clone(): Queue<E> {
|
|
258
|
-
return new Queue(this.elements.slice(this.offset));
|
|
253
|
+
clone(): Queue<E, R> {
|
|
254
|
+
return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
|
|
259
255
|
}
|
|
260
256
|
|
|
261
257
|
/**
|
|
@@ -279,8 +275,8 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
279
275
|
* @returns The `filter` method is returning a new `Queue` object that contains the elements that
|
|
280
276
|
* satisfy the given predicate function.
|
|
281
277
|
*/
|
|
282
|
-
filter(predicate: ElementCallback<E, boolean
|
|
283
|
-
const newDeque = new Queue<E>([]);
|
|
278
|
+
filter(predicate: ElementCallback<E, R, boolean, Queue<E, R>>, thisArg?: any): Queue<E, R> {
|
|
279
|
+
const newDeque = new Queue<E, R>([], { toElementFn: this.toElementFn });
|
|
284
280
|
let index = 0;
|
|
285
281
|
for (const el of this) {
|
|
286
282
|
if (predicate.call(thisArg, el, index, this)) {
|
|
@@ -296,22 +292,12 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
296
292
|
* Space Complexity: O(n)
|
|
297
293
|
*/
|
|
298
294
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
306
|
-
* queue. It takes three arguments: the current element, the index of the current element, and the
|
|
307
|
-
* queue itself. The callback function should return a new value that will be added to the new queue.
|
|
308
|
-
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
309
|
-
* to be used as `this` when executing the `callback` function. If `thisArg` is provided, it will be
|
|
310
|
-
* passed as the `this` value to the `callback` function. If `thisArg` is
|
|
311
|
-
* @returns The `map` function is returning a new `Queue` object with the transformed elements.
|
|
312
|
-
*/
|
|
313
|
-
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Queue<T> {
|
|
314
|
-
const newDeque = new Queue<T>([]);
|
|
295
|
+
map<EM, RM>(
|
|
296
|
+
callback: ElementCallback<E, R, EM, Queue<E, R>>,
|
|
297
|
+
toElementFn?: (rawElement: RM) => EM,
|
|
298
|
+
thisArg?: any
|
|
299
|
+
): Queue<EM, RM> {
|
|
300
|
+
const newDeque = new Queue<EM, RM>([], { toElementFn });
|
|
315
301
|
let index = 0;
|
|
316
302
|
for (const el of this) {
|
|
317
303
|
newDeque.push(callback.call(thisArg, el, index, this));
|
|
@@ -332,7 +318,7 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
332
318
|
* The function `_getIterator` returns an iterable iterator for the elements in the class.
|
|
333
319
|
*/
|
|
334
320
|
protected* _getIterator(): IterableIterator<E> {
|
|
335
|
-
for (const item of this.elements) {
|
|
321
|
+
for (const item of this.elements.slice(this.offset)) {
|
|
336
322
|
yield item;
|
|
337
323
|
}
|
|
338
324
|
}
|
|
@@ -344,7 +330,7 @@ export class Queue<E = any> extends IterableElementBase<E> {
|
|
|
344
330
|
* 3. Memory Usage: Since each element requires additional space to store a pointer to the next element, linked lists may use more memory compared to arrays.
|
|
345
331
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
346
332
|
*/
|
|
347
|
-
export class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
|
|
333
|
+
export class LinkedListQueue<E = any, R = any> extends SinglyLinkedList<E, R> {
|
|
348
334
|
/**
|
|
349
335
|
* Time Complexity: O(n)
|
|
350
336
|
* Space Complexity: O(n)
|
|
@@ -358,7 +344,7 @@ export class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
|
|
|
358
344
|
* @returns The `clone()` method is returning a new instance of `LinkedListQueue` with the same
|
|
359
345
|
* values as the original `LinkedListQueue`.
|
|
360
346
|
*/
|
|
361
|
-
override clone(): LinkedListQueue<E> {
|
|
362
|
-
return new LinkedListQueue<E>(this.
|
|
347
|
+
override clone(): LinkedListQueue<E, R> {
|
|
348
|
+
return new LinkedListQueue<E, R>(this, { toElementFn: this.toElementFn });
|
|
363
349
|
}
|
|
364
350
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { ElementCallback } from '../../types';
|
|
8
|
+
import type { ElementCallback, StackOptions } from '../../types';
|
|
9
9
|
import { IterableElementBase } from '../base';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -16,17 +16,17 @@ import { IterableElementBase } from '../base';
|
|
|
16
16
|
* 5. Expression Evaluation: Used for the evaluation of arithmetic or logical expressions, especially when dealing with parenthesis matching and operator precedence.
|
|
17
17
|
* 6. Backtracking Algorithms: In problems where multiple branches need to be explored but only one branch can be explored at a time, stacks can be used to save the state at each branching point.
|
|
18
18
|
*/
|
|
19
|
-
export class Stack<E = any> extends IterableElementBase<E
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param {E[]} [elements] - The `elements` parameter is an optional parameter of type `E[]`, which represents an array
|
|
23
|
-
* of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
|
|
24
|
-
* is provided and is an array, it is assigned to the `_elements
|
|
25
|
-
*/
|
|
26
|
-
constructor(elements: Iterable<E> = []) {
|
|
27
|
-
super();
|
|
19
|
+
export class Stack<E = any, R = any> extends IterableElementBase<E, R, Stack<E, R>> {
|
|
20
|
+
constructor(elements: Iterable<E> | Iterable<R> = [], options?: StackOptions<E, R>) {
|
|
21
|
+
super(options);
|
|
28
22
|
if (elements) {
|
|
29
|
-
for (const el of elements)
|
|
23
|
+
for (const el of elements) {
|
|
24
|
+
if (this.toElementFn) {
|
|
25
|
+
this.push(this.toElementFn(el as R));
|
|
26
|
+
} else {
|
|
27
|
+
this.push(el as E);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -192,8 +192,8 @@ export class Stack<E = any> extends IterableElementBase<E> {
|
|
|
192
192
|
* The `clone()` function returns a new `Stack` object with the same elements as the original stack.
|
|
193
193
|
* @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
|
|
194
194
|
*/
|
|
195
|
-
clone(): Stack<E> {
|
|
196
|
-
return new Stack(this.
|
|
195
|
+
clone(): Stack<E, R> {
|
|
196
|
+
return new Stack<E, R>(this, { toElementFn: this.toElementFn });
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
@@ -217,8 +217,8 @@ export class Stack<E = any> extends IterableElementBase<E> {
|
|
|
217
217
|
* @returns The `filter` method is returning a new `Stack` object that contains the elements that
|
|
218
218
|
* satisfy the given predicate function.
|
|
219
219
|
*/
|
|
220
|
-
filter(predicate: ElementCallback<E, boolean
|
|
221
|
-
const newStack = new Stack<E>();
|
|
220
|
+
filter(predicate: ElementCallback<E, R, boolean, Stack<E, R>>, thisArg?: any): Stack<E, R> {
|
|
221
|
+
const newStack = new Stack<E, R>([], { toElementFn: this.toElementFn });
|
|
222
222
|
let index = 0;
|
|
223
223
|
for (const el of this) {
|
|
224
224
|
if (predicate.call(thisArg, el, index, this)) {
|
|
@@ -235,20 +235,25 @@ export class Stack<E = any> extends IterableElementBase<E> {
|
|
|
235
235
|
*/
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
|
-
* Time Complexity: O(n)
|
|
239
|
-
* Space Complexity: O(n)
|
|
240
|
-
*
|
|
241
238
|
* The `map` function takes a callback function and applies it to each element in the stack,
|
|
242
239
|
* returning a new stack with the results.
|
|
243
|
-
* @param callback - The
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* @
|
|
240
|
+
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
241
|
+
* stack. It takes three arguments: the current element, the index of the element, and the stack
|
|
242
|
+
* itself. It should return a new value that will be added to the new stack.
|
|
243
|
+
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
|
|
244
|
+
* transform the raw element (`RM`) into a new element (`EM`) before pushing it into the new stack.
|
|
245
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
246
|
+
* specify the value of `this` within the callback function. It is used to set the context or scope
|
|
247
|
+
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
|
|
248
|
+
* value of
|
|
249
|
+
* @returns a new Stack object with elements of type EM and raw elements of type RM.
|
|
249
250
|
*/
|
|
250
|
-
map<
|
|
251
|
-
|
|
251
|
+
map<EM, RM>(
|
|
252
|
+
callback: ElementCallback<E, R, EM, Stack<E, R>>,
|
|
253
|
+
toElementFn?: (rawElement: RM) => EM,
|
|
254
|
+
thisArg?: any
|
|
255
|
+
): Stack<EM, RM> {
|
|
256
|
+
const newStack = new Stack<EM, RM>([], { toElementFn });
|
|
252
257
|
let index = 0;
|
|
253
258
|
for (const el of this) {
|
|
254
259
|
newStack.push(callback.call(thisArg, el, index, this));
|
|
@@ -93,21 +93,27 @@ export class TrieNode {
|
|
|
93
93
|
* 10. IP Routing: Used in certain types of IP routing algorithms.
|
|
94
94
|
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data.
|
|
95
95
|
*/
|
|
96
|
-
export class Trie extends IterableElementBase<string, Trie
|
|
96
|
+
export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
|
|
97
97
|
/**
|
|
98
98
|
* The constructor function for the Trie class.
|
|
99
99
|
* @param words: Iterable string Initialize the trie with a set of words
|
|
100
100
|
* @param options?: TrieOptions Allow the user to pass in options for the trie
|
|
101
101
|
* @return This
|
|
102
102
|
*/
|
|
103
|
-
constructor(words: Iterable<string> = [], options?: TrieOptions) {
|
|
104
|
-
super();
|
|
103
|
+
constructor(words: Iterable<string> | Iterable<R> = [], options?: TrieOptions<R>) {
|
|
104
|
+
super(options);
|
|
105
105
|
if (options) {
|
|
106
106
|
const { caseSensitive } = options;
|
|
107
107
|
if (caseSensitive !== undefined) this._caseSensitive = caseSensitive;
|
|
108
108
|
}
|
|
109
109
|
if (words) {
|
|
110
|
-
for (const word of words)
|
|
110
|
+
for (const word of words) {
|
|
111
|
+
if (this.toElementFn) {
|
|
112
|
+
this.add(this.toElementFn(word as R));
|
|
113
|
+
} else {
|
|
114
|
+
this.add(word as string);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
|
|
@@ -470,8 +476,8 @@ export class Trie extends IterableElementBase<string, Trie> {
|
|
|
470
476
|
* sensitivity as the original Trie.
|
|
471
477
|
* @returns A new instance of the Trie class is being returned.
|
|
472
478
|
*/
|
|
473
|
-
clone(): Trie {
|
|
474
|
-
return new Trie(this
|
|
479
|
+
clone(): Trie<R> {
|
|
480
|
+
return new Trie<R>(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
|
|
475
481
|
}
|
|
476
482
|
|
|
477
483
|
/**
|
|
@@ -493,8 +499,8 @@ export class Trie extends IterableElementBase<string, Trie> {
|
|
|
493
499
|
* specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
|
|
494
500
|
* @returns The `filter` method is returning an array of strings (`string[]`).
|
|
495
501
|
*/
|
|
496
|
-
filter(predicate: ElementCallback<string, boolean
|
|
497
|
-
const results
|
|
502
|
+
filter(predicate: ElementCallback<string, R, boolean, Trie<R>>, thisArg?: any): Trie<R> {
|
|
503
|
+
const results = new Trie<R>([], { toElementFn: this.toElementFn, caseSensitive: this.caseSensitive });
|
|
498
504
|
let index = 0;
|
|
499
505
|
for (const word of this) {
|
|
500
506
|
if (predicate.call(thisArg, word, index, this)) {
|
|
@@ -514,17 +520,26 @@ export class Trie extends IterableElementBase<string, Trie> {
|
|
|
514
520
|
* Time Complexity: O(n)
|
|
515
521
|
* Space Complexity: O(n)
|
|
516
522
|
*
|
|
517
|
-
* The `map` function creates a new Trie by applying a callback function to each element in the
|
|
523
|
+
* The `map` function creates a new Trie by applying a callback function to each element in the
|
|
524
|
+
* current Trie.
|
|
518
525
|
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
519
|
-
* Trie. It takes
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
* @
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
* Trie. It takes four arguments:
|
|
527
|
+
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be used to
|
|
528
|
+
* convert the raw element (`RM`) into a string representation. This can be useful if the raw element
|
|
529
|
+
* is not already a string or if you want to customize how the element is converted into a string. If
|
|
530
|
+
* this parameter is
|
|
531
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
|
|
532
|
+
* specify the value of `this` within the callback function. It is used to set the context or scope
|
|
533
|
+
* in which the callback function will be executed. If `thisArg` is provided, it will be used as the
|
|
534
|
+
* value of
|
|
535
|
+
* @returns a new Trie object.
|
|
536
|
+
*/
|
|
537
|
+
map<RM>(
|
|
538
|
+
callback: ElementCallback<string, R, string, Trie<R>>,
|
|
539
|
+
toElementFn?: (rawElement: RM) => string,
|
|
540
|
+
thisArg?: any
|
|
541
|
+
): Trie<RM> {
|
|
542
|
+
const newTrie = new Trie<RM>([], { toElementFn, caseSensitive: this.caseSensitive });
|
|
528
543
|
let index = 0;
|
|
529
544
|
for (const word of this) {
|
|
530
545
|
newTrie.add(callback.call(thisArg, word, index, this));
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
// export { MinHeap } from 'data-structure-typed';
|
|
9
8
|
export * from './data-structures/heap/min-heap';
|
|
9
|
+
export * from './data-structures/heap/heap';
|
|
10
10
|
export * from './types/data-structures/heap/min-heap';
|
|
11
|
+
export * from './types/data-structures/heap/heap';
|
|
11
12
|
export * from './types/common';
|
|
@@ -5,12 +5,11 @@ import type {
|
|
|
5
5
|
BinaryTreeNodeNested,
|
|
6
6
|
BinaryTreeOptions,
|
|
7
7
|
BTNCallback,
|
|
8
|
-
|
|
9
|
-
KeyOrNodeOrEntry
|
|
8
|
+
BTNKeyOrNodeOrEntry
|
|
10
9
|
} from '../types';
|
|
11
10
|
|
|
12
11
|
export interface IBinaryTree<
|
|
13
|
-
K
|
|
12
|
+
K = any,
|
|
14
13
|
V = any,
|
|
15
14
|
R = [K, V],
|
|
16
15
|
NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>,
|
|
@@ -20,9 +19,9 @@ export interface IBinaryTree<
|
|
|
20
19
|
|
|
21
20
|
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
|
|
22
21
|
|
|
23
|
-
add(keyOrNodeOrEntryOrRawElement:
|
|
22
|
+
add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
24
23
|
|
|
25
|
-
addMany(nodes: Iterable<
|
|
24
|
+
addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
|
|
26
25
|
|
|
27
26
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
|
|
28
27
|
}
|
package/src/types/common.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
export type CP = 1 | -1 | 0;
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Enum representing different loop types.
|
|
5
|
-
*
|
|
6
|
-
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
7
|
-
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
8
|
-
*/
|
|
9
3
|
export type IterationType = 'ITERATIVE' | 'RECURSIVE';
|
|
10
4
|
|
|
11
5
|
export type FamilyPosition = 'ROOT' | 'LEFT' | 'RIGHT' | 'ROOT_LEFT' | 'ROOT_RIGHT' | 'ISOLATED' | 'MAL_NODE';
|
|
@@ -16,8 +10,6 @@ export type DFSOrderPattern = 'PRE' | 'IN' | 'POST';
|
|
|
16
10
|
|
|
17
11
|
export type NodeDisplayLayout = [string[], number, number, number];
|
|
18
12
|
|
|
19
|
-
export type BTNCallback<N, D = any> = (node: N) => D;
|
|
20
|
-
|
|
21
13
|
export interface IterableWithSize<T> extends Iterable<T> {
|
|
22
14
|
size: number | ((...args: any[]) => number);
|
|
23
15
|
}
|
|
@@ -26,22 +18,8 @@ export interface IterableWithLength<T> extends Iterable<T> {
|
|
|
26
18
|
length: number | ((...args: any[]) => number);
|
|
27
19
|
}
|
|
28
20
|
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
export type BinaryTreePrintOptions = { isShowUndefined?: boolean; isShowNull?: boolean; isShowRedBlackNIL?: boolean };
|
|
32
|
-
|
|
33
|
-
export type BTNEntry<K, V> = [K | null | undefined, V | undefined];
|
|
34
|
-
|
|
35
|
-
export type BTNKeyOrNode<K, N> = K | null | undefined | N;
|
|
21
|
+
export type OptValue<V> = V | undefined;
|
|
36
22
|
|
|
37
|
-
export type
|
|
38
|
-
|
|
39
|
-
export type BTNodePureKeyOrNode<K, N> = K | N;
|
|
40
|
-
|
|
41
|
-
export type BTNPureKeyOrNodeOrEntry<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
|
|
42
|
-
|
|
43
|
-
export type BSTNKeyOrNode<K, N> = K | undefined | N;
|
|
44
|
-
|
|
45
|
-
export type BinaryTreeDeleteResult<N> = { deleted: N | null | undefined; needBalanced: N | null | undefined };
|
|
23
|
+
export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>;
|
|
46
24
|
|
|
47
25
|
export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
|
|
2
2
|
|
|
3
3
|
export type EntryCallback<K, V, R> = (value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
|
|
4
|
-
export type ElementCallback<
|
|
4
|
+
export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
|
|
5
5
|
export type ReduceEntryCallback<K, V, R> = (
|
|
6
6
|
accumulator: R,
|
|
7
7
|
value: V,
|
|
@@ -9,9 +9,17 @@ export type ReduceEntryCallback<K, V, R> = (
|
|
|
9
9
|
index: number,
|
|
10
10
|
container: IterableEntryBase<K, V>
|
|
11
11
|
) => R;
|
|
12
|
-
export type ReduceElementCallback<
|
|
13
|
-
accumulator:
|
|
14
|
-
element:
|
|
12
|
+
export type ReduceElementCallback<E, R, RT, C> = (
|
|
13
|
+
accumulator: RT,
|
|
14
|
+
element: E,
|
|
15
15
|
index: number,
|
|
16
|
-
container: IterableElementBase<
|
|
17
|
-
) =>
|
|
16
|
+
container: IterableElementBase<E, R, C>
|
|
17
|
+
) => RT;
|
|
18
|
+
|
|
19
|
+
// export type IterableEntryBaseOptions<K, V, R> = {
|
|
20
|
+
// toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
|
|
21
|
+
// };
|
|
22
|
+
|
|
23
|
+
export type IterableElementBaseOptions<E, R> = {
|
|
24
|
+
toElementFn?: (rawElement: R) => E;
|
|
25
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
|
|
2
2
|
import type { AVLTreeOptions } from './avl-tree';
|
|
3
|
-
import { Comparable } from "../../utils";
|
|
4
3
|
|
|
5
|
-
export type AVLTreeMultiMapNodeNested<K
|
|
4
|
+
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
6
5
|
|
|
7
|
-
export type AVLTreeMultiMapNested<K
|
|
6
|
+
export type AVLTreeMultiMapNested<K, V, R, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, AVLTreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
8
7
|
|
|
9
8
|
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AVLTree, AVLTreeNode } from '../../../data-structures';
|
|
2
2
|
import { BSTOptions } from './bst';
|
|
3
|
-
import { Comparable } from "../../utils";
|
|
4
3
|
|
|
5
|
-
export type AVLTreeNodeNested<K
|
|
4
|
+
export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
6
5
|
|
|
7
|
-
export type AVLTreeNested<K
|
|
6
|
+
export type AVLTreeNested<K, V, R, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, AVLTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
8
7
|
|
|
9
8
|
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
|