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 * PlainArray stores key-value (KV) pairs. Each key must be unique, be of the number type, and have only one value. 23 * PlainArray is based on generics and uses a lightweight structure. 24 * 25 * @syscap SystemCapability.Utils.Lang 26 * @since 8 27 */ 28/** 29 * PlainArray stores key-value (KV) pairs. Each key must be unique, be of the number type, and have only one value. 30 * PlainArray is based on generics and uses a lightweight structure. 31 * 32 * @syscap SystemCapability.Utils.Lang 33 * @crossplatform 34 * @since 10 35 */ 36declare class PlainArray<T> { 37 /** 38 * A constructor used to create a PlainArray object. 39 * 40 * @throws { BusinessError } 10200012 - The PlainArray's constructor cannot be directly invoked. 41 * @syscap SystemCapability.Utils.Lang 42 * @since 8 43 */ 44 /** 45 * A constructor used to create a PlainArray object. 46 * 47 * @throws { BusinessError } 10200012 - The PlainArray's constructor cannot be directly invoked. 48 * @syscap SystemCapability.Utils.Lang 49 * @crossplatform 50 * @since 10 51 */ 52 constructor(); 53 /** 54 * Gets the element number of the PlainArray. 55 * 56 * @syscap SystemCapability.Utils.Lang 57 * @since 8 58 */ 59 /** 60 * Gets the element number of the PlainArray. 61 * 62 * @syscap SystemCapability.Utils.Lang 63 * @crossplatform 64 * @since 10 65 */ 66 length: number; 67 /** 68 * Appends a key-value pair to PlainArray 69 * 70 * @param { number } key - key key Added the key of key-value 71 * @param { T } value - value value Added the value of key-value 72 * @throws { BusinessError } 10200011 - The add method cannot be bound. 73 * @throws { BusinessError } 401 - The type of parameters are invalid. 74 * @syscap SystemCapability.Utils.Lang 75 * @since 8 76 */ 77 /** 78 * Appends a key-value pair to PlainArray 79 * 80 * @param { number } key - key key Added the key of key-value 81 * @param { T } value - value value Added the value of key-value 82 * @throws { BusinessError } 10200011 - The add method cannot be bound. 83 * @throws { BusinessError } 401 - The type of parameters are invalid. 84 * @syscap SystemCapability.Utils.Lang 85 * @crossplatform 86 * @since 10 87 */ 88 add(key: number, value: T): void; 89 /** 90 * Clears the current PlainArray object 91 * 92 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 93 * @syscap SystemCapability.Utils.Lang 94 * @since 8 95 */ 96 /** 97 * Clears the current PlainArray object 98 * 99 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 100 * @syscap SystemCapability.Utils.Lang 101 * @crossplatform 102 * @since 10 103 */ 104 clear(): void; 105 /** 106 * Obtains a clone of the current PlainArray object 107 * 108 * @returns { PlainArray<T> } 109 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 110 * @syscap SystemCapability.Utils.Lang 111 * @since 8 112 */ 113 /** 114 * Obtains a clone of the current PlainArray object 115 * 116 * @returns { PlainArray<T> } 117 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 118 * @syscap SystemCapability.Utils.Lang 119 * @crossplatform 120 * @since 10 121 */ 122 clone(): PlainArray<T>; 123 /** 124 * Checks whether the current PlainArray object contains the specified key 125 * 126 * @param { number } key - key key need to determine whether to include the key 127 * @returns { boolean } the boolean type 128 * @throws { BusinessError } 10200011 - The has method cannot be bound. 129 * @throws { BusinessError } 401 - The type of parameters are invalid. 130 * @syscap SystemCapability.Utils.Lang 131 * @since 8 132 */ 133 /** 134 * Checks whether the current PlainArray object contains the specified key 135 * 136 * @param { number } key - key key need to determine whether to include the key 137 * @returns { boolean } the boolean type 138 * @throws { BusinessError } 10200011 - The has method cannot be bound. 139 * @throws { BusinessError } 401 - The type of parameters are invalid. 140 * @syscap SystemCapability.Utils.Lang 141 * @crossplatform 142 * @since 10 143 */ 144 has(key: number): boolean; 145 /** 146 * Queries the value associated with the specified key 147 * 148 * @param { number } key - key key Looking for goals 149 * @returns { T } the value of key-value pairs 150 * @throws { BusinessError } 10200011 - The get method cannot be bound. 151 * @throws { BusinessError } 401 - The type of parameters are invalid. 152 * @syscap SystemCapability.Utils.Lang 153 * @since 8 154 */ 155 /** 156 * Queries the value associated with the specified key 157 * 158 * @param { number } key - key key Looking for goals 159 * @returns { T } the value of key-value pairs 160 * @throws { BusinessError } 10200011 - The get method cannot be bound. 161 * @throws { BusinessError } 401 - The type of parameters are invalid. 162 * @syscap SystemCapability.Utils.Lang 163 * @crossplatform 164 * @since 10 165 */ 166 get(key: number): T; 167 /** 168 * Queries the index for a specified key 169 * 170 * @param { number } key - key key Looking for goals 171 * @returns { number } Subscript corresponding to target 172 * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. 173 * @throws { BusinessError } 401 - The type of parameters are invalid. 174 * @syscap SystemCapability.Utils.Lang 175 * @since 8 176 */ 177 /** 178 * Queries the index for a specified key 179 * 180 * @param { number } key - key key Looking for goals 181 * @returns { number } Subscript corresponding to target 182 * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. 183 * @throws { BusinessError } 401 - The type of parameters are invalid. 184 * @syscap SystemCapability.Utils.Lang 185 * @crossplatform 186 * @since 10 187 */ 188 getIndexOfKey(key: number): number; 189 /** 190 * Queries the index for a specified value 191 * 192 * @param { T } value - value value Looking for goals 193 * @returns { number } Subscript corresponding to target 194 * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. 195 * @syscap SystemCapability.Utils.Lang 196 * @since 8 197 */ 198 /** 199 * Queries the index for a specified value 200 * 201 * @param { T } value - value value Looking for goals 202 * @returns { number } Subscript corresponding to target 203 * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. 204 * @syscap SystemCapability.Utils.Lang 205 * @crossplatform 206 * @since 10 207 */ 208 getIndexOfValue(value: T): number; 209 /** 210 * Checks whether the current PlainArray object is empty 211 * 212 * @returns { boolean } the boolean type 213 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 214 * @syscap SystemCapability.Utils.Lang 215 * @since 8 216 */ 217 /** 218 * Checks whether the current PlainArray object is empty 219 * 220 * @returns { boolean } the boolean type 221 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 222 * @syscap SystemCapability.Utils.Lang 223 * @crossplatform 224 * @since 10 225 */ 226 isEmpty(): boolean; 227 /** 228 * Queries the key at a specified index 229 * 230 * @param { number } index - index index Target subscript for search 231 * @returns { number } the key of key-value pairs 232 * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. 233 * @throws { BusinessError } 401 - The type of parameters are invalid. 234 * @syscap SystemCapability.Utils.Lang 235 * @since 8 236 */ 237 /** 238 * Queries the key at a specified index 239 * 240 * @param { number } index - index index Target subscript for search 241 * @returns { number } the key of key-value pairs 242 * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. 243 * @throws { BusinessError } 401 - The type of parameters are invalid. 244 * @syscap SystemCapability.Utils.Lang 245 * @crossplatform 246 * @since 10 247 */ 248 getKeyAt(index: number): number; 249 /** 250 * Remove the key-value pair based on a specified key if it exists and return the value 251 * 252 * @param { number } key - key key Target to be deleted 253 * @returns { T } Target mapped value 254 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 255 * @throws { BusinessError } 401 - The type of parameters are invalid. 256 * @syscap SystemCapability.Utils.Lang 257 * @since 8 258 */ 259 /** 260 * Remove the key-value pair based on a specified key if it exists and return the value 261 * 262 * @param { number } key - key key Target to be deleted 263 * @returns { T } Target mapped value 264 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 265 * @throws { BusinessError } 401 - The type of parameters are invalid. 266 * @syscap SystemCapability.Utils.Lang 267 * @crossplatform 268 * @since 10 269 */ 270 remove(key: number): T; 271 /** 272 * Remove the key-value pair at a specified index if it exists and return the value 273 * 274 * @param { number } index - index index Target subscript for search 275 * @returns { T } the T type 276 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 277 * @throws { BusinessError } 401 - The type of parameters are invalid. 278 * @syscap SystemCapability.Utils.Lang 279 * @since 8 280 */ 281 /** 282 * Remove the key-value pair at a specified index if it exists and return the value 283 * 284 * @param { number } index - index index Target subscript for search 285 * @returns { T } the T type 286 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 287 * @throws { BusinessError } 401 - The type of parameters are invalid. 288 * @syscap SystemCapability.Utils.Lang 289 * @crossplatform 290 * @since 10 291 */ 292 removeAt(index: number): T; 293 /** 294 * Remove a group of key-value pairs from a specified index 295 * 296 * @param { number } index - index index remove start index 297 * @param { number } size - size size Expected deletion quantity 298 * @returns { number } Actual deleted quantity 299 * @throws { BusinessError } 10200011 - The removeRangeFrom method cannot be bound. 300 * @throws { BusinessError } 10200001 - The value of index is out of range. 301 * @throws { BusinessError } 401 - The type of parameters are invalid. 302 * @syscap SystemCapability.Utils.Lang 303 * @since 8 304 */ 305 /** 306 * Remove a group of key-value pairs from a specified index 307 * 308 * @param { number } index - index index remove start index 309 * @param { number } size - size size Expected deletion quantity 310 * @returns { number } Actual deleted quantity 311 * @throws { BusinessError } 10200011 - The removeRangeFrom method cannot be bound. 312 * @throws { BusinessError } 10200001 - The value of index is out of range. 313 * @throws { BusinessError } 401 - The type of parameters are invalid. 314 * @syscap SystemCapability.Utils.Lang 315 * @crossplatform 316 * @since 10 317 */ 318 removeRangeFrom(index: number, size: number): number; 319 /** 320 * Update value on specified index 321 * 322 * @param { number } index - index index Target subscript for search 323 * @param { T } value - value value Updated the target mapped value 324 * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. 325 * @throws { BusinessError } 10200001 - The value of index is out of range. 326 * @throws { BusinessError } 401 - The type of parameters are invalid. 327 * @syscap SystemCapability.Utils.Lang 328 * @since 8 329 */ 330 /** 331 * Update value on specified index 332 * 333 * @param { number } index - index index Target subscript for search 334 * @param { T } value - value value Updated the target mapped value 335 * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. 336 * @throws { BusinessError } 10200001 - The value of index is out of range. 337 * @throws { BusinessError } 401 - The type of parameters are invalid. 338 * @syscap SystemCapability.Utils.Lang 339 * @crossplatform 340 * @since 10 341 */ 342 setValueAt(index: number, value: T): void; 343 /** 344 * Obtains the string representation of the PlainArray object 345 * 346 * @returns { String } 347 * @throws { BusinessError } 10200011 - The toString method cannot be bound. 348 * @syscap SystemCapability.Utils.Lang 349 * @since 8 350 */ 351 /** 352 * Obtains the string representation of the PlainArray object 353 * 354 * @returns { String } 355 * @throws { BusinessError } 10200011 - The toString method cannot be bound. 356 * @syscap SystemCapability.Utils.Lang 357 * @crossplatform 358 * @since 10 359 */ 360 toString(): String; 361 /** 362 * Queries the value at a specified index 363 * 364 * @param { number } index - index index Target subscript for search 365 * @returns { T } the value of key-value pairs 366 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 367 * @throws { BusinessError } 10200001 - The value of index is out of range. 368 * @throws { BusinessError } 401 - The type of parameters are invalid. 369 * @syscap SystemCapability.Utils.Lang 370 * @since 8 371 */ 372 /** 373 * Queries the value at a specified index 374 * 375 * @param { number } index - index index Target subscript for search 376 * @returns { T } the value of key-value pairs 377 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 378 * @throws { BusinessError } 10200001 - The value of index is out of range. 379 * @throws { BusinessError } 401 - The type of parameters are invalid. 380 * @syscap SystemCapability.Utils.Lang 381 * @crossplatform 382 * @since 10 383 */ 384 getValueAt(index: number): T; 385 /** 386 * Executes a provided function once for each value in the PlainArray object. 387 * 388 * @param { function } callbackFn - callbackFn 389 * callbackFn (required) A function that accepts up to three arguments. 390 * The function to be called for each element. 391 * @param { Object } [thisArg] - thisArg 392 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 393 * If thisArg is omitted, undefined is used as the this value. 394 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 395 * @throws { BusinessError } 401 - The type of parameters are invalid. 396 * @syscap SystemCapability.Utils.Lang 397 * @since 8 398 */ 399 /** 400 * Executes a provided function once for each value in the PlainArray object. 401 * 402 * @param { function } callbackFn - callbackFn 403 * callbackFn (required) A function that accepts up to three arguments. 404 * The function to be called for each element. 405 * @param { Object } [thisArg] - thisArg 406 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 407 * If thisArg is omitted, undefined is used as the this value. 408 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 409 * @throws { BusinessError } 401 - The type of parameters are invalid. 410 * @syscap SystemCapability.Utils.Lang 411 * @crossplatform 412 * @since 10 413 */ 414 forEach(callbackFn: (value: T, index?: number, PlainArray?: PlainArray<T>) => void, thisArg?: Object): void; 415 /** 416 * returns an iterator.Each item of the iterator is a Javascript Object 417 * 418 * @returns { IterableIterator<[number, T]> } 419 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 420 * @syscap SystemCapability.Utils.Lang 421 * @since 8 422 */ 423 /** 424 * returns an iterator.Each item of the iterator is a Javascript Object 425 * 426 * @returns { IterableIterator<[number, T]> } 427 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 428 * @syscap SystemCapability.Utils.Lang 429 * @crossplatform 430 * @since 10 431 */ 432 [Symbol.iterator](): IterableIterator<[number, T]>; 433} 434 435export default PlainArray; 436