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 * LightWeightMap stores key-value (KV) pairs. Each key must be unique and have only one value. 18 * 19 * @namespace LightWeightMap 20 * @syscap SystemCapability.Utils.Lang 21 * @since 8 22 */ 23/** 24 * LightWeightMap stores key-value (KV) pairs. Each key must be unique and have only one value. 25 * 26 * @namespace LightWeightMap 27 * @syscap SystemCapability.Utils.Lang 28 * @crossplatform 29 * @since 10 30 */ 31declare class LightWeightMap<K, V> { 32 /** 33 * A constructor used to create a LightWeightMap object. 34 * 35 * @throws { BusinessError } 10200012 - The LightWeightMap's constructor cannot be directly invoked. 36 * @syscap SystemCapability.Utils.Lang 37 * @since 8 38 */ 39 /** 40 * A constructor used to create a LightWeightMap object. 41 * 42 * @throws { BusinessError } 10200012 - The LightWeightMap's constructor cannot be directly invoked. 43 * @syscap SystemCapability.Utils.Lang 44 * @crossplatform 45 * @since 10 46 */ 47 constructor(); 48 /** 49 * Gets the element number of the LightWeightMap. 50 * 51 * @syscap SystemCapability.Utils.Lang 52 * @since 8 53 */ 54 /** 55 * Gets the element number of the LightWeightMap. 56 * 57 * @syscap SystemCapability.Utils.Lang 58 * @crossplatform 59 * @since 10 60 */ 61 length: number; 62 /** 63 * Returns whether this map has all the object in a specified map 64 * 65 * @param { LightWeightMap<K, V> } map - map map the Map object to compare 66 * @returns { boolean } the boolean type 67 * @throws { BusinessError } 401 - The type of parameters are invalid. 68 * @throws { BusinessError } 10200011 - The hasAll method cannot be bound. 69 * @syscap SystemCapability.Utils.Lang 70 * @since 8 71 */ 72 /** 73 * Returns whether this map has all the object in a specified map 74 * 75 * @param { LightWeightMap<K, V> } map - map map the Map object to compare 76 * @returns { boolean } the boolean type 77 * @throws { BusinessError } 401 - The type of parameters are invalid. 78 * @throws { BusinessError } 10200011 - The hasAll method cannot be bound. 79 * @syscap SystemCapability.Utils.Lang 80 * @crossplatform 81 * @since 10 82 */ 83 hasAll(map: LightWeightMap<K, V>): boolean; 84 /** 85 * Returns whether a key is contained in this map 86 * 87 * @param { K } key - key key need to determine whether to include the key 88 * @returns { boolean } the boolean type 89 * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. 90 * @syscap SystemCapability.Utils.Lang 91 * @since 8 92 */ 93 /** 94 * Returns whether a key is contained in this map 95 * 96 * @param { K } key - key key need to determine whether to include the key 97 * @returns { boolean } the boolean type 98 * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. 99 * @syscap SystemCapability.Utils.Lang 100 * @crossplatform 101 * @since 10 102 */ 103 hasKey(key: K): boolean; 104 /** 105 * Returns whether a value is contained in this map 106 * 107 * @param { V } value - value value need to determine whether to include the value 108 * @returns { boolean } the boolean type 109 * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. 110 * @syscap SystemCapability.Utils.Lang 111 * @since 8 112 */ 113 /** 114 * Returns whether a value is contained in this map 115 * 116 * @param { V } value - value value need to determine whether to include the value 117 * @returns { boolean } the boolean type 118 * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. 119 * @syscap SystemCapability.Utils.Lang 120 * @crossplatform 121 * @since 10 122 */ 123 hasValue(value: V): boolean; 124 /** 125 * Ensures that the capacity of an LightWeightMap container is greater than or equal to a specified value, 126 * and that the container has all the original objects after capacity expansion 127 * 128 * @param { number } minimumCapacity - minimumCapacity minimumCapacity Minimum capacity to be reserved 129 * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. 130 * @throws { BusinessError } 401 - The type of parameters are invalid. 131 * @syscap SystemCapability.Utils.Lang 132 * @since 8 133 */ 134 /** 135 * Ensures that the capacity of an LightWeightMap container is greater than or equal to a specified value, 136 * and that the container has all the original objects after capacity expansion 137 * 138 * @param { number } minimumCapacity - minimumCapacity minimumCapacity Minimum capacity to be reserved 139 * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. 140 * @throws { BusinessError } 401 - The type of parameters are invalid. 141 * @syscap SystemCapability.Utils.Lang 142 * @crossplatform 143 * @since 10 144 */ 145 increaseCapacityTo(minimumCapacity: number): void; 146 /** 147 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order 148 * 149 * @returns { IterableIterator<[K, V]> } 150 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 151 * @syscap SystemCapability.Utils.Lang 152 * @since 8 153 */ 154 /** 155 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order 156 * 157 * @returns { IterableIterator<[K, V]> } 158 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 159 * @syscap SystemCapability.Utils.Lang 160 * @crossplatform 161 * @since 10 162 */ 163 entries(): IterableIterator<[K, V]>; 164 /** 165 * Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key 166 * 167 * @param { K } key - key key the index in LightWeightMap 168 * @returns { V } value or undefined 169 * @throws { BusinessError } 10200011 - The get method cannot be bound. 170 * @syscap SystemCapability.Utils.Lang 171 * @since 8 172 */ 173 /** 174 * Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key 175 * 176 * @param { K } key - key key the index in LightWeightMap 177 * @returns { V } value or undefined 178 * @throws { BusinessError } 10200011 - The get method cannot be bound. 179 * @syscap SystemCapability.Utils.Lang 180 * @crossplatform 181 * @since 10 182 */ 183 get(key: K): V; 184 /** 185 * Obtains the index of the key equal to a specified key in an LightWeightMap container 186 * 187 * @param { K } key - key key Looking for goals 188 * @returns { number } Subscript corresponding to target 189 * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. 190 * @syscap SystemCapability.Utils.Lang 191 * @since 8 192 */ 193 /** 194 * Obtains the index of the key equal to a specified key in an LightWeightMap container 195 * 196 * @param { K } key - key key Looking for goals 197 * @returns { number } Subscript corresponding to target 198 * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. 199 * @syscap SystemCapability.Utils.Lang 200 * @crossplatform 201 * @since 10 202 */ 203 getIndexOfKey(key: K): number; 204 /** 205 * Obtains the index of the value equal to a specified value in an LightWeightMap container 206 * 207 * @param { V } value - value value Looking for goals 208 * @returns { number } Subscript corresponding to target 209 * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. 210 * @syscap SystemCapability.Utils.Lang 211 * @since 8 212 */ 213 /** 214 * Obtains the index of the value equal to a specified value in an LightWeightMap container 215 * 216 * @param { V } value - value value Looking for goals 217 * @returns { number } Subscript corresponding to target 218 * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. 219 * @syscap SystemCapability.Utils.Lang 220 * @crossplatform 221 * @since 10 222 */ 223 getIndexOfValue(value: V): number; 224 /** 225 * Returns whether the Map object contains elements 226 * 227 * @returns { boolean } the boolean type 228 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 229 * @syscap SystemCapability.Utils.Lang 230 * @since 8 231 */ 232 /** 233 * Returns whether the Map object contains elements 234 * 235 * @returns { boolean } the boolean type 236 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 237 * @syscap SystemCapability.Utils.Lang 238 * @crossplatform 239 * @since 10 240 */ 241 isEmpty(): boolean; 242 /** 243 * Obtains the key at the location identified by index in an LightWeightMap container 244 * 245 * @param { number } index - index index Target subscript for search 246 * @returns { K } the key of key-value pairs 247 * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. 248 * @throws { BusinessError } 10200001 - The value of index is out of range. 249 * @throws { BusinessError } 401 - The type of parameters are invalid. 250 * @syscap SystemCapability.Utils.Lang 251 * @since 8 252 */ 253 /** 254 * Obtains the key at the location identified by index in an LightWeightMap container 255 * 256 * @param { number } index - index index Target subscript for search 257 * @returns { K } the key of key-value pairs 258 * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. 259 * @throws { BusinessError } 10200001 - The value of index is out of range. 260 * @throws { BusinessError } 401 - The type of parameters are invalid. 261 * @syscap SystemCapability.Utils.Lang 262 * @crossplatform 263 * @since 10 264 */ 265 getKeyAt(index: number): K; 266 /** 267 * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container 268 * 269 * @returns { IterableIterator<K> } 270 * @throws { BusinessError } 10200011 - The keys method cannot be bound. 271 * @syscap SystemCapability.Utils.Lang 272 * @since 8 273 */ 274 /** 275 * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container 276 * 277 * @returns { IterableIterator<K> } 278 * @throws { BusinessError } 10200011 - The keys method cannot be bound. 279 * @syscap SystemCapability.Utils.Lang 280 * @crossplatform 281 * @since 10 282 */ 283 keys(): IterableIterator<K>; 284 /** 285 * Adds all element groups in one map to another map 286 * 287 * @param { LightWeightMap<K, V> } map - map map the Map object to add members 288 * @throws { BusinessError } 10200011 - The setAll method cannot be bound. 289 * @throws { BusinessError } 401 - The type of parameters are invalid. 290 * @syscap SystemCapability.Utils.Lang 291 * @since 8 292 */ 293 /** 294 * Adds all element groups in one map to another map 295 * 296 * @param { LightWeightMap<K, V> } map - map map the Map object to add members 297 * @throws { BusinessError } 10200011 - The setAll 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 setAll(map: LightWeightMap<K, V>): void; 304 /** 305 * Adds or updates a(new) key-value pair with a key and value specified for the Map object 306 * 307 * @param { K } key - key key Added or updated targets 308 * @param { V } value - value Added or updated value 309 * @returns { Object } the map object after set 310 * @throws { BusinessError } 10200011 - The set method cannot be bound. 311 * @syscap SystemCapability.Utils.Lang 312 * @since 8 313 */ 314 /** 315 * Adds or updates a(new) key-value pair with a key and value specified for the Map object 316 * 317 * @param { K } key - key key Added or updated targets 318 * @param { V } value - value Added or updated value 319 * @returns { Object } the map object after set 320 * @throws { BusinessError } 10200011 - The set method cannot be bound. 321 * @syscap SystemCapability.Utils.Lang 322 * @crossplatform 323 * @since 10 324 */ 325 set(key: K, value: V): Object; 326 /** 327 * Remove the mapping for this key from this map if present 328 * 329 * @param { K } key - key key Target to be deleted 330 * @returns { V } Target mapped value 331 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 332 * @syscap SystemCapability.Utils.Lang 333 * @since 8 334 */ 335 /** 336 * Remove the mapping for this key from this map if present 337 * 338 * @param { K } key - key key Target to be deleted 339 * @returns { V } Target mapped value 340 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 341 * @syscap SystemCapability.Utils.Lang 342 * @crossplatform 343 * @since 10 344 */ 345 remove(key: K): V; 346 /** 347 * Deletes a key-value pair at the location identified by index from an LightWeightMap container 348 * 349 * @param { number } index - index index Target subscript for search 350 * @returns { boolean } the boolean type(Is there a delete value) 351 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 352 * @throws { BusinessError } 401 - The type of parameters are invalid. 353 * @syscap SystemCapability.Utils.Lang 354 * @since 8 355 */ 356 /** 357 * Deletes a key-value pair at the location identified by index from an LightWeightMap container 358 * 359 * @param { number } index - index index Target subscript for search 360 * @returns { boolean } the boolean type(Is there a delete value) 361 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 362 * @throws { BusinessError } 401 - The type of parameters are invalid. 363 * @syscap SystemCapability.Utils.Lang 364 * @crossplatform 365 * @since 10 366 */ 367 removeAt(index: number): boolean; 368 /** 369 * Removes all of the mapping from this map 370 * The map will be empty after this call returns 371 * 372 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 373 * @syscap SystemCapability.Utils.Lang 374 * @since 8 375 */ 376 /** 377 * Removes all of the mapping from this map 378 * The map will be empty after this call returns 379 * 380 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 381 * @syscap SystemCapability.Utils.Lang 382 * @crossplatform 383 * @since 10 384 */ 385 clear(): void; 386 /** 387 * Sets the value identified by index in an LightWeightMap container to a specified value 388 * 389 * @param { number } index - index index Target subscript for search 390 * @param { V } newValue - newValue value Updated the target mapped value 391 * @returns { boolean } the boolean type(Is there a value corresponding to the subscript) 392 * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. 393 * @throws { BusinessError } 10200001 - The value of index is out of range. 394 * @throws { BusinessError } 401 - The type of parameters are invalid. 395 * @syscap SystemCapability.Utils.Lang 396 * @since 8 397 */ 398 /** 399 * Sets the value identified by index in an LightWeightMap container to a specified value 400 * 401 * @param { number } index - index index Target subscript for search 402 * @param { V } newValue - newValue value Updated the target mapped value 403 * @returns { boolean } the boolean type(Is there a value corresponding to the subscript) 404 * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. 405 * @throws { BusinessError } 10200001 - The value of index is out of range. 406 * @throws { BusinessError } 401 - The type of parameters are invalid. 407 * @syscap SystemCapability.Utils.Lang 408 * @crossplatform 409 * @since 10 410 */ 411 setValueAt(index: number, newValue: V): boolean; 412 /** 413 * Executes the given callback function once for each real key in the map. 414 * It does not perform functions on deleted keys 415 * 416 * @param { (value?: V, key?: K, map?: LightWeightMap<K, V>) => void } callbackFn - callbackFn callbackFn 417 * @param { Object } thisArg - thisArg thisArg 418 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 419 * @throws { BusinessError } 401 - The type of parameters are invalid. 420 * @syscap SystemCapability.Utils.Lang 421 * @since 8 422 */ 423 /** 424 * Executes the given callback function once for each real key in the map. 425 * It does not perform functions on deleted keys 426 * 427 * @param { (value?: V, key?: K, map?: LightWeightMap<K, V>) => void } callbackFn - callbackFn callbackFn 428 * @param { Object } thisArg - thisArg thisArg 429 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 430 * @throws { BusinessError } 401 - The type of parameters are invalid. 431 * @syscap SystemCapability.Utils.Lang 432 * @crossplatform 433 * @since 10 434 */ 435 forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void, thisArg?: Object): void; 436 /** 437 * returns an ES6 iterator.Each item of the iterator is a Javascript Object 438 * 439 * @returns { IterableIterator<[K, V]> } 440 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 441 * @syscap SystemCapability.Utils.Lang 442 * @since 8 443 */ 444 /** 445 * returns an ES6 iterator.Each item of the iterator is a Javascript Object 446 * 447 * @returns { IterableIterator<[K, V]> } 448 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 449 * @syscap SystemCapability.Utils.Lang 450 * @crossplatform 451 * @since 10 452 */ 453 [Symbol.iterator](): IterableIterator<[K, V]>; 454 /** 455 * Obtains a string that contains all the keys and values in an LightWeightMap container 456 * 457 * @returns { String } 458 * @throws { BusinessError } 10200011 - The toString method cannot be bound. 459 * @syscap SystemCapability.Utils.Lang 460 * @since 8 461 */ 462 /** 463 * Obtains a string that contains all the keys and values in an LightWeightMap container 464 * 465 * @returns { String } 466 * @throws { BusinessError } 10200011 - The toString method cannot be bound. 467 * @syscap SystemCapability.Utils.Lang 468 * @crossplatform 469 * @since 10 470 */ 471 toString(): String; 472 /** 473 * Obtains the value identified by index in an LightWeightMap container 474 * 475 * @param { number } index - index index Target subscript for search 476 * @returns { V } the value of key-value pairs 477 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 478 * @throws { BusinessError } 10200001 - The value of index is out of range. 479 * @throws { BusinessError } 401 - The type of parameters are invalid. 480 * @syscap SystemCapability.Utils.Lang 481 * @since 8 482 */ 483 /** 484 * Obtains the value identified by index in an LightWeightMap container 485 * 486 * @param { number } index - index index Target subscript for search 487 * @returns { V } the value of key-value pairs 488 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 489 * @throws { BusinessError } 10200001 - The value of index is out of range. 490 * @throws { BusinessError } 401 - The type of parameters are invalid. 491 * @syscap SystemCapability.Utils.Lang 492 * @crossplatform 493 * @since 10 494 */ 495 getValueAt(index: number): V; 496 /** 497 * Returns an iterator of the values contained in this map 498 * 499 * @returns { IterableIterator<V> } 500 * @throws { BusinessError } 10200011 - The values method cannot be bound. 501 * @syscap SystemCapability.Utils.Lang 502 * @since 8 503 */ 504 /** 505 * Returns an iterator of the values contained in this map 506 * 507 * @returns { IterableIterator<V> } 508 * @throws { BusinessError } 10200011 - The values method cannot be bound. 509 * @syscap SystemCapability.Utils.Lang 510 * @crossplatform 511 * @since 10 512 */ 513 values(): IterableIterator<V>; 514} 515 516export default LightWeightMap; 517