• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkTS
19 */
20
21/**
22 * HashMap is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion,
23 * and removal. The elements in a HashMap instance are mappings of key-value pairs. Each key must be unique and have only one value.
24 *
25 * @syscap SystemCapability.Utils.Lang
26 * @since 8
27 */
28/**
29 * HashMap is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion,
30 * and removal. The elements in a HashMap instance are mappings of key-value pairs. Each key must be unique and have only one value.
31 *
32 * @syscap SystemCapability.Utils.Lang
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * HashMap is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion,
38 * and removal. The elements in a HashMap instance are mappings of key-value pairs. Each key must be unique and have only one value.
39 *
40 * @syscap SystemCapability.Utils.Lang
41 * @crossplatform
42 * @atomicservice
43 * @since 12
44 */
45declare class HashMap<K, V> {
46  /**
47   * A constructor used to create a HashMap object.
48   *
49   * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked.
50   * @syscap SystemCapability.Utils.Lang
51   * @since 8
52   */
53  /**
54   * A constructor used to create a HashMap object.
55   *
56   * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked.
57   * @syscap SystemCapability.Utils.Lang
58   * @crossplatform
59   * @since 10
60   */
61  /**
62   * A constructor used to create a HashMap object.
63   *
64   * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked.
65   * @syscap SystemCapability.Utils.Lang
66   * @crossplatform
67   * @atomicservice
68   * @since 12
69   */
70  constructor();
71  /**
72   * Gets the element number of the hashmap.
73   *
74   * @type { number }
75   * @syscap SystemCapability.Utils.Lang
76   * @since 8
77   */
78  /**
79   * Gets the element number of the hashmap.
80   *
81   * @type { number }
82   * @syscap SystemCapability.Utils.Lang
83   * @crossplatform
84   * @since 10
85   */
86  /**
87   * Gets the element number of the hashmap.
88   *
89   * @type { number }
90   * @syscap SystemCapability.Utils.Lang
91   * @crossplatform
92   * @atomicservice
93   * @since 12
94   */
95  length: number;
96  /**
97   * Returns whether the Map object contains elements
98   *
99   * @returns { boolean } the boolean type
100   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
101   * @syscap SystemCapability.Utils.Lang
102   * @since 8
103   */
104  /**
105   * Returns whether the Map object contains elements
106   *
107   * @returns { boolean } the boolean type
108   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
109   * @syscap SystemCapability.Utils.Lang
110   * @crossplatform
111   * @since 10
112   */
113  /**
114   * Returns whether the Map object contains elements
115   *
116   * @returns { boolean } the boolean type
117   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
118   * @syscap SystemCapability.Utils.Lang
119   * @crossplatform
120   * @atomicservice
121   * @since 12
122   */
123  isEmpty(): boolean;
124  /**
125   * Returns whether a key is contained in this map
126   *
127   * @param { K } key - key key need to determine whether to include the key
128   * @returns { boolean } the boolean type
129   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
130   * @syscap SystemCapability.Utils.Lang
131   * @since 8
132   */
133  /**
134   * Returns whether a key is contained in this map
135   *
136   * @param { K } key - key key need to determine whether to include the key
137   * @returns { boolean } the boolean type
138   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
139   * @syscap SystemCapability.Utils.Lang
140   * @crossplatform
141   * @since 10
142   */
143  /**
144   * Returns whether a key is contained in this map
145   *
146   * @param { K } key - key key need to determine whether to include the key
147   * @returns { boolean } the boolean type
148   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
149   * @syscap SystemCapability.Utils.Lang
150   * @crossplatform
151   * @atomicservice
152   * @since 12
153   */
154  hasKey(key: K): boolean;
155  /**
156   * Returns whether a value is contained in this map
157   *
158   * @param { V } value - value value need to determine whether to include the value
159   * @returns { boolean } the boolean type
160   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
161   * @syscap SystemCapability.Utils.Lang
162   * @since 8
163   */
164  /**
165   * Returns whether a value is contained in this map
166   *
167   * @param { V } value - value value need to determine whether to include the value
168   * @returns { boolean } the boolean type
169   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
170   * @syscap SystemCapability.Utils.Lang
171   * @crossplatform
172   * @since 10
173   */
174  /**
175   * Returns whether a value is contained in this map
176   *
177   * @param { V } value - value value need to determine whether to include the value
178   * @returns { boolean } the boolean type
179   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
180   * @syscap SystemCapability.Utils.Lang
181   * @crossplatform
182   * @atomicservice
183   * @since 12
184   */
185  hasValue(value: V): boolean;
186  /**
187   * Returns a specified element in a Map object, or undefined if there is no corresponding element
188   *
189   * @param { K } key - key key the index in HashMap
190   * @returns { V } value or undefined
191   * @throws { BusinessError } 10200011 - The get method cannot be bound.
192   * @syscap SystemCapability.Utils.Lang
193   * @since 8
194   */
195  /**
196   * Returns a specified element in a Map object, or undefined if there is no corresponding element
197   *
198   * @param { K } key - key key the index in HashMap
199   * @returns { V } value or undefined
200   * @throws { BusinessError } 10200011 - The get method cannot be bound.
201   * @syscap SystemCapability.Utils.Lang
202   * @crossplatform
203   * @since 10
204   */
205  /**
206   * Returns a specified element in a Map object, or undefined if there is no corresponding element
207   *
208   * @param { K } key - key key the index in HashMap
209   * @returns { V } value or undefined
210   * @throws { BusinessError } 10200011 - The get method cannot be bound.
211   * @syscap SystemCapability.Utils.Lang
212   * @crossplatform
213   * @atomicservice
214   * @since 12
215   */
216  get(key: K): V;
217  /**
218   * Adds all element groups in one map to another map
219   *
220   * @param { HashMap<K, V> } map - map map the Map object to add members
221   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
222   * @throws { BusinessError } 401 -  Parameter error. Possible causes:
223   * 1.Mandatory parameters are left unspecified;
224   * 2.Incorrect parameter types.
225   * @syscap SystemCapability.Utils.Lang
226   * @since 8
227   */
228  /**
229   * Adds all element groups in one map to another map
230   *
231   * @param { HashMap<K, V> } map - map map the Map object to add members
232   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
233   * @throws { BusinessError } 401 -  Parameter error. Possible causes:
234   * 1.Mandatory parameters are left unspecified;
235   * 2.Incorrect parameter types.
236   * @syscap SystemCapability.Utils.Lang
237   * @crossplatform
238   * @since 10
239   */
240  /**
241   * Adds all element groups in one map to another map
242   *
243   * @param { HashMap<K, V> } map - map map the Map object to add members
244   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
245   * @throws { BusinessError } 401 -  Parameter error. Possible causes:
246   * 1.Mandatory parameters are left unspecified;
247   * 2.Incorrect parameter types.
248   * @syscap SystemCapability.Utils.Lang
249   * @crossplatform
250   * @atomicservice
251   * @since 12
252   */
253  setAll(map: HashMap<K, V>): void;
254  /**
255   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
256   *
257   * @param { K } key - key key Added or updated targets
258   * @param { V } value - value value Added or updated value
259   * @returns { Object } the map object after set
260   * @throws { BusinessError } 10200011 - The set method cannot be bound.
261   * @throws { BusinessError } 401 - Parameter error. Possible causes:
262   * 1.Mandatory parameters are left unspecified.
263   * @syscap SystemCapability.Utils.Lang
264   * @since 8
265   */
266  /**
267   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
268   *
269   * @param { K } key - key key Added or updated targets
270   * @param { V } value - value value Added or updated value
271   * @returns { Object } the map object after set
272   * @throws { BusinessError } 10200011 - The set method cannot be bound.
273   * @throws { BusinessError } 401 - Parameter error. Possible causes:
274   * 1.Mandatory parameters are left unspecified.
275   * @syscap SystemCapability.Utils.Lang
276   * @crossplatform
277   * @since 10
278   */
279  /**
280   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
281   *
282   * @param { K } key - key key Added or updated targets
283   * @param { V } value - value value Added or updated value
284   * @returns { Object } the map object after set
285   * @throws { BusinessError } 10200011 - The set method cannot be bound.
286   * @throws { BusinessError } 401 - Parameter error. Possible causes:
287   * 1.Mandatory parameters are left unspecified.
288   * @syscap SystemCapability.Utils.Lang
289   * @crossplatform
290   * @atomicservice
291   * @since 12
292   */
293  set(key: K, value: V): Object;
294  /**
295   * Remove a specified element from a Map object
296   *
297   * @param { K } key - key key Target to be deleted
298   * @returns { V } Target mapped value
299   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
300   * @syscap SystemCapability.Utils.Lang
301   * @since 8
302   */
303  /**
304   * Remove a specified element from a Map object
305   *
306   * @param { K } key - key key Target to be deleted
307   * @returns { V } Target mapped value
308   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
309   * @syscap SystemCapability.Utils.Lang
310   * @crossplatform
311   * @since 10
312   */
313  /**
314   * Remove a specified element from a Map object
315   *
316   * @param { K } key - key key Target to be deleted
317   * @returns { V } Target mapped value
318   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
319   * @syscap SystemCapability.Utils.Lang
320   * @crossplatform
321   * @atomicservice
322   * @since 12
323   */
324  remove(key: K): V;
325  /**
326   * Clear all element groups in the map
327   *
328   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
329   * @syscap SystemCapability.Utils.Lang
330   * @since 8
331   */
332  /**
333   * Clear all element groups in the map
334   *
335   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
336   * @syscap SystemCapability.Utils.Lang
337   * @crossplatform
338   * @since 10
339   */
340  /**
341   * Clear all element groups in the map
342   *
343   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
344   * @syscap SystemCapability.Utils.Lang
345   * @crossplatform
346   * @atomicservice
347   * @since 12
348   */
349  clear(): void;
350  /**
351   * Returns a new Iterator object that contains the keys contained in this map
352   *
353   * @returns { IterableIterator<K> }
354   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
355   * @syscap SystemCapability.Utils.Lang
356   * @since 8
357   */
358  /**
359   * Returns a new Iterator object that contains the keys contained in this map
360   *
361   * @returns { IterableIterator<K> }
362   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
363   * @syscap SystemCapability.Utils.Lang
364   * @crossplatform
365   * @since 10
366   */
367  /**
368   * Returns a new Iterator object that contains the keys contained in this map
369   *
370   * @returns { IterableIterator<K> }
371   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
372   * @syscap SystemCapability.Utils.Lang
373   * @crossplatform
374   * @atomicservice
375   * @since 12
376   */
377  keys(): IterableIterator<K>;
378  /**
379   * Returns a new Iterator object that contains the values contained in this map
380   *
381   * @returns { IterableIterator<V> }
382   * @throws { BusinessError } 10200011 - The values method cannot be bound.
383   * @syscap SystemCapability.Utils.Lang
384   * @since 8
385   */
386  /**
387   * Returns a new Iterator object that contains the values contained in this map
388   *
389   * @returns { IterableIterator<V> }
390   * @throws { BusinessError } 10200011 - The values method cannot be bound.
391   * @syscap SystemCapability.Utils.Lang
392   * @crossplatform
393   * @since 10
394   */
395  /**
396   * Returns a new Iterator object that contains the values contained in this map
397   *
398   * @returns { IterableIterator<V> }
399   * @throws { BusinessError } 10200011 - The values method cannot be bound.
400   * @syscap SystemCapability.Utils.Lang
401   * @crossplatform
402   * @atomicservice
403   * @since 12
404   */
405  values(): IterableIterator<V>;
406  /**
407   * Replace the old value by new value corresponding to the specified key
408   *
409   * @param { K } key - key key Updated targets
410   * @param { V } newValue - newValue newValue Updated the target mapped value
411   * @returns { boolean } the boolean type(Is there a target pointed to by the key)
412   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
413   * @syscap SystemCapability.Utils.Lang
414   * @since 8
415   */
416  /**
417   * Replace the old value by new value corresponding to the specified key
418   *
419   * @param { K } key - key key Updated targets
420   * @param { V } newValue - newValue newValue Updated the target mapped value
421   * @returns { boolean } the boolean type(Is there a target pointed to by the key)
422   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
423   * @syscap SystemCapability.Utils.Lang
424   * @crossplatform
425   * @since 10
426   */
427  /**
428   * Replace the old value by new value corresponding to the specified key
429   *
430   * @param { K } key - key key Updated targets
431   * @param { V } newValue - newValue newValue Updated the target mapped value
432   * @returns { boolean } the boolean type(Is there a target pointed to by the key)
433   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
434   * @syscap SystemCapability.Utils.Lang
435   * @crossplatform
436   * @atomicservice
437   * @since 12
438   */
439  replace(key: K, newValue: V): boolean;
440  /**
441   * Executes the given callback function once for each real key in the map.
442   * It does not perform functions on deleted keys
443   *
444   * @param { function } callbackFn - callbackFn
445   * callbackFn (required) A function that accepts up to three arguments.
446   * The function to be called for each element.
447   * @param { Object } [thisArg] - thisArg
448   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
449   * If thisArg is omitted, undefined is used as the this value.
450   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
451   * @throws { BusinessError } 401 - Parameter error. Possible causes:
452   * 1.Mandatory parameters are left unspecified;
453   * 2.Incorrect parameter types.
454   * @syscap SystemCapability.Utils.Lang
455   * @since 8
456   */
457  /**
458   * Executes the given callback function once for each real key in the map.
459   * It does not perform functions on deleted keys
460   *
461   * @param { function } callbackFn - callbackFn
462   * callbackFn (required) A function that accepts up to three arguments.
463   * The function to be called for each element.
464   * @param { Object } [thisArg] - thisArg
465   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
466   * If thisArg is omitted, undefined is used as the this value.
467   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
468   * @throws { BusinessError } 401 - Parameter error. Possible causes:
469   * 1.Mandatory parameters are left unspecified;
470   * 2.Incorrect parameter types.
471   * @syscap SystemCapability.Utils.Lang
472   * @crossplatform
473   * @since 10
474   */
475  /**
476   * Executes the given callback function once for each real key in the map.
477   * It does not perform functions on deleted keys
478   *
479   * @param { function } callbackFn - callbackFn
480   * callbackFn (required) A function that accepts up to three arguments.
481   * The function to be called for each element.
482   * @param { Object } [thisArg] - thisArg
483   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
484   * If thisArg is omitted, undefined is used as the this value.
485   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
486   * @throws { BusinessError } 401 - Parameter error. Possible causes:
487   * 1.Mandatory parameters are left unspecified;
488   * 2.Incorrect parameter types.
489   * @syscap SystemCapability.Utils.Lang
490   * @crossplatform
491   * @atomicservice
492   * @since 12
493   */
494  forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void, thisArg?: Object): void;
495  /**
496   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
497   *
498   * @returns { IterableIterator<[K, V]> }
499   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
500   * @syscap SystemCapability.Utils.Lang
501   * @since 8
502   */
503  /**
504   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
505   *
506   * @returns { IterableIterator<[K, V]> }
507   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
508   * @syscap SystemCapability.Utils.Lang
509   * @crossplatform
510   * @since 10
511   */
512  /**
513   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
514   *
515   * @returns { IterableIterator<[K, V]> }
516   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
517   * @syscap SystemCapability.Utils.Lang
518   * @crossplatform
519   * @atomicservice
520   * @since 12
521   */
522  entries(): IterableIterator<[K, V]>;
523  /**
524   * returns an iterator.Each item of the iterator is a Javascript Object
525   *
526   * @returns { IterableIterator<[K, V]> }
527   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
528   * @syscap SystemCapability.Utils.Lang
529   * @since 8
530   */
531  /**
532   * returns an iterator.Each item of the iterator is a Javascript Object
533   *
534   * @returns { IterableIterator<[K, V]> }
535   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
536   * @syscap SystemCapability.Utils.Lang
537   * @crossplatform
538   * @since 10
539   */
540  /**
541   * returns an iterator.Each item of the iterator is a Javascript Object
542   *
543   * @returns { IterableIterator<[K, V]> }
544   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
545   * @syscap SystemCapability.Utils.Lang
546   * @crossplatform
547   * @atomicservice
548   * @since 12
549   */
550  [Symbol.iterator](): IterableIterator<[K, V]>;
551}
552
553export default HashMap;
554