data-structure-typed 1.46.3 → 1.46.5
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 +47 -61
- package/benchmark/report.html +1 -1
- package/benchmark/report.json +5 -17
- package/dist/cjs/data-structures/hash/hash-map.d.ts +22 -26
- package/dist/cjs/data-structures/hash/hash-map.js +104 -76
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/index.d.ts +0 -4
- package/dist/cjs/data-structures/hash/index.js +0 -4
- package/dist/cjs/data-structures/hash/index.js.map +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +5 -0
- package/dist/cjs/types/data-structures/hash/index.d.ts +0 -4
- package/dist/cjs/types/data-structures/hash/index.js +0 -4
- package/dist/cjs/types/data-structures/hash/index.js.map +1 -1
- package/dist/cjs/utils/utils.d.ts +1 -1
- package/dist/cjs/utils/utils.js +3 -3
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +22 -26
- package/dist/mjs/data-structures/hash/hash-map.js +107 -77
- package/dist/mjs/data-structures/hash/index.d.ts +0 -4
- package/dist/mjs/data-structures/hash/index.js +0 -4
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +5 -0
- package/dist/mjs/types/data-structures/hash/index.d.ts +0 -4
- package/dist/mjs/types/data-structures/hash/index.js +0 -4
- package/dist/mjs/utils/utils.d.ts +1 -1
- package/dist/mjs/utils/utils.js +1 -1
- package/dist/umd/data-structure-typed.js +96 -182
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/hash/hash-map.ts +130 -81
- package/src/data-structures/hash/index.ts +0 -4
- package/src/types/data-structures/hash/hash-map.ts +6 -0
- package/src/types/data-structures/hash/index.ts +0 -4
- package/src/utils/utils.ts +1 -1
- package/test/performance/data-structures/hash/hash-map.test.ts +75 -0
- package/test/unit/data-structures/hash/hash-map.test.ts +32 -0
- package/dist/cjs/data-structures/hash/coordinate-map.d.ts +0 -44
- package/dist/cjs/data-structures/hash/coordinate-map.js +0 -63
- package/dist/cjs/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/coordinate-set.d.ts +0 -36
- package/dist/cjs/data-structures/hash/coordinate-set.js +0 -53
- package/dist/cjs/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/data-structures/hash/tree-map.d.ts +0 -2
- package/dist/cjs/data-structures/hash/tree-map.js +0 -7
- package/dist/cjs/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/data-structures/hash/tree-set.d.ts +0 -2
- package/dist/cjs/data-structures/hash/tree-set.js +0 -7
- package/dist/cjs/data-structures/hash/tree-set.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-map.d.ts +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-map.js +0 -3
- package/dist/cjs/types/data-structures/hash/coordinate-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-set.d.ts +0 -1
- package/dist/cjs/types/data-structures/hash/coordinate-set.js +0 -3
- package/dist/cjs/types/data-structures/hash/coordinate-set.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/tree-map.d.ts +0 -1
- package/dist/cjs/types/data-structures/hash/tree-map.js +0 -3
- package/dist/cjs/types/data-structures/hash/tree-map.js.map +0 -1
- package/dist/cjs/types/data-structures/hash/tree-set.d.ts +0 -1
- package/dist/cjs/types/data-structures/hash/tree-set.js +0 -3
- package/dist/cjs/types/data-structures/hash/tree-set.js.map +0 -1
- package/dist/mjs/data-structures/hash/coordinate-map.d.ts +0 -44
- package/dist/mjs/data-structures/hash/coordinate-map.js +0 -58
- package/dist/mjs/data-structures/hash/coordinate-set.d.ts +0 -36
- package/dist/mjs/data-structures/hash/coordinate-set.js +0 -48
- package/dist/mjs/data-structures/hash/tree-map.d.ts +0 -2
- package/dist/mjs/data-structures/hash/tree-map.js +0 -2
- package/dist/mjs/data-structures/hash/tree-set.d.ts +0 -2
- package/dist/mjs/data-structures/hash/tree-set.js +0 -2
- package/dist/mjs/types/data-structures/hash/coordinate-map.d.ts +0 -1
- package/dist/mjs/types/data-structures/hash/coordinate-map.js +0 -1
- package/dist/mjs/types/data-structures/hash/coordinate-set.d.ts +0 -1
- package/dist/mjs/types/data-structures/hash/coordinate-set.js +0 -1
- package/dist/mjs/types/data-structures/hash/tree-map.d.ts +0 -1
- package/dist/mjs/types/data-structures/hash/tree-map.js +0 -1
- package/dist/mjs/types/data-structures/hash/tree-set.d.ts +0 -1
- package/dist/mjs/types/data-structures/hash/tree-set.js +0 -1
- package/src/data-structures/hash/coordinate-map.ts +0 -63
- package/src/data-structures/hash/coordinate-set.ts +0 -52
- package/src/data-structures/hash/tree-map.ts +0 -2
- package/src/data-structures/hash/tree-set.ts +0 -2
- package/src/types/data-structures/hash/coordinate-map.ts +0 -1
- package/src/types/data-structures/hash/coordinate-set.ts +0 -1
- package/src/types/data-structures/hash/tree-map.ts +0 -1
- package/src/types/data-structures/hash/tree-set.ts +0 -1
- package/test/performance/data-structures/hash/coordinate-map.test.ts +0 -0
- package/test/performance/data-structures/hash/coordinate-set.test.ts +0 -0
- package/test/unit/data-structures/hash/coordinate-map.test.ts +0 -74
- package/test/unit/data-structures/hash/coordinate-set.test.ts +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
|
9
9
|
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
|
|
10
10
|
|
|
11
|
-
## [v1.46.
|
|
11
|
+
## [v1.46.5](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
|
|
12
12
|
|
|
13
13
|
### Changes
|
|
14
14
|
|
package/README.md
CHANGED
|
@@ -71,54 +71,6 @@ const {
|
|
|
71
71
|
} = dataStructureTyped;
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
## Software Engineering Design Standards
|
|
75
|
-
<table>
|
|
76
|
-
<tr>
|
|
77
|
-
<th>Principle</th>
|
|
78
|
-
<th>Description</th>
|
|
79
|
-
</tr>
|
|
80
|
-
<tr>
|
|
81
|
-
<td>Practicality</td>
|
|
82
|
-
<td>Follows ES6 and ESNext standards, offering unified and considerate optional parameters, and simplifies method names.</td>
|
|
83
|
-
</tr>
|
|
84
|
-
<tr>
|
|
85
|
-
<td>Extensibility</td>
|
|
86
|
-
<td>Adheres to OOP (Object-Oriented Programming) principles, allowing inheritance for all data structures.</td>
|
|
87
|
-
</tr>
|
|
88
|
-
<tr>
|
|
89
|
-
<td>Modularization</td>
|
|
90
|
-
<td>Includes data structure modularization and independent NPM packages.</td>
|
|
91
|
-
</tr>
|
|
92
|
-
<tr>
|
|
93
|
-
<td>Efficiency</td>
|
|
94
|
-
<td>All methods provide time and space complexity, comparable to native JS performance.</td>
|
|
95
|
-
</tr>
|
|
96
|
-
<tr>
|
|
97
|
-
<td>Maintainability</td>
|
|
98
|
-
<td>Follows open-source community development standards, complete documentation, continuous integration, and adheres to TDD (Test-Driven Development) patterns.</td>
|
|
99
|
-
</tr>
|
|
100
|
-
<tr>
|
|
101
|
-
<td>Testability</td>
|
|
102
|
-
<td>Automated and customized unit testing, performance testing, and integration testing.</td>
|
|
103
|
-
</tr>
|
|
104
|
-
<tr>
|
|
105
|
-
<td>Portability</td>
|
|
106
|
-
<td>Plans for porting to Java, Python, and C++, currently achieved to 80%.</td>
|
|
107
|
-
</tr>
|
|
108
|
-
<tr>
|
|
109
|
-
<td>Reusability</td>
|
|
110
|
-
<td>Fully decoupled, minimized side effects, and adheres to OOP.</td>
|
|
111
|
-
</tr>
|
|
112
|
-
<tr>
|
|
113
|
-
<td>Security</td>
|
|
114
|
-
<td>Carefully designed security for member variables and methods. Read-write separation. Data structure software does not need to consider other security aspects.</td>
|
|
115
|
-
</tr>
|
|
116
|
-
<tr>
|
|
117
|
-
<td>Scalability</td>
|
|
118
|
-
<td>Data structure software does not involve load issues.</td>
|
|
119
|
-
</tr>
|
|
120
|
-
</table>
|
|
121
|
-
|
|
122
74
|
## Vivid Examples
|
|
123
75
|
|
|
124
76
|
### Binary Tree
|
|
@@ -859,16 +811,50 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', '
|
|
|
859
811
|
[//]: # (No deletion!!! End of Replace Section)
|
|
860
812
|
|
|
861
813
|
|
|
862
|
-
##
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
814
|
+
## Software Engineering Design Standards
|
|
815
|
+
<table>
|
|
816
|
+
<tr>
|
|
817
|
+
<th>Principle</th>
|
|
818
|
+
<th>Description</th>
|
|
819
|
+
</tr>
|
|
820
|
+
<tr>
|
|
821
|
+
<td>Practicality</td>
|
|
822
|
+
<td>Follows ES6 and ESNext standards, offering unified and considerate optional parameters, and simplifies method names.</td>
|
|
823
|
+
</tr>
|
|
824
|
+
<tr>
|
|
825
|
+
<td>Extensibility</td>
|
|
826
|
+
<td>Adheres to OOP (Object-Oriented Programming) principles, allowing inheritance for all data structures.</td>
|
|
827
|
+
</tr>
|
|
828
|
+
<tr>
|
|
829
|
+
<td>Modularization</td>
|
|
830
|
+
<td>Includes data structure modularization and independent NPM packages.</td>
|
|
831
|
+
</tr>
|
|
832
|
+
<tr>
|
|
833
|
+
<td>Efficiency</td>
|
|
834
|
+
<td>All methods provide time and space complexity, comparable to native JS performance.</td>
|
|
835
|
+
</tr>
|
|
836
|
+
<tr>
|
|
837
|
+
<td>Maintainability</td>
|
|
838
|
+
<td>Follows open-source community development standards, complete documentation, continuous integration, and adheres to TDD (Test-Driven Development) patterns.</td>
|
|
839
|
+
</tr>
|
|
840
|
+
<tr>
|
|
841
|
+
<td>Testability</td>
|
|
842
|
+
<td>Automated and customized unit testing, performance testing, and integration testing.</td>
|
|
843
|
+
</tr>
|
|
844
|
+
<tr>
|
|
845
|
+
<td>Portability</td>
|
|
846
|
+
<td>Plans for porting to Java, Python, and C++, currently achieved to 80%.</td>
|
|
847
|
+
</tr>
|
|
848
|
+
<tr>
|
|
849
|
+
<td>Reusability</td>
|
|
850
|
+
<td>Fully decoupled, minimized side effects, and adheres to OOP.</td>
|
|
851
|
+
</tr>
|
|
852
|
+
<tr>
|
|
853
|
+
<td>Security</td>
|
|
854
|
+
<td>Carefully designed security for member variables and methods. Read-write separation. Data structure software does not need to consider other security aspects.</td>
|
|
855
|
+
</tr>
|
|
856
|
+
<tr>
|
|
857
|
+
<td>Scalability</td>
|
|
858
|
+
<td>Data structure software does not involve load issues.</td>
|
|
859
|
+
</tr>
|
|
860
|
+
</table>
|
package/benchmark/report.html
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<body>
|
|
44
44
|
<div id="json-to-html"><div class="json-to-html-collapse clearfix 0">
|
|
45
45
|
<div class='collapsible level0' ><span class='json-to-html-label'>hash-map</span></div>
|
|
46
|
-
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>
|
|
46
|
+
<div class="content"><table style="display: table; width:100%; table-layout: fixed;"><tr><th>test name</th><th>time taken (ms)</th><th>executions per sec</th><th>sample deviation</th></tr><tr><td>1,000,000 set</td><td>217.67</td><td>4.59</td><td>0.02</td></tr><tr><td>1,000,000 CPT set</td><td>176.11</td><td>5.68</td><td>0.03</td></tr></table></div>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
49
|
</div>
|
package/benchmark/report.json
CHANGED
|
@@ -3,27 +3,15 @@
|
|
|
3
3
|
"benchmarks": [
|
|
4
4
|
{
|
|
5
5
|
"test name": "1,000,000 set",
|
|
6
|
-
"time taken (ms)": "
|
|
7
|
-
"executions per sec": "
|
|
6
|
+
"time taken (ms)": "217.67",
|
|
7
|
+
"executions per sec": "4.59",
|
|
8
8
|
"sample deviation": "0.02"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"test name": "1,000,000 CPT set",
|
|
12
|
-
"time taken (ms)": "
|
|
13
|
-
"executions per sec": "5.
|
|
14
|
-
"sample deviation": "0.
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"test name": "1,000,000 set & get",
|
|
18
|
-
"time taken (ms)": "182.19",
|
|
19
|
-
"executions per sec": "5.49",
|
|
20
|
-
"sample deviation": "0.02"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"test name": "1,000,000 CPT set & get",
|
|
24
|
-
"time taken (ms)": "175.65",
|
|
25
|
-
"executions per sec": "5.69",
|
|
26
|
-
"sample deviation": "0.02"
|
|
12
|
+
"time taken (ms)": "176.11",
|
|
13
|
+
"executions per sec": "5.68",
|
|
14
|
+
"sample deviation": "0.03"
|
|
27
15
|
}
|
|
28
16
|
],
|
|
29
17
|
"testName": "hash-map"
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { HashMapLinkedNode,
|
|
8
|
+
import { HashMapLinkedNode, HashMapOptions } from '../../types';
|
|
9
9
|
export declare class HashMap<K = any, V = any> {
|
|
10
|
-
|
|
11
|
-
protected
|
|
12
|
-
protected
|
|
13
|
-
protected
|
|
14
|
-
protected
|
|
15
|
-
protected
|
|
10
|
+
protected _noObjMap: Record<string, HashMapLinkedNode<K, V | undefined>>;
|
|
11
|
+
protected _objMap: WeakMap<object, HashMapLinkedNode<K, V | undefined>>;
|
|
12
|
+
protected _head: HashMapLinkedNode<K, V | undefined>;
|
|
13
|
+
protected _tail: HashMapLinkedNode<K, V | undefined>;
|
|
14
|
+
protected readonly _sentinel: HashMapLinkedNode<K, V | undefined>;
|
|
15
|
+
protected _hashFn: (key: K) => string;
|
|
16
|
+
protected _objHashFn: (key: K) => object;
|
|
16
17
|
/**
|
|
17
|
-
* The constructor initializes a
|
|
18
|
-
* @param
|
|
19
|
-
*
|
|
20
|
-
* `K` represents the type of the key and `V` represents the
|
|
18
|
+
* The constructor initializes a HashMapLinkedNode with an optional iterable of key-value pairs.
|
|
19
|
+
* @param options - The `options` parameter is an object that contains the `elements` property. The
|
|
20
|
+
* `elements` property is an iterable that contains key-value pairs represented as arrays `[K, V]`.
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(options?: HashMapOptions<K, V>);
|
|
23
23
|
protected _size: number;
|
|
24
24
|
get size(): number;
|
|
25
25
|
/**
|
|
@@ -43,12 +43,12 @@ export declare class HashMap<K = any, V = any> {
|
|
|
43
43
|
/**
|
|
44
44
|
* The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
|
|
45
45
|
*/
|
|
46
|
-
begin(): Generator<(K | V)[], void, unknown>;
|
|
46
|
+
begin(): Generator<(K | V | undefined)[], void, unknown>;
|
|
47
47
|
/**
|
|
48
48
|
* The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
|
|
49
49
|
* key and value.
|
|
50
50
|
*/
|
|
51
|
-
reverseBegin(): Generator<(K | V)[], void, unknown>;
|
|
51
|
+
reverseBegin(): Generator<(K | V | undefined)[], void, unknown>;
|
|
52
52
|
/**
|
|
53
53
|
* Time Complexity: O(1)
|
|
54
54
|
* Space Complexity: O(1)
|
|
@@ -59,10 +59,9 @@ export declare class HashMap<K = any, V = any> {
|
|
|
59
59
|
* type, but typically it is a string or symbol.
|
|
60
60
|
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
|
|
61
61
|
* value associated with the key being set in the data structure.
|
|
62
|
-
* @param {boolean} isObjectKey - A boolean flag indicating whether the key is an object key or not.
|
|
63
62
|
* @returns the size of the data structure after the key-value pair has been set.
|
|
64
63
|
*/
|
|
65
|
-
set(key: K, value?: V
|
|
64
|
+
set(key: K, value?: V): number;
|
|
66
65
|
/**
|
|
67
66
|
* Time Complexity: O(1)
|
|
68
67
|
* Space Complexity: O(1)
|
|
@@ -71,15 +70,12 @@ export declare class HashMap<K = any, V = any> {
|
|
|
71
70
|
* key directly or by using an index stored in the key object.
|
|
72
71
|
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
73
72
|
* of any type, but typically it is a string or symbol.
|
|
74
|
-
* @param {boolean} isObjectKey - The `isObjectKey` parameter is a boolean flag that indicates
|
|
75
|
-
* whether the `key` parameter is an object key or not. If `isObjectKey` is `true`, it means that
|
|
76
|
-
* `key` is an object key. If `isObjectKey` is `false`, it means that `key`
|
|
77
73
|
* @returns The value associated with the given key is being returned. If the key is an object key,
|
|
78
74
|
* the value is retrieved from the `_nodes` array using the index stored in the `OBJ_KEY_INDEX`
|
|
79
|
-
* property of the key. If the key is a string key, the value is retrieved from the `
|
|
75
|
+
* property of the key. If the key is a string key, the value is retrieved from the `_noObjMap` object
|
|
80
76
|
* using the key itself. If the key is not found, `undefined` is
|
|
81
77
|
*/
|
|
82
|
-
get(key: K
|
|
78
|
+
get(key: K): V | undefined;
|
|
83
79
|
/**
|
|
84
80
|
* Time Complexity: O(n), where n is the index.
|
|
85
81
|
* Space Complexity: O(1)
|
|
@@ -99,13 +95,10 @@ export declare class HashMap<K = any, V = any> {
|
|
|
99
95
|
* The `delete` function removes a key-value pair from a map-like data structure.
|
|
100
96
|
* @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
|
|
101
97
|
* It can be of any type, but typically it is a string or an object.
|
|
102
|
-
* @param {boolean} isObjectKey - The `isObjectKey` parameter is a boolean flag that indicates
|
|
103
|
-
* whether the `key` parameter is an object key or not. If `isObjectKey` is `true`, it means that the
|
|
104
|
-
* `key` parameter is an object key. If `isObjectKey` is `false`, it means that the
|
|
105
98
|
* @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
|
|
106
99
|
* was not found.
|
|
107
100
|
*/
|
|
108
|
-
delete(key: K
|
|
101
|
+
delete(key: K): boolean;
|
|
109
102
|
/**
|
|
110
103
|
* Time Complexity: O(n), where n is the index.
|
|
111
104
|
* Space Complexity: O(1)
|
|
@@ -142,6 +135,9 @@ export declare class HashMap<K = any, V = any> {
|
|
|
142
135
|
* HashMap. It takes three arguments:
|
|
143
136
|
*/
|
|
144
137
|
forEach(callback: (element: [K, V], index: number, hashMap: HashMap<K, V>) => void): void;
|
|
138
|
+
filter(predicate: (element: [K, V], map: HashMap<K, V>) => boolean): HashMap<K, V>;
|
|
139
|
+
map<NV>(callback: (element: [K, V], map: HashMap<K, V>) => NV): HashMap<K, NV>;
|
|
140
|
+
reduce<A>(callback: (accumulator: A, element: [K, V], map: HashMap<K, V>) => A, initialValue: A): A;
|
|
145
141
|
/**
|
|
146
142
|
* Time Complexity: O(n), where n is the number of elements in the HashMap.
|
|
147
143
|
* Space Complexity: O(1)
|
|
@@ -159,5 +155,5 @@ export declare class HashMap<K = any, V = any> {
|
|
|
159
155
|
* represents a node in a linked list. It contains a key-value pair and references to the previous
|
|
160
156
|
* and next nodes in the list.
|
|
161
157
|
*/
|
|
162
|
-
protected _deleteNode(node: HashMapLinkedNode<K, V>): void;
|
|
158
|
+
protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): void;
|
|
163
159
|
}
|
|
@@ -11,21 +11,27 @@ exports.HashMap = void 0;
|
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
12
|
class HashMap {
|
|
13
13
|
/**
|
|
14
|
-
* The constructor initializes a
|
|
15
|
-
* @param
|
|
16
|
-
*
|
|
17
|
-
* `K` represents the type of the key and `V` represents the
|
|
14
|
+
* The constructor initializes a HashMapLinkedNode with an optional iterable of key-value pairs.
|
|
15
|
+
* @param options - The `options` parameter is an object that contains the `elements` property. The
|
|
16
|
+
* `elements` property is an iterable that contains key-value pairs represented as arrays `[K, V]`.
|
|
18
17
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
constructor(options = {
|
|
19
|
+
elements: [],
|
|
20
|
+
hashFn: (key) => String(key),
|
|
21
|
+
objHashFn: (key) => key
|
|
22
|
+
}) {
|
|
23
|
+
this._noObjMap = {};
|
|
24
|
+
this._objMap = new WeakMap();
|
|
23
25
|
this._size = 0;
|
|
24
|
-
Object.setPrototypeOf(this._orgMap, null);
|
|
25
26
|
this._sentinel = {};
|
|
26
27
|
this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const { elements, hashFn, objHashFn } = options;
|
|
29
|
+
this._hashFn = hashFn;
|
|
30
|
+
this._objHashFn = objHashFn;
|
|
31
|
+
if (elements) {
|
|
32
|
+
for (const el of elements) {
|
|
33
|
+
this.set(el[0], el[1]);
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
get size() {
|
|
@@ -88,52 +94,51 @@ class HashMap {
|
|
|
88
94
|
* type, but typically it is a string or symbol.
|
|
89
95
|
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
|
|
90
96
|
* value associated with the key being set in the data structure.
|
|
91
|
-
* @param {boolean} isObjectKey - A boolean flag indicating whether the key is an object key or not.
|
|
92
97
|
* @returns the size of the data structure after the key-value pair has been set.
|
|
93
98
|
*/
|
|
94
|
-
set(key, value
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
set(key, value) {
|
|
100
|
+
let node;
|
|
101
|
+
if ((0, utils_1.isWeakKey)(key)) {
|
|
102
|
+
const hash = this._objHashFn(key);
|
|
103
|
+
node = this._objMap.get(hash);
|
|
104
|
+
if (node) {
|
|
105
|
+
// If the node already exists, update its value
|
|
106
|
+
node.value = value;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Create new node
|
|
110
|
+
node = { key: hash, value, prev: this._tail, next: this._sentinel };
|
|
111
|
+
// Add new nodes to _objMap and linked list
|
|
112
|
+
this._objMap.set(hash, node);
|
|
101
113
|
}
|
|
102
|
-
Object.defineProperty(key, this.OBJ_KEY_INDEX, {
|
|
103
|
-
value: this._nodes.length,
|
|
104
|
-
configurable: true
|
|
105
|
-
});
|
|
106
|
-
newTail = {
|
|
107
|
-
key: key,
|
|
108
|
-
value: value,
|
|
109
|
-
prev: this._tail,
|
|
110
|
-
next: this._sentinel
|
|
111
|
-
};
|
|
112
|
-
this._nodes.push(newTail);
|
|
113
114
|
}
|
|
114
115
|
else {
|
|
115
|
-
const
|
|
116
|
+
const hash = this._hashFn(key);
|
|
117
|
+
// Non-object keys are handled in the same way as the original implementation
|
|
118
|
+
node = this._noObjMap[hash];
|
|
116
119
|
if (node) {
|
|
117
120
|
node.value = value;
|
|
118
|
-
return this._size;
|
|
119
121
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
else {
|
|
123
|
+
this._noObjMap[hash] = node = {
|
|
124
|
+
key,
|
|
125
|
+
value,
|
|
126
|
+
prev: this._tail,
|
|
127
|
+
next: this._sentinel
|
|
128
|
+
};
|
|
129
|
+
}
|
|
126
130
|
}
|
|
127
131
|
if (this._size === 0) {
|
|
128
|
-
this._head =
|
|
129
|
-
this._sentinel.next =
|
|
132
|
+
this._head = node;
|
|
133
|
+
this._sentinel.next = node;
|
|
130
134
|
}
|
|
131
135
|
else {
|
|
132
|
-
this._tail.next =
|
|
136
|
+
this._tail.next = node;
|
|
133
137
|
}
|
|
134
|
-
this._tail =
|
|
135
|
-
this._sentinel.prev =
|
|
136
|
-
|
|
138
|
+
this._tail = node;
|
|
139
|
+
this._sentinel.prev = node;
|
|
140
|
+
this._size++;
|
|
141
|
+
return this._size;
|
|
137
142
|
}
|
|
138
143
|
/**
|
|
139
144
|
* Time Complexity: O(1)
|
|
@@ -143,21 +148,22 @@ class HashMap {
|
|
|
143
148
|
* key directly or by using an index stored in the key object.
|
|
144
149
|
* @param {K} key - The `key` parameter is the key used to retrieve a value from the map. It can be
|
|
145
150
|
* of any type, but typically it is a string or symbol.
|
|
146
|
-
* @param {boolean} isObjectKey - The `isObjectKey` parameter is a boolean flag that indicates
|
|
147
|
-
* whether the `key` parameter is an object key or not. If `isObjectKey` is `true`, it means that
|
|
148
|
-
* `key` is an object key. If `isObjectKey` is `false`, it means that `key`
|
|
149
151
|
* @returns The value associated with the given key is being returned. If the key is an object key,
|
|
150
152
|
* the value is retrieved from the `_nodes` array using the index stored in the `OBJ_KEY_INDEX`
|
|
151
|
-
* property of the key. If the key is a string key, the value is retrieved from the `
|
|
153
|
+
* property of the key. If the key is a string key, the value is retrieved from the `_noObjMap` object
|
|
152
154
|
* using the key itself. If the key is not found, `undefined` is
|
|
153
155
|
*/
|
|
154
|
-
get(key
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
156
|
+
get(key) {
|
|
157
|
+
if ((0, utils_1.isWeakKey)(key)) {
|
|
158
|
+
const hash = this._objHashFn(key);
|
|
159
|
+
const node = this._objMap.get(hash);
|
|
160
|
+
return node ? node.value : undefined;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const hash = this._hashFn(key);
|
|
164
|
+
const node = this._noObjMap[hash];
|
|
165
|
+
return node ? node.value : undefined;
|
|
158
166
|
}
|
|
159
|
-
const node = this._orgMap[key];
|
|
160
|
-
return node ? node.value : undefined;
|
|
161
167
|
}
|
|
162
168
|
/**
|
|
163
169
|
* Time Complexity: O(n), where n is the index.
|
|
@@ -185,28 +191,32 @@ class HashMap {
|
|
|
185
191
|
* The `delete` function removes a key-value pair from a map-like data structure.
|
|
186
192
|
* @param {K} key - The `key` parameter is the key that you want to delete from the data structure.
|
|
187
193
|
* It can be of any type, but typically it is a string or an object.
|
|
188
|
-
* @param {boolean} isObjectKey - The `isObjectKey` parameter is a boolean flag that indicates
|
|
189
|
-
* whether the `key` parameter is an object key or not. If `isObjectKey` is `true`, it means that the
|
|
190
|
-
* `key` parameter is an object key. If `isObjectKey` is `false`, it means that the
|
|
191
194
|
* @returns a boolean value. It returns `true` if the deletion was successful, and `false` if the key
|
|
192
195
|
* was not found.
|
|
193
196
|
*/
|
|
194
|
-
delete(key
|
|
197
|
+
delete(key) {
|
|
195
198
|
let node;
|
|
196
|
-
if (
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
if ((0, utils_1.isWeakKey)(key)) {
|
|
200
|
+
const hash = this._objHashFn(key);
|
|
201
|
+
// Get nodes from WeakMap
|
|
202
|
+
node = this._objMap.get(hash);
|
|
203
|
+
if (!node) {
|
|
204
|
+
return false; // If the node does not exist, return false
|
|
205
|
+
}
|
|
206
|
+
// Remove nodes from WeakMap
|
|
207
|
+
this._objMap.delete(hash);
|
|
203
208
|
}
|
|
204
209
|
else {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
const hash = this._hashFn(key);
|
|
211
|
+
// Get nodes from noObjMap
|
|
212
|
+
node = this._noObjMap[hash];
|
|
213
|
+
if (!node) {
|
|
214
|
+
return false; // If the node does not exist, return false
|
|
215
|
+
}
|
|
216
|
+
// Remove nodes from orgMap
|
|
217
|
+
delete this._noObjMap[hash];
|
|
209
218
|
}
|
|
219
|
+
// Remove node from doubly linked list
|
|
210
220
|
this._deleteNode(node);
|
|
211
221
|
return true;
|
|
212
222
|
}
|
|
@@ -246,13 +256,7 @@ class HashMap {
|
|
|
246
256
|
* The `clear` function clears all the elements in a data structure and resets its properties.
|
|
247
257
|
*/
|
|
248
258
|
clear() {
|
|
249
|
-
|
|
250
|
-
// this._nodes.forEach(el => {
|
|
251
|
-
// delete (<Record<symbol, number>><unknown>el.key)[OBJ_KEY_INDEX];
|
|
252
|
-
// });
|
|
253
|
-
this._nodes = [];
|
|
254
|
-
this._orgMap = {};
|
|
255
|
-
Object.setPrototypeOf(this._orgMap, null);
|
|
259
|
+
this._noObjMap = {};
|
|
256
260
|
this._size = 0;
|
|
257
261
|
this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
|
|
258
262
|
}
|
|
@@ -273,6 +277,30 @@ class HashMap {
|
|
|
273
277
|
node = node.next;
|
|
274
278
|
}
|
|
275
279
|
}
|
|
280
|
+
filter(predicate) {
|
|
281
|
+
const filteredMap = new HashMap();
|
|
282
|
+
for (const [key, value] of this) {
|
|
283
|
+
if (predicate([key, value], this)) {
|
|
284
|
+
filteredMap.set(key, value);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return filteredMap;
|
|
288
|
+
}
|
|
289
|
+
map(callback) {
|
|
290
|
+
const mappedMap = new HashMap();
|
|
291
|
+
for (const [key, value] of this) {
|
|
292
|
+
const newValue = callback([key, value], this);
|
|
293
|
+
mappedMap.set(key, newValue);
|
|
294
|
+
}
|
|
295
|
+
return mappedMap;
|
|
296
|
+
}
|
|
297
|
+
reduce(callback, initialValue) {
|
|
298
|
+
let accumulator = initialValue;
|
|
299
|
+
for (const element of this) {
|
|
300
|
+
accumulator = callback(accumulator, element, this);
|
|
301
|
+
}
|
|
302
|
+
return accumulator;
|
|
303
|
+
}
|
|
276
304
|
/**
|
|
277
305
|
* Time Complexity: O(n), where n is the number of elements in the HashMap.
|
|
278
306
|
* Space Complexity: O(1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,
|
|
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,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AAK,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;AA1WD,0BA0WC"}
|
|
@@ -15,9 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./hash-table"), exports);
|
|
18
|
-
__exportStar(require("./coordinate-map"), exports);
|
|
19
|
-
__exportStar(require("./coordinate-set"), exports);
|
|
20
|
-
__exportStar(require("./tree-map"), exports);
|
|
21
|
-
__exportStar(require("./tree-set"), exports);
|
|
22
18
|
__exportStar(require("./hash-map"), exports);
|
|
23
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,6CAA2B"}
|
|
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./coordinate-map"), exports);
|
|
18
|
-
__exportStar(require("./coordinate-set"), exports);
|
|
19
17
|
__exportStar(require("./hash-map"), exports);
|
|
20
18
|
__exportStar(require("./hash-table"), exports);
|
|
21
|
-
__exportStar(require("./tree-map"), exports);
|
|
22
|
-
__exportStar(require("./tree-set"), exports);
|
|
23
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/hash/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B"}
|
|
@@ -20,5 +20,5 @@ export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Paramet
|
|
|
20
20
|
export declare const getMSB: (value: number) => number;
|
|
21
21
|
export declare const rangeCheck: (index: number, min: number, max: number, message?: string) => void;
|
|
22
22
|
export declare const throwRangeError: (message?: string) => void;
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const isWeakKey: (input: unknown) => input is object;
|
|
24
24
|
export declare const calcMinUnitsRequired: (totalQuantity: number, unitSize: number) => number;
|