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 * @syscap SystemCapability.Utils.Lang 75 * @since 8 76 */ 77 /** 78 * Gets the element number of the hashmap. 79 * 80 * @syscap SystemCapability.Utils.Lang 81 * @crossplatform 82 * @since 10 83 */ 84 /** 85 * Gets the element number of the hashmap. 86 * 87 * @syscap SystemCapability.Utils.Lang 88 * @crossplatform 89 * @atomicservice 90 * @since 12 91 */ 92 length: number; 93 /** 94 * Returns whether the Map object contains elements 95 * 96 * @returns { boolean } the boolean type 97 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 98 * @syscap SystemCapability.Utils.Lang 99 * @since 8 100 */ 101 /** 102 * Returns whether the Map object contains elements 103 * 104 * @returns { boolean } the boolean type 105 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 106 * @syscap SystemCapability.Utils.Lang 107 * @crossplatform 108 * @since 10 109 */ 110 /** 111 * Returns whether the Map object contains elements 112 * 113 * @returns { boolean } the boolean type 114 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 115 * @syscap SystemCapability.Utils.Lang 116 * @crossplatform 117 * @atomicservice 118 * @since 12 119 */ 120 isEmpty(): boolean; 121 /** 122 * Returns whether a key is contained in this map 123 * 124 * @param { K } key - key key need to determine whether to include the key 125 * @returns { boolean } the boolean type 126 * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. 127 * @syscap SystemCapability.Utils.Lang 128 * @since 8 129 */ 130 /** 131 * Returns whether a key is contained in this map 132 * 133 * @param { K } key - key key need to determine whether to include the key 134 * @returns { boolean } the boolean type 135 * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. 136 * @syscap SystemCapability.Utils.Lang 137 * @crossplatform 138 * @since 10 139 */ 140 /** 141 * Returns whether a key is contained in this map 142 * 143 * @param { K } key - key key need to determine whether to include the key 144 * @returns { boolean } the boolean type 145 * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. 146 * @syscap SystemCapability.Utils.Lang 147 * @crossplatform 148 * @atomicservice 149 * @since 12 150 */ 151 hasKey(key: K): boolean; 152 /** 153 * Returns whether a value is contained in this map 154 * 155 * @param { V } value - value value need to determine whether to include the value 156 * @returns { boolean } the boolean type 157 * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. 158 * @syscap SystemCapability.Utils.Lang 159 * @since 8 160 */ 161 /** 162 * Returns whether a value is contained in this map 163 * 164 * @param { V } value - value value need to determine whether to include the value 165 * @returns { boolean } the boolean type 166 * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. 167 * @syscap SystemCapability.Utils.Lang 168 * @crossplatform 169 * @since 10 170 */ 171 /** 172 * Returns whether a value is contained in this map 173 * 174 * @param { V } value - value value need to determine whether to include the value 175 * @returns { boolean } the boolean type 176 * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. 177 * @syscap SystemCapability.Utils.Lang 178 * @crossplatform 179 * @atomicservice 180 * @since 12 181 */ 182 hasValue(value: V): boolean; 183 /** 184 * Returns a specified element in a Map object, or undefined if there is no corresponding element 185 * 186 * @param { K } key - key key the index in HashMap 187 * @returns { V } value or undefined 188 * @throws { BusinessError } 10200011 - The get method cannot be bound. 189 * @syscap SystemCapability.Utils.Lang 190 * @since 8 191 */ 192 /** 193 * Returns a specified element in a Map object, or undefined if there is no corresponding element 194 * 195 * @param { K } key - key key the index in HashMap 196 * @returns { V } value or undefined 197 * @throws { BusinessError } 10200011 - The get method cannot be bound. 198 * @syscap SystemCapability.Utils.Lang 199 * @crossplatform 200 * @since 10 201 */ 202 /** 203 * Returns a specified element in a Map object, or undefined if there is no corresponding element 204 * 205 * @param { K } key - key key the index in HashMap 206 * @returns { V } value or undefined 207 * @throws { BusinessError } 10200011 - The get method cannot be bound. 208 * @syscap SystemCapability.Utils.Lang 209 * @crossplatform 210 * @atomicservice 211 * @since 12 212 */ 213 get(key: K): V; 214 /** 215 * Adds all element groups in one map to another map 216 * 217 * @param { HashMap<K, V> } map - map map the Map object to add members 218 * @throws { BusinessError } 10200011 - The setAll method cannot be bound. 219 * @throws { BusinessError } 401 - Parameter error. Possible causes: 220 * 1.Mandatory parameters are left unspecified; 221 * 2.Incorrect parameter types. 222 * @syscap SystemCapability.Utils.Lang 223 * @since 8 224 */ 225 /** 226 * Adds all element groups in one map to another map 227 * 228 * @param { HashMap<K, V> } map - map map the Map object to add members 229 * @throws { BusinessError } 10200011 - The setAll method cannot be bound. 230 * @throws { BusinessError } 401 - Parameter error. Possible causes: 231 * 1.Mandatory parameters are left unspecified; 232 * 2.Incorrect parameter types. 233 * @syscap SystemCapability.Utils.Lang 234 * @crossplatform 235 * @since 10 236 */ 237 /** 238 * Adds all element groups in one map to another map 239 * 240 * @param { HashMap<K, V> } map - map map the Map object to add members 241 * @throws { BusinessError } 10200011 - The setAll method cannot be bound. 242 * @throws { BusinessError } 401 - Parameter error. Possible causes: 243 * 1.Mandatory parameters are left unspecified; 244 * 2.Incorrect parameter types. 245 * @syscap SystemCapability.Utils.Lang 246 * @crossplatform 247 * @atomicservice 248 * @since 12 249 */ 250 setAll(map: HashMap<K, V>): void; 251 /** 252 * Adds or updates a(new) key-value pair with a key and value specified for the Map object 253 * 254 * @param { K } key - key key Added or updated targets 255 * @param { V } value - value value Added or updated value 256 * @returns { Object } the map object after set 257 * @throws { BusinessError } 10200011 - The set method cannot be bound. 258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 259 * 1.Mandatory parameters are left unspecified. 260 * @syscap SystemCapability.Utils.Lang 261 * @since 8 262 */ 263 /** 264 * Adds or updates a(new) key-value pair with a key and value specified for the Map object 265 * 266 * @param { K } key - key key Added or updated targets 267 * @param { V } value - value value Added or updated value 268 * @returns { Object } the map object after set 269 * @throws { BusinessError } 10200011 - The set method cannot be bound. 270 * @throws { BusinessError } 401 - Parameter error. Possible causes: 271 * 1.Mandatory parameters are left unspecified. 272 * @syscap SystemCapability.Utils.Lang 273 * @crossplatform 274 * @since 10 275 */ 276 /** 277 * Adds or updates a(new) key-value pair with a key and value specified for the Map object 278 * 279 * @param { K } key - key key Added or updated targets 280 * @param { V } value - value value Added or updated value 281 * @returns { Object } the map object after set 282 * @throws { BusinessError } 10200011 - The set method cannot be bound. 283 * @throws { BusinessError } 401 - Parameter error. Possible causes: 284 * 1.Mandatory parameters are left unspecified. 285 * @syscap SystemCapability.Utils.Lang 286 * @crossplatform 287 * @atomicservice 288 * @since 12 289 */ 290 set(key: K, value: V): Object; 291 /** 292 * Remove a specified element from a Map object 293 * 294 * @param { K } key - key key Target to be deleted 295 * @returns { V } Target mapped value 296 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 297 * @syscap SystemCapability.Utils.Lang 298 * @since 8 299 */ 300 /** 301 * Remove a specified element from a Map object 302 * 303 * @param { K } key - key key Target to be deleted 304 * @returns { V } Target mapped value 305 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 306 * @syscap SystemCapability.Utils.Lang 307 * @crossplatform 308 * @since 10 309 */ 310 /** 311 * Remove a specified element from a Map object 312 * 313 * @param { K } key - key key Target to be deleted 314 * @returns { V } Target mapped value 315 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 316 * @syscap SystemCapability.Utils.Lang 317 * @crossplatform 318 * @atomicservice 319 * @since 12 320 */ 321 remove(key: K): V; 322 /** 323 * Clear all element groups in the map 324 * 325 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 326 * @syscap SystemCapability.Utils.Lang 327 * @since 8 328 */ 329 /** 330 * Clear all element groups in the map 331 * 332 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 333 * @syscap SystemCapability.Utils.Lang 334 * @crossplatform 335 * @since 10 336 */ 337 /** 338 * Clear all element groups in the map 339 * 340 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 341 * @syscap SystemCapability.Utils.Lang 342 * @crossplatform 343 * @atomicservice 344 * @since 12 345 */ 346 clear(): void; 347 /** 348 * Returns a new Iterator object that contains the keys contained in this map 349 * 350 * @returns { IterableIterator<K> } 351 * @throws { BusinessError } 10200011 - The keys method cannot be bound. 352 * @syscap SystemCapability.Utils.Lang 353 * @since 8 354 */ 355 /** 356 * Returns a new Iterator object that contains the keys contained in this map 357 * 358 * @returns { IterableIterator<K> } 359 * @throws { BusinessError } 10200011 - The keys method cannot be bound. 360 * @syscap SystemCapability.Utils.Lang 361 * @crossplatform 362 * @since 10 363 */ 364 /** 365 * Returns a new Iterator object that contains the keys contained in this map 366 * 367 * @returns { IterableIterator<K> } 368 * @throws { BusinessError } 10200011 - The keys method cannot be bound. 369 * @syscap SystemCapability.Utils.Lang 370 * @crossplatform 371 * @atomicservice 372 * @since 12 373 */ 374 keys(): IterableIterator<K>; 375 /** 376 * Returns a new Iterator object that contains the values contained in this map 377 * 378 * @returns { IterableIterator<V> } 379 * @throws { BusinessError } 10200011 - The values method cannot be bound. 380 * @syscap SystemCapability.Utils.Lang 381 * @since 8 382 */ 383 /** 384 * Returns a new Iterator object that contains the values contained in this map 385 * 386 * @returns { IterableIterator<V> } 387 * @throws { BusinessError } 10200011 - The values method cannot be bound. 388 * @syscap SystemCapability.Utils.Lang 389 * @crossplatform 390 * @since 10 391 */ 392 /** 393 * Returns a new Iterator object that contains the values contained in this map 394 * 395 * @returns { IterableIterator<V> } 396 * @throws { BusinessError } 10200011 - The values method cannot be bound. 397 * @syscap SystemCapability.Utils.Lang 398 * @crossplatform 399 * @atomicservice 400 * @since 12 401 */ 402 values(): IterableIterator<V>; 403 /** 404 * Replace the old value by new value corresponding to the specified key 405 * 406 * @param { K } key - key key Updated targets 407 * @param { V } newValue - newValue newValue Updated the target mapped value 408 * @returns { boolean } the boolean type(Is there a target pointed to by the key) 409 * @throws { BusinessError } 10200011 - The replace method cannot be bound. 410 * @syscap SystemCapability.Utils.Lang 411 * @since 8 412 */ 413 /** 414 * Replace the old value by new value corresponding to the specified key 415 * 416 * @param { K } key - key key Updated targets 417 * @param { V } newValue - newValue newValue Updated the target mapped value 418 * @returns { boolean } the boolean type(Is there a target pointed to by the key) 419 * @throws { BusinessError } 10200011 - The replace method cannot be bound. 420 * @syscap SystemCapability.Utils.Lang 421 * @crossplatform 422 * @since 10 423 */ 424 /** 425 * Replace the old value by new value corresponding to the specified key 426 * 427 * @param { K } key - key key Updated targets 428 * @param { V } newValue - newValue newValue Updated the target mapped value 429 * @returns { boolean } the boolean type(Is there a target pointed to by the key) 430 * @throws { BusinessError } 10200011 - The replace method cannot be bound. 431 * @syscap SystemCapability.Utils.Lang 432 * @crossplatform 433 * @atomicservice 434 * @since 12 435 */ 436 replace(key: K, newValue: V): boolean; 437 /** 438 * Executes the given callback function once for each real key in the map. 439 * It does not perform functions on deleted keys 440 * 441 * @param { function } callbackFn - callbackFn 442 * callbackFn (required) A function that accepts up to three arguments. 443 * The function to be called for each element. 444 * @param { Object } [thisArg] - thisArg 445 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 446 * If thisArg is omitted, undefined is used as the this value. 447 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 448 * @throws { BusinessError } 401 - Parameter error. Possible causes: 449 * 1.Mandatory parameters are left unspecified; 450 * 2.Incorrect parameter types. 451 * @syscap SystemCapability.Utils.Lang 452 * @since 8 453 */ 454 /** 455 * Executes the given callback function once for each real key in the map. 456 * It does not perform functions on deleted keys 457 * 458 * @param { function } callbackFn - callbackFn 459 * callbackFn (required) A function that accepts up to three arguments. 460 * The function to be called for each element. 461 * @param { Object } [thisArg] - thisArg 462 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 463 * If thisArg is omitted, undefined is used as the this value. 464 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 466 * 1.Mandatory parameters are left unspecified; 467 * 2.Incorrect parameter types. 468 * @syscap SystemCapability.Utils.Lang 469 * @crossplatform 470 * @since 10 471 */ 472 /** 473 * Executes the given callback function once for each real key in the map. 474 * It does not perform functions on deleted keys 475 * 476 * @param { function } callbackFn - callbackFn 477 * callbackFn (required) A function that accepts up to three arguments. 478 * The function to be called for each element. 479 * @param { Object } [thisArg] - thisArg 480 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 481 * If thisArg is omitted, undefined is used as the this value. 482 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 483 * @throws { BusinessError } 401 - Parameter error. Possible causes: 484 * 1.Mandatory parameters are left unspecified; 485 * 2.Incorrect parameter types. 486 * @syscap SystemCapability.Utils.Lang 487 * @crossplatform 488 * @atomicservice 489 * @since 12 490 */ 491 forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void, thisArg?: Object): void; 492 /** 493 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order 494 * 495 * @returns { IterableIterator<[K, V]> } 496 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 497 * @syscap SystemCapability.Utils.Lang 498 * @since 8 499 */ 500 /** 501 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order 502 * 503 * @returns { IterableIterator<[K, V]> } 504 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 505 * @syscap SystemCapability.Utils.Lang 506 * @crossplatform 507 * @since 10 508 */ 509 /** 510 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order 511 * 512 * @returns { IterableIterator<[K, V]> } 513 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 514 * @syscap SystemCapability.Utils.Lang 515 * @crossplatform 516 * @atomicservice 517 * @since 12 518 */ 519 entries(): IterableIterator<[K, V]>; 520 /** 521 * returns an iterator.Each item of the iterator is a Javascript Object 522 * 523 * @returns { IterableIterator<[K, V]> } 524 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 525 * @syscap SystemCapability.Utils.Lang 526 * @since 8 527 */ 528 /** 529 * returns an iterator.Each item of the iterator is a Javascript Object 530 * 531 * @returns { IterableIterator<[K, V]> } 532 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 533 * @syscap SystemCapability.Utils.Lang 534 * @crossplatform 535 * @since 10 536 */ 537 /** 538 * returns an iterator.Each item of the iterator is a Javascript Object 539 * 540 * @returns { IterableIterator<[K, V]> } 541 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 542 * @syscap SystemCapability.Utils.Lang 543 * @crossplatform 544 * @atomicservice 545 * @since 12 546 */ 547 [Symbol.iterator](): IterableIterator<[K, V]>; 548} 549 550export default HashMap; 551