data-structure-typed 2.4.5 → 2.5.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.
Files changed (240) hide show
  1. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +12984 -0
  2. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +3 -0
  3. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +4505 -0
  4. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +9731 -0
  5. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +347 -0
  6. package/CHANGELOG.md +3 -1
  7. package/README.md +78 -31
  8. package/dist/cjs/binary-tree.cjs +23698 -0
  9. package/dist/cjs/graph.cjs +5236 -0
  10. package/dist/cjs/hash.cjs +1262 -0
  11. package/dist/cjs/heap.cjs +1540 -0
  12. package/dist/cjs/index.cjs +24509 -2899
  13. package/dist/cjs/linked-list.cjs +4370 -0
  14. package/dist/cjs/matrix.cjs +1042 -0
  15. package/dist/cjs/priority-queue.cjs +1314 -0
  16. package/dist/cjs/queue.cjs +4090 -0
  17. package/dist/cjs/stack.cjs +861 -0
  18. package/dist/cjs/trie.cjs +1173 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +23730 -0
  20. package/dist/cjs-legacy/graph.cjs +5234 -0
  21. package/dist/cjs-legacy/hash.cjs +1262 -0
  22. package/dist/cjs-legacy/heap.cjs +1537 -0
  23. package/dist/cjs-legacy/index.cjs +32555 -10936
  24. package/dist/cjs-legacy/linked-list.cjs +4376 -0
  25. package/dist/cjs-legacy/matrix.cjs +1045 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +1312 -0
  27. package/dist/cjs-legacy/queue.cjs +4088 -0
  28. package/dist/cjs-legacy/stack.cjs +861 -0
  29. package/dist/cjs-legacy/trie.cjs +1172 -0
  30. package/dist/esm/binary-tree.mjs +23683 -0
  31. package/dist/esm/graph.mjs +5223 -0
  32. package/dist/esm/hash.mjs +1259 -0
  33. package/dist/esm/heap.mjs +1534 -0
  34. package/dist/esm/index.mjs +24507 -2898
  35. package/dist/esm/linked-list.mjs +4363 -0
  36. package/dist/esm/matrix.mjs +1038 -0
  37. package/dist/esm/priority-queue.mjs +1310 -0
  38. package/dist/esm/queue.mjs +4086 -0
  39. package/dist/esm/stack.mjs +859 -0
  40. package/dist/esm/trie.mjs +1170 -0
  41. package/dist/esm-legacy/binary-tree.mjs +23715 -0
  42. package/dist/esm-legacy/graph.mjs +5221 -0
  43. package/dist/esm-legacy/hash.mjs +1259 -0
  44. package/dist/esm-legacy/heap.mjs +1531 -0
  45. package/dist/esm-legacy/index.mjs +32553 -10935
  46. package/dist/esm-legacy/linked-list.mjs +4369 -0
  47. package/dist/esm-legacy/matrix.mjs +1041 -0
  48. package/dist/esm-legacy/priority-queue.mjs +1308 -0
  49. package/dist/esm-legacy/queue.mjs +4084 -0
  50. package/dist/esm-legacy/stack.mjs +859 -0
  51. package/dist/esm-legacy/trie.mjs +1169 -0
  52. package/dist/types/data-structures/base/index.d.ts +1 -0
  53. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  54. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  55. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  56. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +368 -51
  57. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +473 -147
  58. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +931 -80
  59. package/dist/types/data-structures/binary-tree/bst.d.ts +792 -29
  60. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +592 -32
  61. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +320 -135
  62. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3662 -6
  63. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3487 -201
  64. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2778 -65
  65. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3414 -6
  66. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  67. package/dist/types/data-structures/graph/directed-graph.d.ts +419 -47
  68. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  69. package/dist/types/data-structures/graph/undirected-graph.d.ts +384 -59
  70. package/dist/types/data-structures/hash/hash-map.d.ts +462 -89
  71. package/dist/types/data-structures/heap/heap.d.ts +567 -99
  72. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  73. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  74. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +631 -49
  75. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +581 -68
  76. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +775 -12
  77. package/dist/types/data-structures/matrix/matrix.d.ts +491 -0
  78. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  79. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  80. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  81. package/dist/types/data-structures/queue/deque.d.ts +578 -71
  82. package/dist/types/data-structures/queue/queue.d.ts +451 -42
  83. package/dist/types/data-structures/stack/stack.d.ts +374 -32
  84. package/dist/types/data-structures/trie/trie.d.ts +458 -48
  85. package/dist/types/interfaces/graph.d.ts +1 -1
  86. package/dist/types/types/common.d.ts +2 -2
  87. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  88. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  89. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  90. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  91. package/dist/types/types/utils/validate-type.d.ts +4 -4
  92. package/dist/umd/data-structure-typed.js +32432 -10808
  93. package/dist/umd/data-structure-typed.min.js +10 -4
  94. package/docs-site-docusaurus/README.md +41 -0
  95. package/docs-site-docusaurus/docs/api/README.md +52 -0
  96. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6130 -0
  97. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
  98. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
  99. package/docs-site-docusaurus/docs/api/classes/BST.md +5831 -0
  100. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
  101. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
  102. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
  103. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
  104. package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
  105. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
  106. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
  107. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
  108. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
  109. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
  110. package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
  111. package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
  112. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
  113. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
  114. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
  115. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
  116. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
  117. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
  118. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
  119. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
  120. package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
  121. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
  122. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
  123. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
  124. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
  125. package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
  126. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
  127. package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
  128. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6374 -0
  129. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
  130. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
  131. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
  132. package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
  133. package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
  134. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1257 -0
  135. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1475 -0
  136. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1117 -0
  137. package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
  138. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
  139. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
  140. package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
  141. package/docs-site-docusaurus/docs/guide/architecture.md +613 -0
  142. package/docs-site-docusaurus/docs/guide/concepts.md +420 -0
  143. package/docs-site-docusaurus/docs/guide/guides.md +611 -0
  144. package/docs-site-docusaurus/docs/guide/installation.md +60 -0
  145. package/docs-site-docusaurus/docs/guide/integrations.md +823 -0
  146. package/docs-site-docusaurus/docs/guide/overview.md +638 -0
  147. package/docs-site-docusaurus/docs/guide/performance.md +833 -0
  148. package/docs-site-docusaurus/docs/guide/quick-start.md +73 -0
  149. package/docs-site-docusaurus/docusaurus.config.ts +159 -0
  150. package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
  151. package/docs-site-docusaurus/package-lock.json +18667 -0
  152. package/docs-site-docusaurus/package.json +50 -0
  153. package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
  154. package/docs-site-docusaurus/sidebars.ts +23 -0
  155. package/docs-site-docusaurus/sort-protected.mjs +87 -0
  156. package/docs-site-docusaurus/src/css/custom.css +96 -0
  157. package/docs-site-docusaurus/src/pages/index.module.css +13 -0
  158. package/docs-site-docusaurus/src/pages/index.tsx +71 -0
  159. package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
  160. package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
  161. package/docs-site-docusaurus/static/.nojekyll +0 -0
  162. package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  163. package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
  164. package/docs-site-docusaurus/static/img/favicon.ico +0 -0
  165. package/docs-site-docusaurus/static/img/favicon.png +0 -0
  166. package/docs-site-docusaurus/static/img/logo-180.png +0 -0
  167. package/docs-site-docusaurus/static/img/logo.jpg +0 -0
  168. package/docs-site-docusaurus/static/img/logo.png +0 -0
  169. package/docs-site-docusaurus/static/img/logo.svg +1 -0
  170. package/docs-site-docusaurus/static/img/og-image.png +0 -0
  171. package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  172. package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  173. package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  174. package/docs-site-docusaurus/static/robots.txt +4 -0
  175. package/docs-site-docusaurus/typedoc.json +23 -0
  176. package/package.json +109 -12
  177. package/src/data-structures/base/index.ts +1 -0
  178. package/src/data-structures/base/iterable-element-base.ts +4 -5
  179. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  180. package/src/data-structures/base/linear-base.ts +3 -3
  181. package/src/data-structures/binary-tree/avl-tree.ts +386 -51
  182. package/src/data-structures/binary-tree/binary-indexed-tree.ts +596 -247
  183. package/src/data-structures/binary-tree/binary-tree.ts +956 -81
  184. package/src/data-structures/binary-tree/bst.ts +840 -35
  185. package/src/data-structures/binary-tree/red-black-tree.ts +689 -97
  186. package/src/data-structures/binary-tree/segment-tree.ts +498 -249
  187. package/src/data-structures/binary-tree/tree-map.ts +3784 -7
  188. package/src/data-structures/binary-tree/tree-multi-map.ts +3614 -211
  189. package/src/data-structures/binary-tree/tree-multi-set.ts +2874 -65
  190. package/src/data-structures/binary-tree/tree-set.ts +3531 -10
  191. package/src/data-structures/graph/abstract-graph.ts +4 -4
  192. package/src/data-structures/graph/directed-graph.ts +429 -47
  193. package/src/data-structures/graph/map-graph.ts +59 -1
  194. package/src/data-structures/graph/undirected-graph.ts +393 -59
  195. package/src/data-structures/hash/hash-map.ts +476 -92
  196. package/src/data-structures/heap/heap.ts +581 -99
  197. package/src/data-structures/heap/max-heap.ts +46 -0
  198. package/src/data-structures/heap/min-heap.ts +59 -0
  199. package/src/data-structures/linked-list/doubly-linked-list.ts +646 -47
  200. package/src/data-structures/linked-list/singly-linked-list.ts +596 -68
  201. package/src/data-structures/linked-list/skip-linked-list.ts +1067 -90
  202. package/src/data-structures/matrix/matrix.ts +584 -12
  203. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  204. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  205. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  206. package/src/data-structures/queue/deque.ts +592 -70
  207. package/src/data-structures/queue/queue.ts +463 -42
  208. package/src/data-structures/stack/stack.ts +384 -32
  209. package/src/data-structures/trie/trie.ts +470 -48
  210. package/src/interfaces/graph.ts +1 -1
  211. package/src/types/common.ts +2 -2
  212. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  213. package/src/types/data-structures/heap/heap.ts +1 -0
  214. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
  215. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  216. package/src/types/utils/validate-type.ts +4 -4
  217. package/vercel.json +6 -0
  218. package/dist/leetcode/avl-tree-counter.mjs +0 -2957
  219. package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
  220. package/dist/leetcode/avl-tree.mjs +0 -2720
  221. package/dist/leetcode/binary-tree.mjs +0 -1594
  222. package/dist/leetcode/bst.mjs +0 -2398
  223. package/dist/leetcode/deque.mjs +0 -683
  224. package/dist/leetcode/directed-graph.mjs +0 -1733
  225. package/dist/leetcode/doubly-linked-list.mjs +0 -709
  226. package/dist/leetcode/hash-map.mjs +0 -493
  227. package/dist/leetcode/heap.mjs +0 -542
  228. package/dist/leetcode/max-heap.mjs +0 -375
  229. package/dist/leetcode/max-priority-queue.mjs +0 -383
  230. package/dist/leetcode/min-heap.mjs +0 -363
  231. package/dist/leetcode/min-priority-queue.mjs +0 -371
  232. package/dist/leetcode/priority-queue.mjs +0 -363
  233. package/dist/leetcode/queue.mjs +0 -943
  234. package/dist/leetcode/red-black-tree.mjs +0 -2765
  235. package/dist/leetcode/singly-linked-list.mjs +0 -754
  236. package/dist/leetcode/stack.mjs +0 -217
  237. package/dist/leetcode/tree-counter.mjs +0 -3039
  238. package/dist/leetcode/tree-multi-map.mjs +0 -2913
  239. package/dist/leetcode/trie.mjs +0 -413
  240. package/dist/leetcode/undirected-graph.mjs +0 -1650
@@ -0,0 +1,1333 @@
1
+ [**data-structure-typed**](../README.md)
2
+
3
+ ***
4
+
5
+ [data-structure-typed](../README.md) / HashMap
6
+
7
+ # Class: HashMap\<K, V, R\>
8
+
9
+ Defined in: [data-structures/hash/hash-map.ts:97](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L97)
10
+
11
+ Hash-based map. Supports object keys and custom hashing; offers O(1) average set/get/has.
12
+
13
+ ## Remarks
14
+
15
+ Time O(1), Space O(1)
16
+
17
+ ## Examples
18
+
19
+ ```ts
20
+ // HashMap for user session caching O(1) performance
21
+ interface UserSession {
22
+ userId: number;
23
+ username: string;
24
+ loginTime: number;
25
+ lastActivity: number;
26
+ }
27
+
28
+ // HashMap provides O(1) average-case performance for set/get/delete
29
+ // Perfect for session management with fast lookups
30
+ const sessionCache = new HashMap<string, UserSession>();
31
+
32
+ // Simulate user sessions
33
+ const sessions: [string, UserSession][] = [
34
+ ['session_001', { userId: 1, username: 'alice', loginTime: 1000, lastActivity: 1050 }],
35
+ ['session_002', { userId: 2, username: 'bob', loginTime: 1100, lastActivity: 1150 }],
36
+ ['session_003', { userId: 3, username: 'charlie', loginTime: 1200, lastActivity: 1250 }]
37
+ ];
38
+
39
+ // Store sessions with O(1) insertion
40
+ for (const [token, session] of sessions) {
41
+ sessionCache.set(token, session);
42
+ }
43
+
44
+ console.log(sessionCache.size); // 3;
45
+
46
+ // Retrieve session with O(1) lookup
47
+ const userSession = sessionCache.get('session_001');
48
+ console.log(userSession?.username); // 'alice';
49
+ console.log(userSession?.userId); // 1;
50
+
51
+ // Update session with O(1) operation
52
+ if (userSession) {
53
+ userSession.lastActivity = 2000;
54
+ sessionCache.set('session_001', userSession);
55
+ }
56
+
57
+ // Check updated value
58
+ const updated = sessionCache.get('session_001');
59
+ console.log(updated?.lastActivity); // 2000;
60
+
61
+ // Cleanup: delete expired sessions
62
+ sessionCache.delete('session_002');
63
+ console.log(sessionCache.has('session_002')); // false;
64
+
65
+ // Verify remaining sessions
66
+ console.log(sessionCache.size); // 2;
67
+
68
+ // Get all active sessions
69
+ const activeCount = [...sessionCache.values()].length;
70
+ console.log(activeCount); // 2;
71
+ ```
72
+
73
+ ```ts
74
+ // Aggregate values
75
+ const counts = new HashMap<string, number>([['a', 5], ['b', 3], ['c', 8]]);
76
+
77
+ const total = counts.reduce((sum, v) => sum + (v ?? 0), 0);
78
+ console.log(total); // 16;
79
+ ```
80
+
81
+ ```ts
82
+ // Iterate over entries
83
+ const map = new HashMap<string, number>([['x', 1], ['y', 2]]);
84
+ const keys: string[] = [];
85
+
86
+ map.forEach((v, k) => keys.push(k));
87
+ console.log(keys.sort()); // ['x', 'y'];
88
+ ```
89
+
90
+ ## Extends
91
+
92
+ - [`IterableEntryBase`](IterableEntryBase.md)\<`K`, `V`\>
93
+
94
+ ## Type Parameters
95
+
96
+ ### K
97
+
98
+ `K` = `any`
99
+
100
+ ### V
101
+
102
+ `V` = `any`
103
+
104
+ ### R
105
+
106
+ `R` = \[`K`, `V`\]
107
+
108
+ 1. Key-Value Pair Storage: HashMap stores key-value pairs. Each key map to a value.
109
+ 2. Fast Lookup: It's used when you need to quickly find, insert, or delete entries based on a key.
110
+ 3. Unique Keys: Keys are unique.
111
+ If you try to insert another entry with the same key, the new one will replace the old entry.
112
+ 4. Unordered Collection: HashMap does not guarantee the order of entries, and the order may change over time.
113
+
114
+ ## Constructors
115
+
116
+ ### Constructor
117
+
118
+ ```ts
119
+ new HashMap<K, V, R>(entryOrRawElements?, options?): HashMap<K, V, R>;
120
+ ```
121
+
122
+ Defined in: [data-structures/hash/hash-map.ts:105](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L105)
123
+
124
+ Create a HashMap and optionally bulk-insert entries.
125
+
126
+ #### Parameters
127
+
128
+ ##### entryOrRawElements?
129
+
130
+ `Iterable`\<\[`K`, `V`\] \| `R`\> = `[]`
131
+
132
+ Iterable of entries or raw elements to insert.
133
+
134
+ ##### options?
135
+
136
+ `HashMapOptions`\<`K`, `V`, `R`\>
137
+
138
+ Options: hash function and optional record-to-entry converter.
139
+
140
+ #### Returns
141
+
142
+ `HashMap`\<`K`, `V`, `R`\>
143
+
144
+ New HashMap instance.
145
+
146
+ #### Remarks
147
+
148
+ Time O(N), Space O(N)
149
+
150
+ #### Overrides
151
+
152
+ ```ts
153
+ IterableEntryBase<K, V>.constructor
154
+ ```
155
+
156
+ ## Accessors
157
+
158
+ ### hashFn
159
+
160
+ #### Get Signature
161
+
162
+ ```ts
163
+ get hashFn(): (key) => string;
164
+ ```
165
+
166
+ Defined in: [data-structures/hash/hash-map.ts:166](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L166)
167
+
168
+ Get the current hash function for non-object keys.
169
+
170
+ ##### Remarks
171
+
172
+ Time O(1), Space O(1)
173
+
174
+ ##### Returns
175
+
176
+ Hash function.
177
+
178
+ (`key`) => `string`
179
+
180
+ ***
181
+
182
+ ### objMap
183
+
184
+ #### Get Signature
185
+
186
+ ```ts
187
+ get objMap(): Map<object, V>;
188
+ ```
189
+
190
+ Defined in: [data-structures/hash/hash-map.ts:133](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L133)
191
+
192
+ Get the internal Map used for object/function keys.
193
+
194
+ ##### Remarks
195
+
196
+ Time O(1), Space O(1)
197
+
198
+ ##### Returns
199
+
200
+ `Map`\<`object`, `V`\>
201
+
202
+ Map of object→value.
203
+
204
+ ***
205
+
206
+ ### size
207
+
208
+ #### Get Signature
209
+
210
+ ```ts
211
+ get size(): number;
212
+ ```
213
+
214
+ Defined in: [data-structures/hash/hash-map.ts:155](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L155)
215
+
216
+ Get the number of distinct keys stored.
217
+
218
+ ##### Remarks
219
+
220
+ Time O(1), Space O(1)
221
+
222
+ ##### Returns
223
+
224
+ `number`
225
+
226
+ Current size.
227
+
228
+ #### Overrides
229
+
230
+ [`IterableEntryBase`](IterableEntryBase.md).[`size`](IterableEntryBase.md#size)
231
+
232
+ ***
233
+
234
+ ### store
235
+
236
+ #### Get Signature
237
+
238
+ ```ts
239
+ get store(): object;
240
+ ```
241
+
242
+ Defined in: [data-structures/hash/hash-map.ts:122](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L122)
243
+
244
+ Get the internal store for non-object keys.
245
+
246
+ ##### Remarks
247
+
248
+ Time O(1), Space O(1)
249
+
250
+ ##### Returns
251
+
252
+ `object`
253
+
254
+ Internal record of string→{key,value}.
255
+
256
+ ***
257
+
258
+ ### toEntryFn
259
+
260
+ #### Get Signature
261
+
262
+ ```ts
263
+ get toEntryFn(): ((rawElement) => [K, V]) | undefined;
264
+ ```
265
+
266
+ Defined in: [data-structures/hash/hash-map.ts:144](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L144)
267
+
268
+ Get the raw→entry converter function if present.
269
+
270
+ ##### Remarks
271
+
272
+ Time O(1), Space O(1)
273
+
274
+ ##### Returns
275
+
276
+ ((`rawElement`) => \[`K`, `V`\]) \| `undefined`
277
+
278
+ Converter function or undefined.
279
+
280
+ ## Methods
281
+
282
+ ### \[iterator\]()
283
+
284
+ ```ts
285
+ iterator: IterableIterator<[K, V]>;
286
+ ```
287
+
288
+ Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L22)
289
+
290
+ Default iterator yielding `[key, value]` entries.
291
+
292
+ #### Parameters
293
+
294
+ ##### args
295
+
296
+ ...`any`[]
297
+
298
+ #### Returns
299
+
300
+ `IterableIterator`\<\[`K`, `V`\]\>
301
+
302
+ Iterator of `[K, V]`.
303
+
304
+ #### Remarks
305
+
306
+ Time O(n) to iterate, Space O(1)
307
+
308
+ #### Inherited from
309
+
310
+ [`IterableEntryBase`](IterableEntryBase.md).[`[iterator]`](IterableEntryBase.md#iterator)
311
+
312
+ ***
313
+
314
+ ### clear()
315
+
316
+ ```ts
317
+ clear(): void;
318
+ ```
319
+
320
+ Defined in: [data-structures/hash/hash-map.ts:245](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L245)
321
+
322
+ Remove all entries and reset counters.
323
+
324
+ #### Returns
325
+
326
+ `void`
327
+
328
+ void
329
+
330
+ *
331
+
332
+ #### Remarks
333
+
334
+ Time O(N), Space O(1)
335
+
336
+ #### Example
337
+
338
+ ```ts
339
+ // Remove all entries
340
+ const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
341
+ map.clear();
342
+ console.log(map.isEmpty()); // true;
343
+ ```
344
+
345
+ #### Overrides
346
+
347
+ [`IterableEntryBase`](IterableEntryBase.md).[`clear`](IterableEntryBase.md#clear)
348
+
349
+ ***
350
+
351
+ ### clone()
352
+
353
+ ```ts
354
+ clone(): this;
355
+ ```
356
+
357
+ Defined in: [data-structures/hash/hash-map.ts:613](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L613)
358
+
359
+ Deep clone this map, preserving hashing behavior.
360
+
361
+ #### Returns
362
+
363
+ `this`
364
+
365
+ A new map with the same content.
366
+
367
+ *
368
+
369
+ #### Remarks
370
+
371
+ Time O(N), Space O(N)
372
+
373
+ #### Example
374
+
375
+ ```ts
376
+ // Create independent copy
377
+ const map = new HashMap<string, number>([['a', 1]]);
378
+ const copy = map.clone();
379
+ copy.set('a', 99);
380
+ console.log(map.get('a')); // 1;
381
+ ```
382
+
383
+ #### Overrides
384
+
385
+ [`IterableEntryBase`](IterableEntryBase.md).[`clone`](IterableEntryBase.md#clone)
386
+
387
+ ***
388
+
389
+ ### delete()
390
+
391
+ ```ts
392
+ delete(key): boolean;
393
+ ```
394
+
395
+ Defined in: [data-structures/hash/hash-map.ts:549](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L549)
396
+
397
+ Delete an entry by key.
398
+
399
+ #### Parameters
400
+
401
+ ##### key
402
+
403
+ `K`
404
+
405
+ Key to delete.
406
+
407
+ #### Returns
408
+
409
+ `boolean`
410
+
411
+ True if the key was found and removed.
412
+
413
+ *
414
+
415
+ #### Remarks
416
+
417
+ Time O(1), Space O(1)
418
+
419
+ #### Example
420
+
421
+ ```ts
422
+ // Remove entries by key
423
+ const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
424
+
425
+ console.log(map.delete('y')); // true;
426
+ console.log(map.has('y')); // false;
427
+ console.log(map.size); // 2;
428
+ ```
429
+
430
+ ***
431
+
432
+ ### entries()
433
+
434
+ ```ts
435
+ entries(): IterableIterator<[K, V | undefined]>;
436
+ ```
437
+
438
+ Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L31)
439
+
440
+ Iterate over `[key, value]` pairs (may yield `undefined` values).
441
+
442
+ #### Returns
443
+
444
+ `IterableIterator`\<\[`K`, `V` \| `undefined`\]\>
445
+
446
+ Iterator of `[K, V | undefined]`.
447
+
448
+ #### Remarks
449
+
450
+ Time O(n), Space O(1)
451
+
452
+ #### Inherited from
453
+
454
+ [`IterableEntryBase`](IterableEntryBase.md).[`entries`](IterableEntryBase.md#entries)
455
+
456
+ ***
457
+
458
+ ### every()
459
+
460
+ ```ts
461
+ every(predicate, thisArg?): boolean;
462
+ ```
463
+
464
+ Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L66)
465
+
466
+ Test whether all entries satisfy the predicate.
467
+
468
+ #### Parameters
469
+
470
+ ##### predicate
471
+
472
+ `EntryCallback`\<`K`, `V`, `boolean`\>
473
+
474
+ `(key, value, index, self) => boolean`.
475
+
476
+ ##### thisArg?
477
+
478
+ `any`
479
+
480
+ Optional `this` for callback.
481
+
482
+ #### Returns
483
+
484
+ `boolean`
485
+
486
+ `true` if all pass; otherwise `false`.
487
+
488
+ #### Remarks
489
+
490
+ Time O(n), Space O(1)
491
+
492
+ #### Inherited from
493
+
494
+ [`IterableEntryBase`](IterableEntryBase.md).[`every`](IterableEntryBase.md#every)
495
+
496
+ ***
497
+
498
+ ### filter()
499
+
500
+ ```ts
501
+ filter(predicate, thisArg?): any;
502
+ ```
503
+
504
+ Defined in: [data-structures/hash/hash-map.ts:729](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L729)
505
+
506
+ Filter entries into a new map.
507
+
508
+ #### Parameters
509
+
510
+ ##### predicate
511
+
512
+ `EntryCallback`\<`K`, `V`, `boolean`\>
513
+
514
+ Predicate (key, value, index, map) → boolean.
515
+
516
+ ##### thisArg?
517
+
518
+ `any`
519
+
520
+ Value for `this` inside the predicate.
521
+
522
+ #### Returns
523
+
524
+ `any`
525
+
526
+ A new map containing entries that satisfied the predicate.
527
+
528
+ *
529
+
530
+ #### Remarks
531
+
532
+ Time O(N), Space O(N)
533
+
534
+ #### Example
535
+
536
+ ```ts
537
+ // HashMap iteration and filter operations
538
+ const map = new HashMap<number, string>([
539
+ [1, 'Alice'],
540
+ [2, 'Bob'],
541
+ [3, 'Charlie'],
542
+ [4, 'Diana'],
543
+ [5, 'Eve']
544
+ ]);
545
+
546
+ // Iterate through entries
547
+ const entries: [number, string][] = [];
548
+ for (const [key, value] of map) {
549
+ entries.push([key, value]);
550
+ }
551
+ console.log(entries); // length: 5;
552
+
553
+ // Filter operation (for iteration with collection methods)
554
+ const filtered = [...map].filter(([key]) => key > 2);
555
+ console.log(filtered.length); // 3;
556
+
557
+ // Map operation
558
+ const values = [...map.values()].map(v => v.length);
559
+ console.log(values); // contains 3; // 'Bob', 'Eve'
560
+ console.log(values); // contains 7;
561
+ ```
562
+
563
+ #### Overrides
564
+
565
+ [`IterableEntryBase`](IterableEntryBase.md).[`filter`](IterableEntryBase.md#filter)
566
+
567
+ ***
568
+
569
+ ### find()
570
+
571
+ ```ts
572
+ find(callbackfn, thisArg?): [K, V] | undefined;
573
+ ```
574
+
575
+ Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L114)
576
+
577
+ Find the first entry that matches a predicate.
578
+
579
+ #### Parameters
580
+
581
+ ##### callbackfn
582
+
583
+ `EntryCallback`\<`K`, `V`, `boolean`\>
584
+
585
+ `(key, value, index, self) => boolean`.
586
+
587
+ ##### thisArg?
588
+
589
+ `any`
590
+
591
+ Optional `this` for callback.
592
+
593
+ #### Returns
594
+
595
+ \[`K`, `V`\] \| `undefined`
596
+
597
+ Matching `[key, value]` or `undefined`.
598
+
599
+ #### Remarks
600
+
601
+ Time O(n), Space O(1)
602
+
603
+ #### Inherited from
604
+
605
+ [`IterableEntryBase`](IterableEntryBase.md).[`find`](IterableEntryBase.md#find)
606
+
607
+ ***
608
+
609
+ ### forEach()
610
+
611
+ ```ts
612
+ forEach(callbackfn, thisArg?): void;
613
+ ```
614
+
615
+ Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L99)
616
+
617
+ Visit each entry, left-to-right.
618
+
619
+ #### Parameters
620
+
621
+ ##### callbackfn
622
+
623
+ `EntryCallback`\<`K`, `V`, `void`\>
624
+
625
+ `(key, value, index, self) => void`.
626
+
627
+ ##### thisArg?
628
+
629
+ `any`
630
+
631
+ Optional `this` for callback.
632
+
633
+ #### Returns
634
+
635
+ `void`
636
+
637
+ #### Remarks
638
+
639
+ Time O(n), Space O(1)
640
+
641
+ #### Inherited from
642
+
643
+ [`IterableEntryBase`](IterableEntryBase.md).[`forEach`](IterableEntryBase.md#foreach)
644
+
645
+ ***
646
+
647
+ ### get()
648
+
649
+ ```ts
650
+ get(key): V | undefined;
651
+ ```
652
+
653
+ Defined in: [data-structures/hash/hash-map.ts:456](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L456)
654
+
655
+ Get the value for a key.
656
+
657
+ #### Parameters
658
+
659
+ ##### key
660
+
661
+ `K`
662
+
663
+ Key to look up.
664
+
665
+ #### Returns
666
+
667
+ `V` \| `undefined`
668
+
669
+ Value or undefined.
670
+
671
+ *
672
+
673
+ #### Remarks
674
+
675
+ Time O(1), Space O(1)
676
+
677
+ #### Example
678
+
679
+ ```ts
680
+ // HashMap get and has operations
681
+ const map = new HashMap<string, number>([
682
+ ['apple', 1],
683
+ ['banana', 2],
684
+ ['cherry', 3]
685
+ ]);
686
+
687
+ // Check if key exists
688
+ console.log(map.has('apple')); // true;
689
+ console.log(map.has('date')); // false;
690
+
691
+ // Get value by key
692
+ console.log(map.get('banana')); // 2;
693
+ console.log(map.get('grape')); // undefined;
694
+
695
+ // Get all keys and values
696
+ const keys = [...map.keys()];
697
+ const values = [...map.values()];
698
+ console.log(keys); // contains 'apple';
699
+ console.log(values); // contains 3;
700
+ ```
701
+
702
+ #### Overrides
703
+
704
+ [`IterableEntryBase`](IterableEntryBase.md).[`get`](IterableEntryBase.md#get)
705
+
706
+ ***
707
+
708
+ ### has()
709
+
710
+ ```ts
711
+ has(key): boolean;
712
+ ```
713
+
714
+ Defined in: [data-structures/hash/hash-map.ts:502](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L502)
715
+
716
+ Check if a key exists.
717
+
718
+ #### Parameters
719
+
720
+ ##### key
721
+
722
+ `K`
723
+
724
+ Key to test.
725
+
726
+ #### Returns
727
+
728
+ `boolean`
729
+
730
+ True if present.
731
+
732
+ *
733
+
734
+ #### Remarks
735
+
736
+ Time O(1), Space O(1)
737
+
738
+ #### Example
739
+
740
+ ```ts
741
+ // Check key existence
742
+ const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
743
+
744
+ console.log(map.has('a')); // true;
745
+ console.log(map.has('z')); // false;
746
+ ```
747
+
748
+ #### Overrides
749
+
750
+ [`IterableEntryBase`](IterableEntryBase.md).[`has`](IterableEntryBase.md#has)
751
+
752
+ ***
753
+
754
+ ### hasValue()
755
+
756
+ ```ts
757
+ hasValue(value): boolean;
758
+ ```
759
+
760
+ Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L143)
761
+
762
+ Whether there exists an entry with the given value.
763
+
764
+ #### Parameters
765
+
766
+ ##### value
767
+
768
+ `V`
769
+
770
+ Value to test.
771
+
772
+ #### Returns
773
+
774
+ `boolean`
775
+
776
+ `true` if found; otherwise `false`.
777
+
778
+ #### Remarks
779
+
780
+ Time O(n), Space O(1)
781
+
782
+ #### Inherited from
783
+
784
+ [`IterableEntryBase`](IterableEntryBase.md).[`hasValue`](IterableEntryBase.md#hasvalue)
785
+
786
+ ***
787
+
788
+ ### isEmpty()
789
+
790
+ ```ts
791
+ isEmpty(): boolean;
792
+ ```
793
+
794
+ Defined in: [data-structures/hash/hash-map.ts:205](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L205)
795
+
796
+ Check whether the map is empty.
797
+
798
+ #### Returns
799
+
800
+ `boolean`
801
+
802
+ True if size is 0.
803
+
804
+ *
805
+
806
+ #### Remarks
807
+
808
+ Time O(1), Space O(1)
809
+
810
+ #### Example
811
+
812
+ ```ts
813
+ // Check if empty
814
+ const map = new HashMap();
815
+ console.log(map.isEmpty()); // true;
816
+ ```
817
+
818
+ #### Overrides
819
+
820
+ [`IterableEntryBase`](IterableEntryBase.md).[`isEmpty`](IterableEntryBase.md#isempty)
821
+
822
+ ***
823
+
824
+ ### isEntry()
825
+
826
+ ```ts
827
+ isEntry(rawElement): rawElement is [K, V];
828
+ ```
829
+
830
+ Defined in: [data-structures/hash/hash-map.ts:256](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L256)
831
+
832
+ Type guard: check if a raw value is a [key, value] entry.
833
+
834
+ #### Parameters
835
+
836
+ ##### rawElement
837
+
838
+ `any`
839
+
840
+ #### Returns
841
+
842
+ `rawElement is [K, V]`
843
+
844
+ True if the value is a 2-tuple.
845
+
846
+ #### Remarks
847
+
848
+ Time O(1), Space O(1)
849
+
850
+ ***
851
+
852
+ ### keys()
853
+
854
+ ```ts
855
+ keys(): IterableIterator<K>;
856
+ ```
857
+
858
+ Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L42)
859
+
860
+ Iterate over keys only.
861
+
862
+ #### Returns
863
+
864
+ `IterableIterator`\<`K`\>
865
+
866
+ Iterator of keys.
867
+
868
+ #### Remarks
869
+
870
+ Time O(n), Space O(1)
871
+
872
+ #### Inherited from
873
+
874
+ [`IterableEntryBase`](IterableEntryBase.md).[`keys`](IterableEntryBase.md#keys)
875
+
876
+ ***
877
+
878
+ ### map()
879
+
880
+ ```ts
881
+ map<VM>(callbackfn, thisArg?): any;
882
+ ```
883
+
884
+ Defined in: [data-structures/hash/hash-map.ts:661](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L661)
885
+
886
+ Map values to a new map with the same keys.
887
+
888
+ #### Type Parameters
889
+
890
+ ##### VM
891
+
892
+ `VM`
893
+
894
+ #### Parameters
895
+
896
+ ##### callbackfn
897
+
898
+ `EntryCallback`\<`K`, `V`, `VM`\>
899
+
900
+ Mapping function (key, value, index, map) → newValue.
901
+
902
+ ##### thisArg?
903
+
904
+ `any`
905
+
906
+ Value for `this` inside the callback.
907
+
908
+ #### Returns
909
+
910
+ `any`
911
+
912
+ A new map with transformed values.
913
+
914
+ *
915
+
916
+ #### Remarks
917
+
918
+ Time O(N), Space O(N)
919
+
920
+ #### Example
921
+
922
+ ```ts
923
+ // Transform all values
924
+ const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
925
+
926
+ const doubled = prices.map(v => (v ?? 0) * 2);
927
+ console.log(doubled.get('apple')); // 2;
928
+ console.log(doubled.get('banana')); // 4;
929
+ ```
930
+
931
+ #### Overrides
932
+
933
+ [`IterableEntryBase`](IterableEntryBase.md).[`map`](IterableEntryBase.md#map)
934
+
935
+ ***
936
+
937
+ ### print()
938
+
939
+ ```ts
940
+ print(): void;
941
+ ```
942
+
943
+ Defined in: [data-structures/base/iterable-entry-base.ts:203](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L203)
944
+
945
+ Print a human-friendly representation to the console.
946
+
947
+ #### Returns
948
+
949
+ `void`
950
+
951
+ #### Remarks
952
+
953
+ Time O(n), Space O(n)
954
+
955
+ #### Inherited from
956
+
957
+ [`IterableEntryBase`](IterableEntryBase.md).[`print`](IterableEntryBase.md#print)
958
+
959
+ ***
960
+
961
+ ### reduce()
962
+
963
+ ```ts
964
+ reduce<U>(callbackfn, initialValue): U;
965
+ ```
966
+
967
+ Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L171)
968
+
969
+ Reduce entries into a single accumulator.
970
+
971
+ #### Type Parameters
972
+
973
+ ##### U
974
+
975
+ `U`
976
+
977
+ #### Parameters
978
+
979
+ ##### callbackfn
980
+
981
+ `ReduceEntryCallback`\<`K`, `V`, `U`\>
982
+
983
+ `(acc, value, key, index, self) => acc`.
984
+
985
+ ##### initialValue
986
+
987
+ `U`
988
+
989
+ Initial accumulator.
990
+
991
+ #### Returns
992
+
993
+ `U`
994
+
995
+ Final accumulator.
996
+
997
+ #### Remarks
998
+
999
+ Time O(n), Space O(1)
1000
+
1001
+ #### Inherited from
1002
+
1003
+ [`IterableEntryBase`](IterableEntryBase.md).[`reduce`](IterableEntryBase.md#reduce)
1004
+
1005
+ ***
1006
+
1007
+ ### set()
1008
+
1009
+ ```ts
1010
+ set(key, value): boolean;
1011
+ ```
1012
+
1013
+ Defined in: [data-structures/hash/hash-map.ts:341](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L341)
1014
+
1015
+ Insert or replace a single entry.
1016
+
1017
+ #### Parameters
1018
+
1019
+ ##### key
1020
+
1021
+ `K`
1022
+
1023
+ Key.
1024
+
1025
+ ##### value
1026
+
1027
+ `V`
1028
+
1029
+ Value.
1030
+
1031
+ #### Returns
1032
+
1033
+ `boolean`
1034
+
1035
+ True when the operation succeeds.
1036
+
1037
+ *
1038
+
1039
+ #### Remarks
1040
+
1041
+ Time O(1), Space O(1)
1042
+
1043
+ #### Example
1044
+
1045
+ ```ts
1046
+ // basic HashMap creation and set operation
1047
+ // Create a simple HashMap with key-value pairs
1048
+ const map = new HashMap<number, string>([
1049
+ [1, 'one'],
1050
+ [2, 'two'],
1051
+ [3, 'three']
1052
+ ]);
1053
+
1054
+ // Verify size
1055
+ console.log(map.size); // 3;
1056
+
1057
+ // Set a new key-value pair
1058
+ map.set(4, 'four');
1059
+ console.log(map.size); // 4;
1060
+
1061
+ // Verify entries
1062
+ console.log([...map.entries()]); // length: 4;
1063
+ ```
1064
+
1065
+ ***
1066
+
1067
+ ### setHashFn()
1068
+
1069
+ ```ts
1070
+ setHashFn(fn): this;
1071
+ ```
1072
+
1073
+ Defined in: [data-structures/hash/hash-map.ts:569](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L569)
1074
+
1075
+ Replace the hash function and rehash the non-object store.
1076
+
1077
+ #### Parameters
1078
+
1079
+ ##### fn
1080
+
1081
+ (`key`) => `string`
1082
+
1083
+ New hash function for non-object keys.
1084
+
1085
+ #### Returns
1086
+
1087
+ `this`
1088
+
1089
+ This map instance.
1090
+
1091
+ #### Remarks
1092
+
1093
+ Time O(N), Space O(N)
1094
+
1095
+ ***
1096
+
1097
+ ### setMany()
1098
+
1099
+ ```ts
1100
+ setMany(entryOrRawElements): boolean[];
1101
+ ```
1102
+
1103
+ Defined in: [data-structures/hash/hash-map.ts:390](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L390)
1104
+
1105
+ Insert many entries from an iterable.
1106
+
1107
+ #### Parameters
1108
+
1109
+ ##### entryOrRawElements
1110
+
1111
+ `Iterable`\<\[`K`, `V`\] \| `R`\>
1112
+
1113
+ Iterable of entries or raw elements to insert.
1114
+
1115
+ #### Returns
1116
+
1117
+ `boolean`[]
1118
+
1119
+ Array of per-entry results.
1120
+
1121
+ *
1122
+
1123
+ #### Remarks
1124
+
1125
+ Time O(N), Space O(N)
1126
+
1127
+ #### Example
1128
+
1129
+ ```ts
1130
+ // Add multiple entries
1131
+ const map = new HashMap<string, number>();
1132
+ map.setMany([['a', 1], ['b', 2], ['c', 3]]);
1133
+ console.log(map.size); // 3;
1134
+ ```
1135
+
1136
+ ***
1137
+
1138
+ ### some()
1139
+
1140
+ ```ts
1141
+ some(predicate, thisArg?): boolean;
1142
+ ```
1143
+
1144
+ Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L83)
1145
+
1146
+ Test whether any entry satisfies the predicate.
1147
+
1148
+ #### Parameters
1149
+
1150
+ ##### predicate
1151
+
1152
+ `EntryCallback`\<`K`, `V`, `boolean`\>
1153
+
1154
+ `(key, value, index, self) => boolean`.
1155
+
1156
+ ##### thisArg?
1157
+
1158
+ `any`
1159
+
1160
+ Optional `this` for callback.
1161
+
1162
+ #### Returns
1163
+
1164
+ `boolean`
1165
+
1166
+ `true` if any passes; otherwise `false`.
1167
+
1168
+ #### Remarks
1169
+
1170
+ Time O(n), Space O(1)
1171
+
1172
+ #### Inherited from
1173
+
1174
+ [`IterableEntryBase`](IterableEntryBase.md).[`some`](IterableEntryBase.md#some)
1175
+
1176
+ ***
1177
+
1178
+ ### toArray()
1179
+
1180
+ ```ts
1181
+ toArray(): [K, V][];
1182
+ ```
1183
+
1184
+ Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L186)
1185
+
1186
+ Converts data structure to `[key, value]` pairs.
1187
+
1188
+ #### Returns
1189
+
1190
+ \[`K`, `V`\][]
1191
+
1192
+ Array of entries.
1193
+
1194
+ #### Remarks
1195
+
1196
+ Time O(n), Space O(n)
1197
+
1198
+ #### Inherited from
1199
+
1200
+ [`IterableEntryBase`](IterableEntryBase.md).[`toArray`](IterableEntryBase.md#toarray)
1201
+
1202
+ ***
1203
+
1204
+ ### toVisual()
1205
+
1206
+ ```ts
1207
+ toVisual(): string | [K, V][];
1208
+ ```
1209
+
1210
+ Defined in: [data-structures/base/iterable-entry-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L195)
1211
+
1212
+ Visualize the iterable as an array of `[key, value]` pairs (or a custom string).
1213
+
1214
+ #### Returns
1215
+
1216
+ `string` \| \[`K`, `V`\][]
1217
+
1218
+ Array of entries (default) or a string.
1219
+
1220
+ #### Remarks
1221
+
1222
+ Time O(n), Space O(n)
1223
+
1224
+ #### Inherited from
1225
+
1226
+ [`IterableEntryBase`](IterableEntryBase.md).[`toVisual`](IterableEntryBase.md#tovisual)
1227
+
1228
+ ***
1229
+
1230
+ ### values()
1231
+
1232
+ ```ts
1233
+ values(): IterableIterator<V>;
1234
+ ```
1235
+
1236
+ Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-entry-base.ts#L53)
1237
+
1238
+ Iterate over values only.
1239
+
1240
+ #### Returns
1241
+
1242
+ `IterableIterator`\<`V`\>
1243
+
1244
+ Iterator of values.
1245
+
1246
+ #### Remarks
1247
+
1248
+ Time O(n), Space O(1)
1249
+
1250
+ #### Inherited from
1251
+
1252
+ [`IterableEntryBase`](IterableEntryBase.md).[`values`](IterableEntryBase.md#values)
1253
+
1254
+
1255
+ ---
1256
+
1257
+ ## Protected Members
1258
+
1259
+ ### \_createLike()
1260
+
1261
+ ```ts
1262
+ protected _createLike<TK, TV, TR>(entries?, options?): any;
1263
+ ```
1264
+
1265
+ Defined in: [data-structures/hash/hash-map.ts:746](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L746)
1266
+
1267
+ (Protected) Create a like-kind instance and seed it from an iterable.
1268
+
1269
+ #### Type Parameters
1270
+
1271
+ ##### TK
1272
+
1273
+ `TK` = `K`
1274
+
1275
+ ##### TV
1276
+
1277
+ `TV` = `V`
1278
+
1279
+ ##### TR
1280
+
1281
+ `TR` = \[`TK`, `TV`\]
1282
+
1283
+ #### Parameters
1284
+
1285
+ ##### entries?
1286
+
1287
+ `Iterable`\<`TR` \| \[`TK`, `TV`\]\> = `[]`
1288
+
1289
+ Iterable used to seed the new map.
1290
+
1291
+ ##### options?
1292
+
1293
+ `any`
1294
+
1295
+ Options forwarded to the constructor.
1296
+
1297
+ #### Returns
1298
+
1299
+ `any`
1300
+
1301
+ A like-kind map instance.
1302
+
1303
+ #### Remarks
1304
+
1305
+ Time O(N), Space O(N)
1306
+
1307
+ ***
1308
+
1309
+ ### \_getIterator()
1310
+
1311
+ ```ts
1312
+ protected _getIterator(): IterableIterator<[K, V]>;
1313
+ ```
1314
+
1315
+ Defined in: [data-structures/hash/hash-map.ts:760](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/hash/hash-map.ts#L760)
1316
+
1317
+ Underlying iterator for the default iteration protocol.
1318
+
1319
+ #### Returns
1320
+
1321
+ `IterableIterator`\<\[`K`, `V`\]\>
1322
+
1323
+ Iterator of `[K, V]`.
1324
+
1325
+ #### Remarks
1326
+
1327
+ Time O(n), Space O(1)
1328
+
1329
+ #### Overrides
1330
+
1331
+ [`IterableEntryBase`](IterableEntryBase.md).[`_getIterator`](IterableEntryBase.md#_getiterator)
1332
+
1333
+ ***