min-heap-typed 1.53.7 → 1.53.9
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/common/index.js +5 -0
- package/dist/data-structures/base/iterable-entry-base.js +4 -4
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +65 -36
- package/dist/data-structures/binary-tree/avl-tree.d.ts +12 -8
- package/dist/data-structures/binary-tree/avl-tree.js +19 -6
- package/dist/data-structures/binary-tree/binary-tree.d.ts +53 -40
- package/dist/data-structures/binary-tree/binary-tree.js +76 -72
- package/dist/data-structures/binary-tree/bst.d.ts +87 -52
- package/dist/data-structures/binary-tree/bst.js +111 -63
- package/dist/data-structures/binary-tree/index.d.ts +1 -1
- package/dist/data-structures/binary-tree/index.js +1 -1
- package/dist/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +83 -10
- package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +91 -44
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +34 -18
- package/dist/data-structures/binary-tree/tree-multi-map.js +66 -40
- package/dist/data-structures/graph/abstract-graph.js +2 -2
- package/dist/data-structures/hash/hash-map.d.ts +31 -1
- package/dist/data-structures/hash/hash-map.js +35 -5
- package/dist/data-structures/heap/heap.d.ts +20 -3
- package/dist/data-structures/heap/heap.js +31 -11
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
- package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +44 -11
- package/dist/data-structures/linked-list/singly-linked-list.js +70 -26
- package/dist/data-structures/queue/deque.d.ts +37 -8
- package/dist/data-structures/queue/deque.js +73 -29
- package/dist/data-structures/queue/queue.d.ts +41 -1
- package/dist/data-structures/queue/queue.js +51 -9
- package/dist/data-structures/stack/stack.d.ts +27 -10
- package/dist/data-structures/stack/stack.js +39 -20
- package/dist/data-structures/trie/trie.d.ts +8 -3
- package/dist/data-structures/trie/trie.js +8 -3
- package/dist/interfaces/binary-tree.d.ts +3 -4
- package/dist/types/data-structures/base/base.d.ts +1 -1
- 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 +2 -3
- package/dist/types/data-structures/binary-tree/bst.d.ts +3 -4
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
- package/package.json +2 -2
- package/src/common/index.ts +7 -1
- package/src/data-structures/base/iterable-entry-base.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +82 -55
- package/src/data-structures/binary-tree/avl-tree.ts +32 -15
- package/src/data-structures/binary-tree/binary-tree.ts +89 -84
- package/src/data-structures/binary-tree/bst.ts +149 -97
- package/src/data-structures/binary-tree/index.ts +1 -1
- package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +105 -55
- package/src/data-structures/binary-tree/tree-multi-map.ts +81 -51
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +37 -7
- package/src/data-structures/heap/heap.ts +33 -10
- package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
- package/src/data-structures/linked-list/singly-linked-list.ts +77 -27
- package/src/data-structures/queue/deque.ts +72 -28
- package/src/data-structures/queue/queue.ts +50 -7
- package/src/data-structures/stack/stack.ts +39 -20
- package/src/data-structures/trie/trie.ts +8 -3
- package/src/interfaces/binary-tree.ts +3 -13
- package/src/types/data-structures/base/base.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -4
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -4
- package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/bst.ts +3 -5
- package/src/types/data-structures/binary-tree/rb-tree.ts +4 -6
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -6
|
@@ -84,6 +84,18 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
84
84
|
* @returns Always returns true, indicating the element was successfully added.
|
|
85
85
|
*/
|
|
86
86
|
push(element: E): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Time Complexity: O(k)
|
|
89
|
+
* Space Complexity: O(k)
|
|
90
|
+
*
|
|
91
|
+
* The `pushMany` function iterates over elements and pushes them into an array after applying a
|
|
92
|
+
* transformation function if provided.
|
|
93
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
|
|
94
|
+
* is an iterable containing elements of type `E` or `R`.
|
|
95
|
+
* @returns The `pushMany` function is returning an array of boolean values indicating whether each
|
|
96
|
+
* element was successfully pushed into the data structure.
|
|
97
|
+
*/
|
|
98
|
+
pushMany(elements: Iterable<E> | Iterable<R>): boolean[];
|
|
87
99
|
/**
|
|
88
100
|
* Time Complexity: O(1)
|
|
89
101
|
* Space Complexity: O(1)
|
|
@@ -94,12 +106,18 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
94
106
|
*/
|
|
95
107
|
shift(): E | undefined;
|
|
96
108
|
/**
|
|
109
|
+
* Time Complexity: O(n)
|
|
110
|
+
* Space Complexity: O(1)
|
|
111
|
+
*
|
|
97
112
|
* The delete function removes an element from the list.
|
|
98
113
|
* @param {E} element - Specify the element to be deleted
|
|
99
114
|
* @return A boolean value indicating whether the element was successfully deleted or not
|
|
100
115
|
*/
|
|
101
116
|
delete(element: E): boolean;
|
|
102
117
|
/**
|
|
118
|
+
* Time Complexity: O(n)
|
|
119
|
+
* Space Complexity: O(1)
|
|
120
|
+
*
|
|
103
121
|
* The deleteAt function deletes the element at a given index.
|
|
104
122
|
* @param {number} index - Determine the index of the element to be deleted
|
|
105
123
|
* @return A boolean value
|
|
@@ -109,7 +127,12 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
109
127
|
* Time Complexity: O(1)
|
|
110
128
|
* Space Complexity: O(1)
|
|
111
129
|
*
|
|
112
|
-
*
|
|
130
|
+
* The `at` function returns the element at a specified index adjusted by an offset, or `undefined`
|
|
131
|
+
* if the index is out of bounds.
|
|
132
|
+
* @param {number} index - The `index` parameter represents the position of the element you want to
|
|
133
|
+
* retrieve from the data structure.
|
|
134
|
+
* @returns The `at` method is returning the element at the specified index adjusted by the offset
|
|
135
|
+
* `_offset`.
|
|
113
136
|
*/
|
|
114
137
|
at(index: number): E | undefined;
|
|
115
138
|
/**
|
|
@@ -136,6 +159,9 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
136
159
|
*/
|
|
137
160
|
clear(): void;
|
|
138
161
|
/**
|
|
162
|
+
* Time Complexity: O(n)
|
|
163
|
+
* Space Complexity: O(1)
|
|
164
|
+
*
|
|
139
165
|
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
|
|
140
166
|
* offset to zero.
|
|
141
167
|
* @returns The `compact()` method is returning a boolean value of `true`.
|
|
@@ -169,6 +195,20 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
169
195
|
/**
|
|
170
196
|
* Time Complexity: O(n)
|
|
171
197
|
* Space Complexity: O(n)
|
|
198
|
+
*
|
|
199
|
+
* The `map` function in TypeScript creates a new Queue by applying a callback function to each
|
|
200
|
+
* element in the original Queue.
|
|
201
|
+
* @param callback - The `callback` parameter is a function that will be applied to each element in
|
|
202
|
+
* the queue. It takes the current element, its index, and the queue itself as arguments, and returns
|
|
203
|
+
* a new element.
|
|
204
|
+
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be provided to
|
|
205
|
+
* convert a raw element of type `RM` to a new element of type `EM`. This function is used within the
|
|
206
|
+
* `map` method to transform each raw element before passing it to the `callback` function. If
|
|
207
|
+
* @param {any} [thisArg] - The `thisArg` parameter in the `map` function is used to specify the
|
|
208
|
+
* value of `this` when executing the `callback` function. It allows you to set the context (the
|
|
209
|
+
* value of `this`) within the callback function. If `thisArg` is provided, it will be
|
|
210
|
+
* @returns A new Queue object containing elements of type EM, which are the result of applying the
|
|
211
|
+
* callback function to each element in the original Queue object.
|
|
172
212
|
*/
|
|
173
213
|
map<EM, RM>(callback: ElementCallback<E, R, EM, Queue<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Queue<EM, RM>;
|
|
174
214
|
/**
|
|
@@ -22,14 +22,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
22
22
|
const { autoCompactRatio = 0.5 } = options;
|
|
23
23
|
this._autoCompactRatio = autoCompactRatio;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
for (const el of elements) {
|
|
27
|
-
if (this.toElementFn)
|
|
28
|
-
this.push(this.toElementFn(el));
|
|
29
|
-
else
|
|
30
|
-
this.push(el);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
25
|
+
this.pushMany(elements);
|
|
33
26
|
}
|
|
34
27
|
/**
|
|
35
28
|
* The elements function returns the elements of this set.
|
|
@@ -114,6 +107,27 @@ class Queue extends base_1.IterableElementBase {
|
|
|
114
107
|
this.elements.push(element);
|
|
115
108
|
return true;
|
|
116
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Time Complexity: O(k)
|
|
112
|
+
* Space Complexity: O(k)
|
|
113
|
+
*
|
|
114
|
+
* The `pushMany` function iterates over elements and pushes them into an array after applying a
|
|
115
|
+
* transformation function if provided.
|
|
116
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
|
|
117
|
+
* is an iterable containing elements of type `E` or `R`.
|
|
118
|
+
* @returns The `pushMany` function is returning an array of boolean values indicating whether each
|
|
119
|
+
* element was successfully pushed into the data structure.
|
|
120
|
+
*/
|
|
121
|
+
pushMany(elements) {
|
|
122
|
+
const ans = [];
|
|
123
|
+
for (const el of elements) {
|
|
124
|
+
if (this.toElementFn)
|
|
125
|
+
ans.push(this.push(this.toElementFn(el)));
|
|
126
|
+
else
|
|
127
|
+
ans.push(this.push(el));
|
|
128
|
+
}
|
|
129
|
+
return ans;
|
|
130
|
+
}
|
|
117
131
|
/**
|
|
118
132
|
* Time Complexity: O(1)
|
|
119
133
|
* Space Complexity: O(1)
|
|
@@ -132,6 +146,9 @@ class Queue extends base_1.IterableElementBase {
|
|
|
132
146
|
return first;
|
|
133
147
|
}
|
|
134
148
|
/**
|
|
149
|
+
* Time Complexity: O(n)
|
|
150
|
+
* Space Complexity: O(1)
|
|
151
|
+
*
|
|
135
152
|
* The delete function removes an element from the list.
|
|
136
153
|
* @param {E} element - Specify the element to be deleted
|
|
137
154
|
* @return A boolean value indicating whether the element was successfully deleted or not
|
|
@@ -141,6 +158,9 @@ class Queue extends base_1.IterableElementBase {
|
|
|
141
158
|
return this.deleteAt(index);
|
|
142
159
|
}
|
|
143
160
|
/**
|
|
161
|
+
* Time Complexity: O(n)
|
|
162
|
+
* Space Complexity: O(1)
|
|
163
|
+
*
|
|
144
164
|
* The deleteAt function deletes the element at a given index.
|
|
145
165
|
* @param {number} index - Determine the index of the element to be deleted
|
|
146
166
|
* @return A boolean value
|
|
@@ -153,7 +173,12 @@ class Queue extends base_1.IterableElementBase {
|
|
|
153
173
|
* Time Complexity: O(1)
|
|
154
174
|
* Space Complexity: O(1)
|
|
155
175
|
*
|
|
156
|
-
*
|
|
176
|
+
* The `at` function returns the element at a specified index adjusted by an offset, or `undefined`
|
|
177
|
+
* if the index is out of bounds.
|
|
178
|
+
* @param {number} index - The `index` parameter represents the position of the element you want to
|
|
179
|
+
* retrieve from the data structure.
|
|
180
|
+
* @returns The `at` method is returning the element at the specified index adjusted by the offset
|
|
181
|
+
* `_offset`.
|
|
157
182
|
*/
|
|
158
183
|
at(index) {
|
|
159
184
|
return this.elements[index + this._offset];
|
|
@@ -189,6 +214,9 @@ class Queue extends base_1.IterableElementBase {
|
|
|
189
214
|
this._offset = 0;
|
|
190
215
|
}
|
|
191
216
|
/**
|
|
217
|
+
* Time Complexity: O(n)
|
|
218
|
+
* Space Complexity: O(1)
|
|
219
|
+
*
|
|
192
220
|
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
|
|
193
221
|
* offset to zero.
|
|
194
222
|
* @returns The `compact()` method is returning a boolean value of `true`.
|
|
@@ -238,6 +266,20 @@ class Queue extends base_1.IterableElementBase {
|
|
|
238
266
|
/**
|
|
239
267
|
* Time Complexity: O(n)
|
|
240
268
|
* Space Complexity: O(n)
|
|
269
|
+
*
|
|
270
|
+
* The `map` function in TypeScript creates a new Queue by applying a callback function to each
|
|
271
|
+
* element in the original Queue.
|
|
272
|
+
* @param callback - The `callback` parameter is a function that will be applied to each element in
|
|
273
|
+
* the queue. It takes the current element, its index, and the queue itself as arguments, and returns
|
|
274
|
+
* a new element.
|
|
275
|
+
* @param [toElementFn] - The `toElementFn` parameter is an optional function that can be provided to
|
|
276
|
+
* convert a raw element of type `RM` to a new element of type `EM`. This function is used within the
|
|
277
|
+
* `map` method to transform each raw element before passing it to the `callback` function. If
|
|
278
|
+
* @param {any} [thisArg] - The `thisArg` parameter in the `map` function is used to specify the
|
|
279
|
+
* value of `this` when executing the `callback` function. It allows you to set the context (the
|
|
280
|
+
* value of `this`) within the callback function. If `thisArg` is provided, it will be
|
|
281
|
+
* @returns A new Queue object containing elements of type EM, which are the result of applying the
|
|
282
|
+
* callback function to each element in the original Queue object.
|
|
241
283
|
*/
|
|
242
284
|
map(callback, toElementFn, thisArg) {
|
|
243
285
|
const newDeque = new Queue([], { toElementFn });
|
|
@@ -28,10 +28,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
28
28
|
* @returns The size of the elements array.
|
|
29
29
|
*/
|
|
30
30
|
get size(): number;
|
|
31
|
-
/**
|
|
32
|
-
* Time Complexity: O(n)
|
|
33
|
-
* Space Complexity: O(n)
|
|
34
|
-
*/
|
|
35
31
|
/**
|
|
36
32
|
* Time Complexity: O(n)
|
|
37
33
|
* Space Complexity: O(n)
|
|
@@ -43,6 +39,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
43
39
|
*/
|
|
44
40
|
static fromArray<E>(elements: E[]): Stack<E>;
|
|
45
41
|
/**
|
|
42
|
+
* Time Complexity: O(1)
|
|
43
|
+
* Space Complexity: O(1)
|
|
44
|
+
*
|
|
46
45
|
* The function checks if an array is empty and returns a boolean value.
|
|
47
46
|
* @returns A boolean value indicating whether the `_elements` array is empty or not.
|
|
48
47
|
*/
|
|
@@ -74,15 +73,33 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
74
73
|
*/
|
|
75
74
|
pop(): E | undefined;
|
|
76
75
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
76
|
+
* Time Complexity: O(k)
|
|
77
|
+
* Space Complexity: O(1)
|
|
78
|
+
*
|
|
79
|
+
* The function `pushMany` iterates over elements and pushes them into an array after applying a
|
|
80
|
+
* transformation function if provided.
|
|
81
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
|
|
82
|
+
* is an iterable containing elements of type `E` or `R`. The function iterates over each element in
|
|
83
|
+
* the iterable and pushes it into the data structure. If a transformation function `toElementFn` is
|
|
84
|
+
* provided, it is used to
|
|
85
|
+
* @returns The `pushMany` function is returning an array of boolean values indicating whether each
|
|
86
|
+
* element was successfully pushed into the data structure.
|
|
87
|
+
*/
|
|
88
|
+
pushMany(elements: Iterable<E> | Iterable<R>): boolean[];
|
|
89
|
+
/**
|
|
90
|
+
* Time Complexity: O(n)
|
|
91
|
+
* Space Complexity: O(1)
|
|
92
|
+
*
|
|
93
|
+
* The toArray function returns a copy of the elements in an array.
|
|
94
|
+
* @returns An array of type E.
|
|
80
95
|
*/
|
|
81
96
|
delete(element: E): boolean;
|
|
82
97
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
98
|
+
* Time Complexity: O(n)
|
|
99
|
+
* Space Complexity: O(1)
|
|
100
|
+
*
|
|
101
|
+
* The toArray function returns a copy of the elements in an array.
|
|
102
|
+
* @returns An array of type E.
|
|
86
103
|
*/
|
|
87
104
|
deleteAt(index: number): boolean;
|
|
88
105
|
/**
|
|
@@ -14,16 +14,7 @@ class Stack extends base_1.IterableElementBase {
|
|
|
14
14
|
constructor(elements = [], options) {
|
|
15
15
|
super(options);
|
|
16
16
|
this._elements = [];
|
|
17
|
-
|
|
18
|
-
for (const el of elements) {
|
|
19
|
-
if (this.toElementFn) {
|
|
20
|
-
this.push(this.toElementFn(el));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
this.push(el);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
17
|
+
this.pushMany(elements);
|
|
27
18
|
}
|
|
28
19
|
/**
|
|
29
20
|
* The elements function returns the elements of this set.
|
|
@@ -39,10 +30,6 @@ class Stack extends base_1.IterableElementBase {
|
|
|
39
30
|
get size() {
|
|
40
31
|
return this.elements.length;
|
|
41
32
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Time Complexity: O(n)
|
|
44
|
-
* Space Complexity: O(n)
|
|
45
|
-
*/
|
|
46
33
|
/**
|
|
47
34
|
* Time Complexity: O(n)
|
|
48
35
|
* Space Complexity: O(n)
|
|
@@ -56,6 +43,9 @@ class Stack extends base_1.IterableElementBase {
|
|
|
56
43
|
return new Stack(elements);
|
|
57
44
|
}
|
|
58
45
|
/**
|
|
46
|
+
* Time Complexity: O(1)
|
|
47
|
+
* Space Complexity: O(1)
|
|
48
|
+
*
|
|
59
49
|
* The function checks if an array is empty and returns a boolean value.
|
|
60
50
|
* @returns A boolean value indicating whether the `_elements` array is empty or not.
|
|
61
51
|
*/
|
|
@@ -100,18 +90,47 @@ class Stack extends base_1.IterableElementBase {
|
|
|
100
90
|
return this.elements.pop();
|
|
101
91
|
}
|
|
102
92
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
93
|
+
* Time Complexity: O(k)
|
|
94
|
+
* Space Complexity: O(1)
|
|
95
|
+
*
|
|
96
|
+
* The function `pushMany` iterates over elements and pushes them into an array after applying a
|
|
97
|
+
* transformation function if provided.
|
|
98
|
+
* @param {Iterable<E> | Iterable<R>} elements - The `elements` parameter in the `pushMany` function
|
|
99
|
+
* is an iterable containing elements of type `E` or `R`. The function iterates over each element in
|
|
100
|
+
* the iterable and pushes it into the data structure. If a transformation function `toElementFn` is
|
|
101
|
+
* provided, it is used to
|
|
102
|
+
* @returns The `pushMany` function is returning an array of boolean values indicating whether each
|
|
103
|
+
* element was successfully pushed into the data structure.
|
|
104
|
+
*/
|
|
105
|
+
pushMany(elements) {
|
|
106
|
+
const ans = [];
|
|
107
|
+
for (const el of elements) {
|
|
108
|
+
if (this.toElementFn) {
|
|
109
|
+
ans.push(this.push(this.toElementFn(el)));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
ans.push(this.push(el));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return ans;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Time Complexity: O(n)
|
|
119
|
+
* Space Complexity: O(1)
|
|
120
|
+
*
|
|
121
|
+
* The toArray function returns a copy of the elements in an array.
|
|
122
|
+
* @returns An array of type E.
|
|
106
123
|
*/
|
|
107
124
|
delete(element) {
|
|
108
125
|
const index = this.elements.indexOf(element);
|
|
109
126
|
return this.deleteAt(index);
|
|
110
127
|
}
|
|
111
128
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
129
|
+
* Time Complexity: O(n)
|
|
130
|
+
* Space Complexity: O(1)
|
|
131
|
+
*
|
|
132
|
+
* The toArray function returns a copy of the elements in an array.
|
|
133
|
+
* @returns An array of type E.
|
|
115
134
|
*/
|
|
116
135
|
deleteAt(index) {
|
|
117
136
|
const spliced = this.elements.splice(index, 1);
|
|
@@ -200,7 +200,7 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
200
200
|
* @returns The `addMany` method returns an array of boolean values indicating whether each word in
|
|
201
201
|
* the input iterable was successfully added to the data structure.
|
|
202
202
|
*/
|
|
203
|
-
addMany(words
|
|
203
|
+
addMany(words: Iterable<string> | Iterable<R>): boolean[];
|
|
204
204
|
/**
|
|
205
205
|
* Time Complexity: O(l), where l is the length of the input word.
|
|
206
206
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -235,9 +235,14 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
235
235
|
*/
|
|
236
236
|
delete(word: string): boolean;
|
|
237
237
|
/**
|
|
238
|
-
* Time Complexity: O(n)
|
|
239
|
-
* Space Complexity: O(1)
|
|
238
|
+
* Time Complexity: O(n)
|
|
239
|
+
* Space Complexity: O(1)
|
|
240
240
|
*
|
|
241
|
+
* The function `getHeight` calculates the height of a trie data structure starting from the root
|
|
242
|
+
* node.
|
|
243
|
+
* @returns The `getHeight` method returns the maximum depth or height of the trie tree starting from
|
|
244
|
+
* the root node. It calculates the depth using a breadth-first search (BFS) traversal of the trie
|
|
245
|
+
* tree and returns the maximum depth found.
|
|
241
246
|
*/
|
|
242
247
|
getHeight(): number;
|
|
243
248
|
/**
|
|
@@ -243,7 +243,7 @@ class Trie extends base_1.IterableElementBase {
|
|
|
243
243
|
* @returns The `addMany` method returns an array of boolean values indicating whether each word in
|
|
244
244
|
* the input iterable was successfully added to the data structure.
|
|
245
245
|
*/
|
|
246
|
-
addMany(words
|
|
246
|
+
addMany(words) {
|
|
247
247
|
const ans = [];
|
|
248
248
|
for (const word of words) {
|
|
249
249
|
if (this.toElementFn) {
|
|
@@ -338,9 +338,14 @@ class Trie extends base_1.IterableElementBase {
|
|
|
338
338
|
return isDeleted;
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
|
-
* Time Complexity: O(n)
|
|
342
|
-
* Space Complexity: O(1)
|
|
341
|
+
* Time Complexity: O(n)
|
|
342
|
+
* Space Complexity: O(1)
|
|
343
343
|
*
|
|
344
|
+
* The function `getHeight` calculates the height of a trie data structure starting from the root
|
|
345
|
+
* node.
|
|
346
|
+
* @returns The `getHeight` method returns the maximum depth or height of the trie tree starting from
|
|
347
|
+
* the root node. It calculates the depth using a breadth-first search (BFS) traversal of the trie
|
|
348
|
+
* tree and returns the maximum depth found.
|
|
344
349
|
*/
|
|
345
350
|
getHeight() {
|
|
346
351
|
const startNode = this.root;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { BinaryTreeDeleteResult,
|
|
3
|
-
export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V
|
|
1
|
+
import { BinaryTreeNode } from '../data-structures';
|
|
2
|
+
import type { BinaryTreeDeleteResult, BinaryTreeNodeNested, BTNRep, NodePredicate } from '../types';
|
|
3
|
+
export interface IBinaryTree<K = any, V = any, R = object, NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>> {
|
|
4
4
|
createNode(key: K, value?: NODE['value']): NODE;
|
|
5
|
-
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
|
|
6
5
|
add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
|
|
7
6
|
addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
|
|
8
7
|
delete(predicate: R | BTNRep<K, V, NODE> | NodePredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
|
|
2
|
-
export type EntryCallback<K, V, R> = (
|
|
2
|
+
export type EntryCallback<K, V, R> = (key: K, value: V, index: number, container: IterableEntryBase<K, V>) => R;
|
|
3
3
|
export type ElementCallback<E, R, RT, C> = (element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
|
|
4
4
|
export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, container: IterableEntryBase<K, V>) => R;
|
|
5
5
|
export type ReduceElementCallback<E, R, RT, C> = (accumulator: RT, element: E, index: number, container: IterableElementBase<E, R, C>) => RT;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVLTreeMultiMapNode } from '../../../data-structures';
|
|
2
2
|
import type { AVLTreeOptions } from './avl-tree';
|
|
3
|
-
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,
|
|
4
|
-
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
3
|
+
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, any>>>>>>>>>>;
|
|
5
4
|
export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVLTreeNode } from '../../../data-structures';
|
|
2
2
|
import { BSTOptions } from './bst';
|
|
3
|
-
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,
|
|
4
|
-
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
3
|
+
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, any>>>>>>>>>>;
|
|
5
4
|
export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BinaryTreeNode } from '../../../data-structures';
|
|
2
2
|
import { IterationType, OptValue } from '../../common';
|
|
3
3
|
import { DFSOperation } from '../../../common';
|
|
4
|
-
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V,
|
|
5
|
-
export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
+
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>;
|
|
6
5
|
export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
|
|
7
6
|
export type BinaryTreeOptions<K, V, R> = {
|
|
8
7
|
iterationType?: IterationType;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BSTNode } from '../../../data-structures';
|
|
2
2
|
import type { BinaryTreeOptions } from './binary-tree';
|
|
3
3
|
import { Comparable } from '../../utils';
|
|
4
|
-
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V,
|
|
5
|
-
export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
+
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>;
|
|
6
5
|
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
|
|
7
|
-
|
|
6
|
+
specifyComparable?: (key: K) => Comparable;
|
|
8
7
|
isReverse?: boolean;
|
|
9
8
|
};
|
|
10
9
|
export type BSTNOptKey<K> = K | undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { BSTOptions } from
|
|
1
|
+
import { RedBlackTreeNode } from '../../../data-structures';
|
|
2
|
+
import type { BSTOptions } from './bst';
|
|
3
3
|
export type RBTNColor = 'RED' | 'BLACK';
|
|
4
|
-
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V,
|
|
5
|
-
export type
|
|
6
|
-
export type RBTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};
|
|
4
|
+
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>;
|
|
5
|
+
export type RedBlackTreeOptions<K, V, R> = Omit<BSTOptions<K, V, R>, 'isReverse'> & {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V,
|
|
4
|
-
export type
|
|
5
|
-
export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {};
|
|
1
|
+
import { TreeMultiMapNode } from '../../../data-structures';
|
|
2
|
+
import type { RedBlackTreeOptions } from './rb-tree';
|
|
3
|
+
export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>>>>>>>>;
|
|
4
|
+
export type TreeMultiMapOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "min-heap-typed",
|
|
3
|
-
"version": "1.53.
|
|
3
|
+
"version": "1.53.9",
|
|
4
4
|
"description": "Min Heap. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -132,6 +132,6 @@
|
|
|
132
132
|
"typescript": "^4.9.5"
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"data-structure-typed": "^1.53.
|
|
135
|
+
"data-structure-typed": "^1.53.9"
|
|
136
136
|
}
|
|
137
137
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { isComparable } from '../utils';
|
|
2
|
+
|
|
1
3
|
export enum DFSOperation {
|
|
2
4
|
VISIT = 0,
|
|
3
5
|
PROCESS = 1
|
|
4
6
|
}
|
|
7
|
+
|
|
5
8
|
export class Range<K> {
|
|
6
9
|
constructor(
|
|
7
10
|
public low: K,
|
|
8
11
|
public high: K,
|
|
9
12
|
public includeLow: boolean = true,
|
|
10
13
|
public includeHigh: boolean = true
|
|
11
|
-
) {
|
|
14
|
+
) {
|
|
15
|
+
if (!(isComparable(low) && isComparable(high))) throw new RangeError('low or high is not comparable');
|
|
16
|
+
if (low > high) throw new RangeError('low must be less than or equal to high');
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
// Determine whether a key is within the range
|
|
14
20
|
isInRange(key: K, comparator: (a: K, b: K) => number): boolean {
|
|
@@ -70,7 +70,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|
|
70
70
|
every(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
|
|
71
71
|
let index = 0;
|
|
72
72
|
for (const item of this) {
|
|
73
|
-
if (!predicate.call(thisArg, item[
|
|
73
|
+
if (!predicate.call(thisArg, item[0], item[1], index++, this)) {
|
|
74
74
|
return false;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -95,7 +95,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|
|
95
95
|
some(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
|
|
96
96
|
let index = 0;
|
|
97
97
|
for (const item of this) {
|
|
98
|
-
if (predicate.call(thisArg, item[
|
|
98
|
+
if (predicate.call(thisArg, item[0], item[1], index++, this)) {
|
|
99
99
|
return true;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -119,7 +119,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|
|
119
119
|
let index = 0;
|
|
120
120
|
for (const item of this) {
|
|
121
121
|
const [key, value] = item;
|
|
122
|
-
callbackfn.call(thisArg,
|
|
122
|
+
callbackfn.call(thisArg, key, value, index++, this);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -144,7 +144,7 @@ export abstract class IterableEntryBase<K = any, V = any> {
|
|
|
144
144
|
let index = 0;
|
|
145
145
|
for (const item of this) {
|
|
146
146
|
const [key, value] = item;
|
|
147
|
-
if (callbackfn.call(thisArg,
|
|
147
|
+
if (callbackfn.call(thisArg, key, value, index++, this)) return item;
|
|
148
148
|
}
|
|
149
149
|
return;
|
|
150
150
|
}
|