data-structure-typed 1.47.0 → 1.47.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 +1 -1
- package/README.md +140 -203
- package/dist/cjs/data-structures/hash/hash-map.d.ts +27 -0
- package/dist/cjs/data-structures/hash/hash-map.js +27 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +27 -0
- package/dist/mjs/data-structures/hash/hash-map.js +27 -0
- package/dist/umd/data-structure-typed.js +27 -0
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/data-structures/hash/hash-map.ts +27 -0
- package/test/integration/index.html +74 -1
|
@@ -135,8 +135,35 @@ export declare class HashMap<K = any, V = any> {
|
|
|
135
135
|
* HashMap. It takes three arguments:
|
|
136
136
|
*/
|
|
137
137
|
forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
|
|
138
|
+
/**
|
|
139
|
+
* The `filter` function takes a predicate function and returns a new HashMap containing only the
|
|
140
|
+
* key-value pairs that satisfy the predicate.
|
|
141
|
+
* @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
|
|
142
|
+
* `map`.
|
|
143
|
+
* @returns a new HashMap object that contains the key-value pairs from the original HashMap that
|
|
144
|
+
* satisfy the given predicate function.
|
|
145
|
+
*/
|
|
138
146
|
filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V>;
|
|
147
|
+
/**
|
|
148
|
+
* The `map` function takes a callback function and returns a new HashMap with the values transformed
|
|
149
|
+
* by the callback.
|
|
150
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `element` and
|
|
151
|
+
* `map`.
|
|
152
|
+
* @returns a new HashMap object with the values mapped according to the provided callback function.
|
|
153
|
+
*/
|
|
139
154
|
map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV>;
|
|
155
|
+
/**
|
|
156
|
+
* The `reduce` function iterates over the elements of a HashMap and applies a callback function to
|
|
157
|
+
* each element, accumulating a single value.
|
|
158
|
+
* @param callback - The callback parameter is a function that takes three arguments: accumulator,
|
|
159
|
+
* element, and map. It is called for each element in the HashMap and is used to accumulate a single
|
|
160
|
+
* result.
|
|
161
|
+
* @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
|
|
162
|
+
* is the value that will be passed as the first argument to the `callback` function when reducing
|
|
163
|
+
* the elements of the map.
|
|
164
|
+
* @returns The `reduce` function is returning the final value of the accumulator after iterating
|
|
165
|
+
* over all the elements in the HashMap and applying the callback function to each element.
|
|
166
|
+
*/
|
|
140
167
|
reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A;
|
|
141
168
|
/**
|
|
142
169
|
* Time Complexity: O(n), where n is the number of elements in the HashMap.
|
|
@@ -277,6 +277,14 @@ class HashMap {
|
|
|
277
277
|
node = node.next;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The `filter` function takes a predicate function and returns a new HashMap containing only the
|
|
282
|
+
* key-value pairs that satisfy the predicate.
|
|
283
|
+
* @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
|
|
284
|
+
* `map`.
|
|
285
|
+
* @returns a new HashMap object that contains the key-value pairs from the original HashMap that
|
|
286
|
+
* satisfy the given predicate function.
|
|
287
|
+
*/
|
|
280
288
|
filter(predicate) {
|
|
281
289
|
const filteredMap = new HashMap();
|
|
282
290
|
for (const [key, value] of this) {
|
|
@@ -286,6 +294,13 @@ class HashMap {
|
|
|
286
294
|
}
|
|
287
295
|
return filteredMap;
|
|
288
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The `map` function takes a callback function and returns a new HashMap with the values transformed
|
|
299
|
+
* by the callback.
|
|
300
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `element` and
|
|
301
|
+
* `map`.
|
|
302
|
+
* @returns a new HashMap object with the values mapped according to the provided callback function.
|
|
303
|
+
*/
|
|
289
304
|
map(callback) {
|
|
290
305
|
const mappedMap = new HashMap();
|
|
291
306
|
for (const [key, value] of this) {
|
|
@@ -294,6 +309,18 @@ class HashMap {
|
|
|
294
309
|
}
|
|
295
310
|
return mappedMap;
|
|
296
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* The `reduce` function iterates over the elements of a HashMap and applies a callback function to
|
|
314
|
+
* each element, accumulating a single value.
|
|
315
|
+
* @param callback - The callback parameter is a function that takes three arguments: accumulator,
|
|
316
|
+
* element, and map. It is called for each element in the HashMap and is used to accumulate a single
|
|
317
|
+
* result.
|
|
318
|
+
* @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
|
|
319
|
+
* is the value that will be passed as the first argument to the `callback` function when reducing
|
|
320
|
+
* the elements of the map.
|
|
321
|
+
* @returns The `reduce` function is returning the final value of the accumulator after iterating
|
|
322
|
+
* over all the elements in the HashMap and applying the callback function to each element.
|
|
323
|
+
*/
|
|
297
324
|
reduce(callback, initialValue) {
|
|
298
325
|
let accumulator = initialValue;
|
|
299
326
|
for (const element of this) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAoD;AAGpD,MAAa,OAAO;IAUlB;;;;OAIG;IACH,YAAY,UAAgC;QAC1C,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,CAAC,GAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;QAC/B,SAAS,EAAE,CAAC,GAAM,EAAE,EAAE,CAAU,GAAI;KACrC;QAjBS,cAAS,GAAwD,EAAE,CAAC;QACpE,YAAO,GAAG,IAAI,OAAO,EAA+C,CAAC;QA+BrE,UAAK,GAAG,CAAC,CAAC;QAdlB,IAAI,CAAC,SAAS,GAA4B,EAAE,CA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;;OASG;IACO,WAAW,CAAC,IAAyC;QAC7D,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QAED,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AArYD,0BAqYC"}
|
|
@@ -135,8 +135,35 @@ export declare class HashMap<K = any, V = any> {
|
|
|
135
135
|
* HashMap. It takes three arguments:
|
|
136
136
|
*/
|
|
137
137
|
forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
|
|
138
|
+
/**
|
|
139
|
+
* The `filter` function takes a predicate function and returns a new HashMap containing only the
|
|
140
|
+
* key-value pairs that satisfy the predicate.
|
|
141
|
+
* @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
|
|
142
|
+
* `map`.
|
|
143
|
+
* @returns a new HashMap object that contains the key-value pairs from the original HashMap that
|
|
144
|
+
* satisfy the given predicate function.
|
|
145
|
+
*/
|
|
138
146
|
filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V>;
|
|
147
|
+
/**
|
|
148
|
+
* The `map` function takes a callback function and returns a new HashMap with the values transformed
|
|
149
|
+
* by the callback.
|
|
150
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `element` and
|
|
151
|
+
* `map`.
|
|
152
|
+
* @returns a new HashMap object with the values mapped according to the provided callback function.
|
|
153
|
+
*/
|
|
139
154
|
map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV>;
|
|
155
|
+
/**
|
|
156
|
+
* The `reduce` function iterates over the elements of a HashMap and applies a callback function to
|
|
157
|
+
* each element, accumulating a single value.
|
|
158
|
+
* @param callback - The callback parameter is a function that takes three arguments: accumulator,
|
|
159
|
+
* element, and map. It is called for each element in the HashMap and is used to accumulate a single
|
|
160
|
+
* result.
|
|
161
|
+
* @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
|
|
162
|
+
* is the value that will be passed as the first argument to the `callback` function when reducing
|
|
163
|
+
* the elements of the map.
|
|
164
|
+
* @returns The `reduce` function is returning the final value of the accumulator after iterating
|
|
165
|
+
* over all the elements in the HashMap and applying the callback function to each element.
|
|
166
|
+
*/
|
|
140
167
|
reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A;
|
|
141
168
|
/**
|
|
142
169
|
* Time Complexity: O(n), where n is the number of elements in the HashMap.
|
|
@@ -279,6 +279,14 @@ export class HashMap {
|
|
|
279
279
|
node = node.next;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* The `filter` function takes a predicate function and returns a new HashMap containing only the
|
|
284
|
+
* key-value pairs that satisfy the predicate.
|
|
285
|
+
* @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
|
|
286
|
+
* `map`.
|
|
287
|
+
* @returns a new HashMap object that contains the key-value pairs from the original HashMap that
|
|
288
|
+
* satisfy the given predicate function.
|
|
289
|
+
*/
|
|
282
290
|
filter(predicate) {
|
|
283
291
|
const filteredMap = new HashMap();
|
|
284
292
|
for (const [key, value] of this) {
|
|
@@ -288,6 +296,13 @@ export class HashMap {
|
|
|
288
296
|
}
|
|
289
297
|
return filteredMap;
|
|
290
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* The `map` function takes a callback function and returns a new HashMap with the values transformed
|
|
301
|
+
* by the callback.
|
|
302
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `element` and
|
|
303
|
+
* `map`.
|
|
304
|
+
* @returns a new HashMap object with the values mapped according to the provided callback function.
|
|
305
|
+
*/
|
|
291
306
|
map(callback) {
|
|
292
307
|
const mappedMap = new HashMap();
|
|
293
308
|
for (const [key, value] of this) {
|
|
@@ -296,6 +311,18 @@ export class HashMap {
|
|
|
296
311
|
}
|
|
297
312
|
return mappedMap;
|
|
298
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* The `reduce` function iterates over the elements of a HashMap and applies a callback function to
|
|
316
|
+
* each element, accumulating a single value.
|
|
317
|
+
* @param callback - The callback parameter is a function that takes three arguments: accumulator,
|
|
318
|
+
* element, and map. It is called for each element in the HashMap and is used to accumulate a single
|
|
319
|
+
* result.
|
|
320
|
+
* @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
|
|
321
|
+
* is the value that will be passed as the first argument to the `callback` function when reducing
|
|
322
|
+
* the elements of the map.
|
|
323
|
+
* @returns The `reduce` function is returning the final value of the accumulator after iterating
|
|
324
|
+
* over all the elements in the HashMap and applying the callback function to each element.
|
|
325
|
+
*/
|
|
299
326
|
reduce(callback, initialValue) {
|
|
300
327
|
let accumulator = initialValue;
|
|
301
328
|
for (const element of this) {
|
|
@@ -729,6 +729,14 @@ var dataStructureTyped = (() => {
|
|
|
729
729
|
node = node.next;
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* The `filter` function takes a predicate function and returns a new HashMap containing only the
|
|
734
|
+
* key-value pairs that satisfy the predicate.
|
|
735
|
+
* @param predicate - The `predicate` parameter is a function that takes two arguments: `element` and
|
|
736
|
+
* `map`.
|
|
737
|
+
* @returns a new HashMap object that contains the key-value pairs from the original HashMap that
|
|
738
|
+
* satisfy the given predicate function.
|
|
739
|
+
*/
|
|
732
740
|
filter(predicate) {
|
|
733
741
|
const filteredMap = new _HashMap();
|
|
734
742
|
for (const [key, value] of this) {
|
|
@@ -738,6 +746,13 @@ var dataStructureTyped = (() => {
|
|
|
738
746
|
}
|
|
739
747
|
return filteredMap;
|
|
740
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* The `map` function takes a callback function and returns a new HashMap with the values transformed
|
|
751
|
+
* by the callback.
|
|
752
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `element` and
|
|
753
|
+
* `map`.
|
|
754
|
+
* @returns a new HashMap object with the values mapped according to the provided callback function.
|
|
755
|
+
*/
|
|
741
756
|
map(callback) {
|
|
742
757
|
const mappedMap = new _HashMap();
|
|
743
758
|
for (const [key, value] of this) {
|
|
@@ -746,6 +761,18 @@ var dataStructureTyped = (() => {
|
|
|
746
761
|
}
|
|
747
762
|
return mappedMap;
|
|
748
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* The `reduce` function iterates over the elements of a HashMap and applies a callback function to
|
|
766
|
+
* each element, accumulating a single value.
|
|
767
|
+
* @param callback - The callback parameter is a function that takes three arguments: accumulator,
|
|
768
|
+
* element, and map. It is called for each element in the HashMap and is used to accumulate a single
|
|
769
|
+
* result.
|
|
770
|
+
* @param {A} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
|
|
771
|
+
* is the value that will be passed as the first argument to the `callback` function when reducing
|
|
772
|
+
* the elements of the map.
|
|
773
|
+
* @returns The `reduce` function is returning the final value of the accumulator after iterating
|
|
774
|
+
* over all the elements in the HashMap and applying the callback function to each element.
|
|
775
|
+
*/
|
|
749
776
|
reduce(callback, initialValue) {
|
|
750
777
|
let accumulator = initialValue;
|
|
751
778
|
for (const element of this) {
|