• 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 * HashMap is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion,
18 * and removal. The elements in a HashMap instance are mappings of key-value pairs. Each key must be unique and have only one value.
19 *
20 * @namespace HashMap
21 * @syscap SystemCapability.Utils.Lang
22 * @since 8
23 */
24/**
25 * HashMap is a map implemented based on the array, linked list, and red-black tree. It provides efficient data query, insertion,
26 * and removal. The elements in a HashMap instance are mappings of key-value pairs. Each key must be unique and have only one value.
27 *
28 * @namespace HashMap
29 * @syscap SystemCapability.Utils.Lang
30 * @crossplatform
31 * @since 10
32 */
33declare class HashMap<K, V> {
34  /**
35   * A constructor used to create a HashMap object.
36   *
37   * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked.
38   * @syscap SystemCapability.Utils.Lang
39   * @since 8
40   */
41  /**
42   * A constructor used to create a HashMap object.
43   *
44   * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked.
45   * @syscap SystemCapability.Utils.Lang
46   * @crossplatform
47   * @since 10
48   */
49  constructor();
50  /**
51   * Gets the element number of the hashmap.
52   *
53   * @syscap SystemCapability.Utils.Lang
54   * @since 8
55   */
56  /**
57   * Gets the element number of the hashmap.
58   *
59   * @syscap SystemCapability.Utils.Lang
60   * @crossplatform
61   * @since 10
62   */
63  length: number;
64  /**
65   * Returns whether the Map object contains elements
66   *
67   * @returns { boolean } the boolean type
68   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
69   * @syscap SystemCapability.Utils.Lang
70   * @since 8
71   */
72  /**
73   * Returns whether the Map object contains elements
74   *
75   * @returns { boolean } the boolean type
76   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
77   * @syscap SystemCapability.Utils.Lang
78   * @crossplatform
79   * @since 10
80   */
81  isEmpty(): boolean;
82  /**
83   * Returns whether a key is contained in this map
84   *
85   * @param { K } key - key key need to determine whether to include the key
86   * @returns { boolean } the boolean type
87   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
88   * @syscap SystemCapability.Utils.Lang
89   * @since 8
90   */
91  /**
92   * Returns whether a key is contained in this map
93   *
94   * @param { K } key - key key need to determine whether to include the key
95   * @returns { boolean } the boolean type
96   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
97   * @syscap SystemCapability.Utils.Lang
98   * @crossplatform
99   * @since 10
100   */
101  hasKey(key: K): boolean;
102  /**
103   * Returns whether a value is contained in this map
104   *
105   * @param { V } value - value value need to determine whether to include the value
106   * @returns { boolean } the boolean type
107   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
108   * @syscap SystemCapability.Utils.Lang
109   * @since 8
110   */
111  /**
112   * Returns whether a value is contained in this map
113   *
114   * @param { V } value - value value need to determine whether to include the value
115   * @returns { boolean } the boolean type
116   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
117   * @syscap SystemCapability.Utils.Lang
118   * @crossplatform
119   * @since 10
120   */
121  hasValue(value: V): boolean;
122  /**
123   * Returns a specified element in a Map object, or null if there is no corresponding element
124   *
125   * @param { K } key - key key the index in HashMap
126   * @returns { V } value or null
127   * @throws { BusinessError } 10200011 - The get method cannot be bound.
128   * @syscap SystemCapability.Utils.Lang
129   * @since 8
130   */
131  /**
132   * Returns a specified element in a Map object, or null if there is no corresponding element
133   *
134   * @param { K } key - key key the index in HashMap
135   * @returns { V } value or null
136   * @throws { BusinessError } 10200011 - The get method cannot be bound.
137   * @syscap SystemCapability.Utils.Lang
138   * @crossplatform
139   * @since 10
140   */
141  get(key: K): V;
142  /**
143   * Adds all element groups in one map to another map
144   *
145   * @param { HashMap<K, V> } map - map map the Map object to add members
146   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
147   * @throws { BusinessError } 401 - The type of parameters are invalid.
148   * @syscap SystemCapability.Utils.Lang
149   * @since 8
150   */
151  /**
152   * Adds all element groups in one map to another map
153   *
154   * @param { HashMap<K, V> } map - map map the Map object to add members
155   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
156   * @throws { BusinessError } 401 - The type of parameters are invalid.
157   * @syscap SystemCapability.Utils.Lang
158   * @crossplatform
159   * @since 10
160   */
161  setAll(map: HashMap<K, V>): void;
162  /**
163   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
164   *
165   * @param { K } key - key key Added or updated targets
166   * @param { V } value - value value Added or updated value
167   * @returns { Object } the map object after set
168   * @throws { BusinessError } 10200011 - The set method cannot be bound.
169   * @throws { BusinessError } 401 - The type of parameters are invalid.
170   * @syscap SystemCapability.Utils.Lang
171   * @since 8
172   */
173  /**
174   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
175   *
176   * @param { K } key - key key Added or updated targets
177   * @param { V } value - value value Added or updated value
178   * @returns { Object } the map object after set
179   * @throws { BusinessError } 10200011 - The set method cannot be bound.
180   * @throws { BusinessError } 401 - The type of parameters are invalid.
181   * @syscap SystemCapability.Utils.Lang
182   * @crossplatform
183   * @since 10
184   */
185  set(key: K, value: V): Object;
186  /**
187   * Remove a specified element from a Map object
188   *
189   * @param { K } key - key key Target to be deleted
190   * @returns { V } Target mapped value
191   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
192   * @syscap SystemCapability.Utils.Lang
193   * @since 8
194   */
195  /**
196   * Remove a specified element from a Map object
197   *
198   * @param { K } key - key key Target to be deleted
199   * @returns { V } Target mapped value
200   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
201   * @syscap SystemCapability.Utils.Lang
202   * @crossplatform
203   * @since 10
204   */
205  remove(key: K): V;
206  /**
207   * Clear all element groups in the map
208   *
209   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
210   * @syscap SystemCapability.Utils.Lang
211   * @since 8
212   */
213  /**
214   * Clear all element groups in the map
215   *
216   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
217   * @syscap SystemCapability.Utils.Lang
218   * @crossplatform
219   * @since 10
220   */
221  clear(): void;
222  /**
223   * Returns a new Iterator object that contains the keys contained in this map
224   *
225   * @returns { IterableIterator<K> }
226   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
227   * @syscap SystemCapability.Utils.Lang
228   * @since 8
229   */
230  /**
231   * Returns a new Iterator object that contains the keys contained in this map
232   *
233   * @returns { IterableIterator<K> }
234   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
235   * @syscap SystemCapability.Utils.Lang
236   * @crossplatform
237   * @since 10
238   */
239  keys(): IterableIterator<K>;
240  /**
241   * Returns a new Iterator object that contains the values contained in this map
242   *
243   * @returns { IterableIterator<V> }
244   * @throws { BusinessError } 10200011 - The values method cannot be bound.
245   * @syscap SystemCapability.Utils.Lang
246   * @since 8
247   */
248  /**
249   * Returns a new Iterator object that contains the values contained in this map
250   *
251   * @returns { IterableIterator<V> }
252   * @throws { BusinessError } 10200011 - The values method cannot be bound.
253   * @syscap SystemCapability.Utils.Lang
254   * @crossplatform
255   * @since 10
256   */
257  values(): IterableIterator<V>;
258  /**
259   * Replace the old value by new value corresponding to the specified key
260   *
261   * @param { K } key - key key Updated targets
262   * @param { V } newValue - newValue newValue Updated the target mapped value
263   * @returns { boolean } the boolean type(Is there a target pointed to by the key)
264   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
265   * @syscap SystemCapability.Utils.Lang
266   * @since 8
267   */
268  /**
269   * Replace the old value by new value corresponding to the specified key
270   *
271   * @param { K } key - key key Updated targets
272   * @param { V } newValue - newValue newValue Updated the target mapped value
273   * @returns { boolean } the boolean type(Is there a target pointed to by the key)
274   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
275   * @syscap SystemCapability.Utils.Lang
276   * @crossplatform
277   * @since 10
278   */
279  replace(key: K, newValue: V): boolean;
280  /**
281   * Executes the given callback function once for each real key in the map.
282   * It does not perform functions on deleted keys
283   *
284   * @param { (value?: V, key?: K, map?: HashMap<K, V>) => void } callbackFn - callbackFn callbackFn
285   * @param { Object } thisArg - thisArg thisArg
286   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
287   * @throws { BusinessError } 401 - The type of parameters are invalid.
288   * @syscap SystemCapability.Utils.Lang
289   * @since 8
290   */
291  /**
292   * Executes the given callback function once for each real key in the map.
293   * It does not perform functions on deleted keys
294   *
295   * @param { (value?: V, key?: K, map?: HashMap<K, V>) => void } callbackFn - callbackFn callbackFn
296   * @param { Object } thisArg - thisArg thisArg
297   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
298   * @throws { BusinessError } 401 - The type of parameters are invalid.
299   * @syscap SystemCapability.Utils.Lang
300   * @crossplatform
301   * @since 10
302   */
303  forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void, thisArg?: Object): void;
304  /**
305   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
306   *
307   * @returns { IterableIterator<[K, V]> }
308   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
309   * @syscap SystemCapability.Utils.Lang
310   * @since 8
311   */
312  /**
313   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
314   *
315   * @returns { IterableIterator<[K, V]> }
316   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
317   * @syscap SystemCapability.Utils.Lang
318   * @crossplatform
319   * @since 10
320   */
321  entries(): IterableIterator<[K, V]>;
322  /**
323   * returns an iterator.Each item of the iterator is a Javascript Object
324   *
325   * @returns { IterableIterator<[K, V]> }
326   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
327   * @syscap SystemCapability.Utils.Lang
328   * @since 8
329   */
330  /**
331   * returns an iterator.Each item of the iterator is a Javascript Object
332   *
333   * @returns { IterableIterator<[K, V]> }
334   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
335   * @syscap SystemCapability.Utils.Lang
336   * @crossplatform
337   * @since 10
338   */
339  [Symbol.iterator](): IterableIterator<[K, V]>;
340}
341
342export default HashMap;
343